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_ws
- 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.2.6.tar.gz
(9.1 kB
view hashes)
Built Distributions
truedata_ws-0.2.6-py3.7.egg
(30.7 kB
view hashes)
Close
Hashes for truedata_ws-0.2.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c8860ff87d9a92167c97b5ff763b8e9506f7e0090363778a1f01bb375544f7f |
|
MD5 | e16a994a17d240e9b2aebed92a84fd0d |
|
BLAKE2b-256 | ab7e0c65e4f2cf3d738a9630534c4a424c2590c7b4f9d09591a3351168db0b65 |