A Python client for TradingView WebSocket API. It's a lightweight library capable of providing real-time data on stocks, cryptocurrencies, 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytradingview-0.4.0.tar.gz.
File metadata
- Download URL: pytradingview-0.4.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e4f40e0c621ffa50a0ee23643108e9da157615408be43507819aec015722509
|
|
| MD5 |
23034a19761fbef364f28a79ead5a19c
|
|
| BLAKE2b-256 |
34fbc4949d7be57aa6df797405013dac67fb73af96365a7bce12ec6583fa2e28
|
File details
Details for the file pytradingview-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pytradingview-0.4.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ab0cc21a946d9f3022a6366a6a085035639dd23756b9e3eb4ef4d0d24ef94a8
|
|
| MD5 |
6e9def7dbafa3dc700ff0d1264785e4e
|
|
| BLAKE2b-256 |
70686bb795a0d30c6b615ae28012fcd4e4f6a9a578ab416475d187118baa6de3
|