Skip to main content

A Python client for TradingView WebSocket API. Lightweight, real-time data for stocks, crypto, indices, etc.

Project description

pytradingview

A lightweight, open-source Python client for connecting to TradingView's WebSocket API.

Features

  • WebSocket connection management
  • Easy to extend for custom signals and data
  • Download data
  • Search for symbols

Dependencies

websocket-client
requests

Installation

pip install pytradingview

Usage

# example.py
from pytradingview import TVclient

# Create the client and chart
client = TVclient()
chart = client.chart

# Set up the chart
chart.set_up_chart()

# Set the market
chart.set_market("BINANCE:BTCUSD", {
    "timeframe": "1",  # 1-minute chart
    "currency": "USD",
})

# Event: When the symbol data is loaded
chart.on_symbol_loaded(lambda _: print("✅ Market loaded:", chart.get_infos['description']))

# Event: When price data is updated
def handle_update(_):
    if chart.get_periods:
        print(f"🟢 New Price: {chart.get_periods['close']}")

chart.on_update(handle_update)

# Start the WebSocket connection
client.create_connection()

Command line (CLI)

python -m pytradingview -d -s '2025-04-24 00:00' -e '2025-04-25 00:00' -p 'FX:EURUSD' 
python -m pytradingview -d -s '2025-04-24 00:00' -e 'now' -p 'FX:EURUSD'
python -m pytradingview --search EURUSD --max 50

Contributing

Contributions are welcome! Please open issues or PRs to collaborate.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytradingview-0.4.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytradingview-0.4.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file pytradingview-0.4.1.tar.gz.

File metadata

  • Download URL: pytradingview-0.4.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytradingview-0.4.1.tar.gz
Algorithm Hash digest
SHA256 465988e20ec34c62af10cb1f0268eb532dda01501d93b4cf2a1b958f8e081f00
MD5 6bc601d7bd17fa60a3fafc322b557c6f
BLAKE2b-256 67548c6916ca65debde0c230b9043c57d52c2de54d6cb4a6a83ed1164c6a0399

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytradingview-0.4.1.tar.gz:

Publisher: python-publish.yml on kwesy/pytradingview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytradingview-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: pytradingview-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytradingview-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a5ce6c52ef1d60f314cd7b0870660c19d2c478650350bdd8ce17b9c5e8b0fa2
MD5 19a74ef9159d5156e7afb782d863db13
BLAKE2b-256 c15088a0befe564675dbf903ab02d74aa46d7163ed81e2e34028392c6748a11d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytradingview-0.4.1-py3-none-any.whl:

Publisher: python-publish.yml on kwesy/pytradingview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page