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.1.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
- Open a TradeSmart account online. TradeSmart Fintech Securities Limited is a
SEBI-registered stockbroker (NSE, BSE, MCX).
- 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.
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.