Truedata's Official Python Package
Project description
This is the official python (websocket) repo for TrueData.
What have we covered so far ?
- Websocket APIs
- Live data
- Historical data
How do you use it ?
For beginners
- Installing from PyPi
python3.7 -m pip install truedata
- Connecting
from truedata_ws.websocket.TD import TD
td_app = TD('<enter_your_login_id>', '<enter_your_password>')
- Starting live data
For Single Symbols
req_id = td_app.start_live_data('<enter_symbol>')
# Example:
# req_id = start_live_data('CRUDEOIL-I')
# This returns an integer that can be used later to reference the data
For Multiple symbols
req_ids = td_app.start_live_data(['<symbol_1>', '<symbol_2>', '<symbol_3>', ...])
# Example:
# req_ids = td_app.start_live_data(['CRUDEOIL-I', 'BANKNIFTY-I', 'RELIANCE', 'ITC'])
# This returns a list that can be used to reference data later
- Sample code for testing market data (single symbol)
from copy import deepcopy
live_data_obj = deepcopy(td_app.live_data[req_id])
while True:
if not td_app.live_data[req_id] == live_data_obj:
print(td_app.live_data[req_id])
live_data_obj = deepcopy(td_app.live_data[req_id])
- Sample code for testing market data (multiple symbols)
from copy import deepcopy
live_data_objs = {}
for req_id in req_ids:
live_data_objs[req_id] = deepcopy(td_app.live_data[req_id])
print(live_data_objs[req_id])
while True:
for req_id in req_ids:
if not td_app.live_data[req_id] == live_data_objs[req_id]:
print(td_app.live_data[req_id])
live_data_objs[req_id] = deepcopy(td_app.live_data[req_id])
What is the plan going forward ?
- Ease of contract handling
- Improved error handling
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
truedata_ws-0.1.18.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for truedata_ws-0.1.18-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4761eaf66d933adb048ddfb0eb28f7167bcbdfcdee61000a1d8cb61560ae3aa |
|
MD5 | 0b72bd3afacd5b017d4e02f8e081a4b6 |
|
BLAKE2b-256 | bc25407f7067f09bdfd56bbc847bbf2a8cc98a8c76cfe32fc09e3fd24190d030 |