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()
Authentication
Guest mode (default):
from pytradingview import TVclient
client = TVclient() # uses TradingView unauthorized_user_token
Auth token mode:
from pytradingview import TVclient
client = TVclient(auth_token="YOUR_TRADINGVIEW_AUTH_TOKEN")
Username/password mode (fetches token via TradingView signin endpoint):
from pytradingview import TVclient
client = TVclient(username="you@example.com", password="your-password")
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
python -m pytradingview -d -p 'CME_MINI:ES1!' -t '1' -s '-1d' -e 'now' --username 'you@example.com' --password 'your-password'
export PYTRADINGVIEW_AUTH_TOKEN='YOUR_TRADINGVIEW_AUTH_TOKEN'
python -m pytradingview -d -p 'CME_MINI:ES1!' -t '1' --start=-2h --end=now -o /tmp/es_1m.csv
Contributing
Contributions are welcome! Please open issues or PRs to collaborate.
Metadata
Release files for pytradingview 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytradingview-0.5.0.tar.gz | 25.1 kB | With provenance | Details for pytradingview-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytradingview-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pytradingview-0.5.0-py3-none-any.whl |
Total release size: 44.9 kB
Release files / pytradingview-0.5.0.tar.gz
| Download URL | pytradingview-0.5.0.tar.gz |
|---|---|
| Size | 25.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a79519b94f4415f3a7b1a474856abdeebdc950fb206da08f1834018aedf48527
|
|
BLAKE2b-256 checksum How to use checksums |
cd6738c6c4ea665c56959b451aa5bc900c7a4fc516af1291aabf32afd7131d48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 11, 2026.
Transparency logRelease files / pytradingview-0.5.0-py3-none-any.whl
| Download URL | pytradingview-0.5.0-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3306b492524b746e839d6312337b1f52c3ef90166f75d3f3f100e8a436122b49
|
|
BLAKE2b-256 checksum How to use checksums |
3458a1b3d1ee11f1e13c2d272d45a379d18e63928f7c74495644f53f6eb96cd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 11, 2026.
Transparency logSecurity for pytradingview 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pytradingview-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.