Skip to main content

ml4t-india

Python 3.12+ Free-threaded: experimental

Algorithmic trading for Indian markets (NSE, BSE) on top of the ML4T library ecosystem.

Status: pre-alpha. Phase-1 Zerodha Kite integration complete. Publishing pipeline ready.

What this is

ml4t-india is a thin extension layer that adapts the five ML4T companion libraries to Indian equity and derivatives markets via the Zerodha Kite Connect v3 broker API.

It contributes only what is India-specific. Every generic capability (engine, indicators, diagnostics, risk framework, storage) is delegated to the upstream libraries unchanged:

Upstream library Role India-specific work
ml4t-data DataManager, BaseProvider, storage KiteProvider, bhavcopy providers
ml4t-engineer 120 indicators, labeling, alt bars None — consumed as-is
ml4t-backtest Event-driven engine, Strategy, presets IndianChargesModel, nse_india preset
ml4t-live LiveEngine, SafeBroker, protocols KiteBroker, KiteTickerFeed
ml4t-diagnostic DSR, CPCV, tear sheets Calendar wiring only

Design principles

  • Extend, don't re-implement. Every adapter subclasses the upstream concrete base where one exists (e.g. IndianOHLCVProvider(BaseProvider)). Where upstream only exposes a typing.Protocol, we implement it once in an India-level abstract base (IndianBrokerBase, IndianTickerFeedBase) and every concrete broker extends that — so the protocol is adhered to exactly once.
  • Drift-insulated. The weekly upstream-drift CI job installs the latest ml4t-* from PyPI and re-runs the full suite. Signature-level drift is caught by dedicated snapshot tests.
  • Pure Python. No C extensions of our own, so a single universal wheel serves both GIL and free-threaded CPython. See docs/free-threaded.md.
  • TDD at every adapter boundary. Contract tests verify substitutability for upstream protocols; recorded HTTP cassettes drive integration.

Phase-1 scope (Zerodha, full surface)

  • Historical candles (1m, 3m, 5m, 10m, 15m, 30m, 60m, day), OI, continuous F&O.
  • KiteTicker WebSocket (ltp / quote / full modes, 3000 instruments / connection, 3 connections).
  • Orders: regular / AMO / CO / iceberg / auction.
  • Product types: CNC / MIS / NRML / MTF.
  • Option chain with Greeks (Black-Scholes) and analytics (PCR, max-pain, ATM ladder).
  • Zerodha fee schedule: brokerage + STT + exchange turnover + GST + SEBI + stamp.
  • Bhavcopy bulk providers: NSE / BSE / MCX for long-history backfill.

Installation

pip install ml4t-india           # core
pip install ml4t-india[options]  # + Black-Scholes Greeks
pip install ml4t-india[viz]      # + plotly tear sheets
pip install ml4t-india[all]

Documentation

  • Quickstart — login, historical data, backtesting, option chain, live trading, NSE calendar
  • Integration Testing — real broker smoke tests with OS keychain credential storage (no secrets in git)
  • Releasing — tag-triggered PyPI publish via OIDC + conda-forge recipe workflow

Full documentation will be published to https://shankarpandala.github.io/ml4t-india/ once Phase-1 stabilises.

Integration Testing

Real broker tests run locally against a live Zerodha Kite account. Credentials are stored in the OS keychain — never in .env files, config files, or git.

# Store credentials once (Windows Credential Manager / GNOME Keyring / macOS Keychain)
python scripts/store_kite_credentials.py

# Daily refresh (Kite tokens expire at ~06:00 IST)
python scripts/store_kite_credentials.py --refresh

# Run the 6-test smoke suite
pytest tests/integration -m integration -v

Tests skip cleanly when credentials are absent. They never run on GitHub Actions. See docs/integration-testing.md for VPS/Linux setup, troubleshooting, and security properties.

License

Not licensed yet.

Metadata

Release files for ml4t-india 0.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 ml4t-india 0.1.0
File Size Uploaded Provenance Actions
ml4t_india-0.1.0.tar.gz 108.5 kB With provenance Details for ml4t_india-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ml4t-india 0.1.0
File Interpreter ABI Platform Actions
ml4t_india-0.1.0-py3-none-any.whl Python 3 none any Details for ml4t_india-0.1.0-py3-none-any.whl

Total release size: 192.7 kB

Release files / ml4t_india-0.1.0.tar.gz

Download URL ml4t_india-0.1.0.tar.gz
Size 108.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a37f34024f32e2743e9f100c2fa3d04c92d1118a4a315954d07eeba605e22ba3
BLAKE2b-256 checksum
How to use checksums
c1bd0abe50d4e586d47cb62083cd7cd8615365040b80f2e5f89fb6f081c49a23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Apr 29, 2026.

Transparency log

Release files / ml4t_india-0.1.0-py3-none-any.whl

Download URL ml4t_india-0.1.0-py3-none-any.whl
Size 84.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02ed6ac9c4ff0ad44426b4979e1b2d586a9e4350dd70b0d4bf1005e81c239f22
BLAKE2b-256 checksum
How to use checksums
6b82c4dd5b4675772b5d9003046bf7967ffd23c8c374497905482f29f281bbce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Apr 29, 2026.

Transparency log

Security for ml4t-india 0.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ml4t_india-0.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 Apr 29, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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