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.17.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for truedata_ws-0.1.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35db900825c029637bca250cb08daac43fe50f717b28c88f5b210e8da4870517 |
|
MD5 | d938cbf5ef14272dd90285a73ec77e5d |
|
BLAKE2b-256 | e3e5492c5f6d510922e684ad394c2f4abe000be7dd43311ed4089202f0dd6a15 |