Skip to main content

tradesmart — Python SDK for the TradeSmart API V2

TradeSmart's official Python client for the TradeSmart API V2. Log in once a day, read your account, find instruments, place and manage orders, and stream live prices and order updates, from plain Python scripts or asyncio programs.

Version 2.2.0. Trading involves real money: read the Orders guide before sending anything that changes state.

What you get

  • Two clients with the same methods: TradeSmart (blocking) and AsyncTradeSmart (asyncio).
  • One-command daily login: python -m tradesmart login; your scripts pick the token up with TradeSmart.from_env(), so no keys live in your code.
  • Orders: place, modify, cancel and exit; large orders sent in slices; GTT (good-till-triggered) orders; OCO (one-cancels-other) exits. Orders are never retried automatically, and an unclear outcome is reported, not guessed.
  • Market data: instrument search, the script master, quotes, candles, option chains, option Greeks.
  • Live streaming: prices and order updates over a WebSocket that reconnects and resubscribes by itself.
  • Typed results: Pydantic models, with prices as Decimal.
  • Offline testing: OfflineBroker runs your strategy against a local fake broker, with no account or network.

New to TradeSmart? Start trading from code in three steps

  1. Open a TradeSmart account online. TradeSmart Fintech Securities Limited is a SEBI-registered stockbroker (NSE, BSE, MCX).
  2. Create your API app on the TradeSmart web platform's API Dashboard: self-service, with no API fee and no approval to wait for, for your own trading.
  3. pip install tradesmart, log in with one command, and place your first order. The getting-started guide takes about 10 minutes.

Open your TradeSmart account → Already a client? Go straight to Get API access.

Install

Python 3.11 to 3.15:

pip install tradesmart

You also need a TradeSmart API app (free, self-service on the TradeSmart web platform's API Dashboard): its App Key (shown as "App ID"), Secret Key, your Client ID, the Redirect URL http://127.0.0.1:8080/callback and your static IP. Step by step: Get API access.

Quick start

Log in once a day (the token is valid until 06:00 IST):

python -m tradesmart login

Then, in your script (illustrative):

from tradesmart import TradeSmart

with TradeSmart.from_env() as client:  # uses the saved login
    print(client.profile().user_id)
    print(client.margins().cash)

New here? Follow Your first order in 10 minutes: API access, install, login, and a first order placed, checked, modified and cancelled.

User guide

Page What is in it
Getting started API access, install, login, first call, first order
Authentication The login command, the token file, from_env(), login in your own server
Orders Every order call, validation, order status, finding an order after an unclear outcome
GTT orders Good-till-triggered orders
OCO orders A target and a stop-loss in one order
Account and portfolio Profile, funds, positions, holdings, trades
Market data Search, script master, quotes, candles, option chains
Option Greeks and analytics Implied volatility, Greeks, chain snapshots, put-call ratio, max pain
Streaming Live prices and order updates
Testing your strategy offline OfflineBroker: fills, rejections, lost replies, dropped streams
Configuration Settings, rate limits, retries, logging
Troubleshooting Error messages and what to do
Reference Every method, model, enum, error and setting; known limitations

Runnable scripts are in examples/, for example a strategy tested offline: offline_strategy_test.py.

Switching from another broker

Guides for moving existing code: migration guides.

Support

Risk notice

Investments in the securities market are subject to market risks; read all the related documents carefully before investing. Automated and API trading can place orders quickly: test your strategy offline first and start with small quantities.

Licence

Apache License 2.0, see LICENSE and NOTICE. Copyright (c) 2026 TradeSmart Fintech Securities Limited.

Metadata

Release files for tradesmart 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradesmart 2.2.0
File Size Uploaded Provenance Actions
tradesmart-2.2.0.tar.gz 203.6 kB With provenance Details for tradesmart-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tradesmart 2.2.0
File Interpreter ABI Platform Actions
tradesmart-2.2.0-py3-none-any.whl Python 3 none any Details for tradesmart-2.2.0-py3-none-any.whl

Total release size: 417.7 kB

Release files / tradesmart-2.2.0.tar.gz

Download URL tradesmart-2.2.0.tar.gz
Size 203.6 kB
Tags Source
SHA-256 checksum
How to use checksums
00c45f2b1e7101fd7d81b8c85fbd1088373adf6ba2a1035e9c621095cbdccdf0
BLAKE2b-256 checksum
How to use checksums
1d52daf9792591168178395808374d9b5a2fafc7def4a7b1ae9648826fc91629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / tradesmart-2.2.0-py3-none-any.whl

Download URL tradesmart-2.2.0-py3-none-any.whl
Size 214.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6dc1c84b32c18567351f9412a43a1bafabe012704026cb1a2040c2fd556299cd
BLAKE2b-256 checksum
How to use checksums
57fd874bdf2ca9c1a344262d5274fafb8ab39fe200342640b559567b35f3863e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for tradesmart 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tradesmart-2.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page