MP / work / kite-algo repo to navigate
PROJECT · QUANT × CS · BROKER INFRASTRUCTURE

kite-algo

Indian-market broker infrastructure on Kite Connect (Zerodha), built as a sibling to trading-algo. It covers the operator surface, engine loop, order management, reconciliation, and safety controls. Strategy research is intentionally outside this repository.

SURFACE · CLI STATUS · active AUDIT · SEBI-oriented SCOPE · NSE · BSE · NFO · MCX · CDS

Why a sibling

trading-algo was already running on IBKR. A Zerodha sibling buys market coverage: Indian equities, F&O, and commodities trade on different schedules and different microstructure than the US tape. It also forced an honest split between the universal trading-system bits and the broker-specific quirks. Kite has a lot of those: daily token rotation, hard rate limits, no Flex equivalent for historical statements, no greeks in the API. None of that can leak into the engine.

The CLI is the API

From the repo's STATUS table:

Strategies — out of scope for this repository

That's a design choice, not a TODO. kite_tool wraps authentication, account data, quotes, history, locally computed options greeks, gated orders, GTT, margin calculations, mutual funds, alerts, and audit output. Commands support structured formats and stable exit codes.

Order placement takes an --idempotency-key. The replay cache means the same key can be re-issued during a retry without double-filling. IdempotentOrderPlacer uses tag-based + orderbook-polling reconciliation in case the broker response timed out before confirming.

Every action writes a jsonl event to data/audit/*, with fields designed around applicable SEBI audit requirements. That is a design target, not a third-party compliance certification. Multi-leg transactions are explicit groups with a reconcile command, so manual and automated actions have a durable log.

Kite vs IBKR

TopicIBKRKite
SessionPersistentToken rotates ~6am IST daily; OAuth re-login required
Historical statementsFlex Web Service, 365dNone — pull Console CSV manually
GreeksFrom APICompute locally with Black-Scholes
Rate limits~50 req/s3 req/s most endpoints, 10 req/s on /quote
InstrumentsLive lookup70MB CSV dump refreshed daily ~8:30am IST
Product typesMargin / cashCNC (delivery), MIS (intraday, auto-squareoff 15:20), NRML (F&O carry)

kite_tool normalizes these behind one surface so callers do not have to handle each broker quirk separately.

Safety rails

Same layered model as trading-algo. TRADING_ALLOW_LIVE=true is required. TRADING_DRY_RUN=true stages orders without transmitting. Order commands need --yes plus a matching TRADING_ORDER_TOKEN/--confirm-token. The broker-call layer prompts for terminal YES on every place/modify/cancel/bracket.

On top of that, the India-specific guards: market-hours, freeze-quantity, lot-size, and MIS-cutoff checks. SEBI's April 2026 market-protection regime is plumbed through the order placer, so anything that would violate the new rules gets rejected with a structured reason before it reaches Kite. halt / resume flips everything to read-only.

Status

The read-only and broker-operations surfaces cover profile, margins, holdings, positions, orders, trades, history, quotes, instruments, options chains, GTT, mutual funds, alerts, audit, and a kill switch. Order placement includes idempotency and reconciliation; the engine, OMS, risk, and persistence layers are implemented.

The strategy layer is outside this repository. If you work with academic-grade Indian-market data or broker infrastructure and want to compare notes, email me.


mahimn · kite-algo · copy reviewed jul 2026