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.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

  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.1.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.1.0
File Size Uploaded Provenance Actions
tradesmart-2.1.0.tar.gz 184.8 kB With provenance Details for tradesmart-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 379.3 kB

Release files / tradesmart-2.1.0.tar.gz

Download URL tradesmart-2.1.0.tar.gz
Size 184.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a74e5a63a49fc9a0816fa54fdc74978a459ec8ed22e4da6a4c7f56cbba70897c
BLAKE2b-256 checksum
How to use checksums
4efb4ff21cf5754dc95f913153c0334f48fefb3db923ab60cca53d0be17e15e4
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 26, 2026.

Transparency log

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

Download URL tradesmart-2.1.0-py3-none-any.whl
Size 194.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74be92e66e4998d1d10163813558eb678beb1cdd360155bde34ace132918c383
BLAKE2b-256 checksum
How to use checksums
7f4f8acf276e3d19484158d0d2268b13d83f0754db6b0ab9d7518d509aca5ff6
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 26, 2026.

Transparency log

Security for tradesmart 2.1.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.1.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 26, 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