MP / positions / 02 · kite-algo repo to navigate
POSITION 02 · QUANT × CS · AGENT-NATIVE

kite-algo

Indian-market trading system on Kite Connect (Zerodha). Sibling to trading-algo. Wired for NSE, BSE, NFO, MCX, and CDS. Right now it's mostly the ops side, the engine loop, and the safety rails; strategies live in an LLM agent that drives the CLI, not in the repo.

CLI · 68 commands TESTS · 731 passing AUDIT · SEBI-compliant 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, commodities all trade on different schedules and different microstructure than the US tape — and it 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 (agent-driven; no in-repo strategies) — out of scope

That's a design choice, not a TODO. kite_tool has 68 subcommands wrapping the Kite surface — auth, account, quotes, history, options chains with locally-computed BSM greeks, orders (gated), GTT (single + OCO), margin calc, basket margin, mutual funds, alerts, audit. Every command takes --format json|csv|table, emits a structured envelope, and uses a stable exit-code taxonomy. Strategy lives in the agent calling the CLI, not in the repo.

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 SEBI-compliant jsonl event to data/audit/*. Multi-leg transactions are explicit groups with a reconcile command. There's no path for the agent to do something that doesn't show up in the 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 the agent doesn't have to know which broker quirk it's looking at.

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

Read-only and ops surfaces are done — profile, margins, holdings, positions, orders, trades, order-history, quotes (LTP/OHLC/depth/OI), historical, instruments cache, options chain, GTT (single + OCO), mutual funds, alerts, audit, kill switch. Order placement is live with idempotency and reconciliation. Engine, OMS, risk, and persistence are done. 731 tests passing.

The thing that isn't in the repo is the strategy layer. It lives in a Claude Code agent that calls the CLI. If you've got academic-grade Indian-market data or you're building agent-driven trading infra and want to compare notes, email.


mahimn · kite-algo · last updated apr 2026