Skip to main content

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.4.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distribution

truedata_ws-0.2.4-py3-none-any.whl (25.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page