Skip to main content

Algorithmic trading for Indian markets (NSE, BSE) on top of the ml4t-* ecosystem

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml4t_india-0.1.0.tar.gz (108.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ml4t_india-0.1.0-py3-none-any.whl (84.2 kB view details)

Uploaded Python 3

File details

Details for the file ml4t_india-0.1.0.tar.gz.

File metadata

  • Download URL: ml4t_india-0.1.0.tar.gz
  • Upload date:
  • Size: 108.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ml4t_india-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a37f34024f32e2743e9f100c2fa3d04c92d1118a4a315954d07eeba605e22ba3
MD5 af50e575b1d6dc650eb6a5dfde955ddc
BLAKE2b-256 c1bd0abe50d4e586d47cb62083cd7cd8615365040b80f2e5f89fb6f081c49a23

See more details on using hashes here.

Provenance

The following attestation bundles were made for ml4t_india-0.1.0.tar.gz:

Publisher: publish.yml on shankarpandala/ml4t-india

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ml4t_india-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ml4t_india-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 84.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ml4t_india-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02ed6ac9c4ff0ad44426b4979e1b2d586a9e4350dd70b0d4bf1005e81c239f22
MD5 b64c8103278f8e3bd841eacd0aeaefed
BLAKE2b-256 6b82c4dd5b4675772b5d9003046bf7967ffd23c8c374497905482f29f281bbce

See more details on using hashes here.

Provenance

The following attestation bundles were made for ml4t_india-0.1.0-py3-none-any.whl:

Publisher: publish.yml on shankarpandala/ml4t-india

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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