https://github.com/dearvn/tradingview_ws
Get data realtime from websocket tradingview
https://github.com/dearvn/tradingview_ws
python3 stock tradingview websocket
Last synced: 4 months ago
JSON representation
Get data realtime from websocket tradingview
- Host: GitHub
- URL: https://github.com/dearvn/tradingview_ws
- Owner: dearvn
- License: mit
- Created: 2022-07-08T16:24:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T11:49:35.000Z (almost 3 years ago)
- Last Synced: 2025-06-09T06:17:37.299Z (4 months ago)
- Topics: python3, stock, tradingview, websocket
- Language: Python
- Homepage:
- Size: 39.1 KB
- Stars: 48
- Watchers: 3
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Information
This package to fetch data from tradingview websocket
## Installation# Create an isolated Python virtual environment
pip3 install virtualenv
virtualenv ./virtualenv --python=$(which python3)# Activate the virtualenv
# IMPORTANT: it needs to be activated every time before you run
. virtualenv/bin/activate# Install Python requirements
pip install -r requirements.txt# Install
pip install -e .# run test
python -m test# Using:
* define a callback function get receive result
```
def callbackFunc(s):
print(s)
```* call websocket to get quote price or ohlcv to write a trading bot, data will be delayed 10m if don't use account premium
```
pair = "ES"market = "futures" # 'stock' | 'futures' | 'forex' | 'cfd' | 'crypto' | 'index' | 'economic'
username = None
password = None
trading = td.TradingViewWs(pair, market, username, password)
# get quote price
trading.realtime_quote(callbackFunc)# get ohlcv
interval = 5
total_candle = 240 # total candle to calculate indicator ex: EMA, WMA
trading.realtime_bar_chart(interval, total_candle, callbackFunc)
```