Kyoto
An options desk, engineered
Phase 1 ✅ · Gate 1 closed
A field manual for the platform · NSE / BSE · 2026

Alpha is engineered,
not discovered. An AI-assisted options desk for Indian derivatives — composed of nine specialised servers, one hundred and sixty-six tools, and a single, unforgiving risk gate.

Kyoto is a Model Context Protocol platform that lets a language model trade NSE/BSE options the way a desk would: read the tape, compute volatility, weigh open interest, structure a strategy, ask a risk manager for permission, route to a broker, and write down every decision in a journal it can later learn from.

9
MCP Servers
166
Registered Tools
4phases
Foundation → Edge
7stages
Trade Lifecycle
18checks
SEBI Pre-Trade Gate
I The Thesis

Three premises, taken seriously.

A trading system is the sum of the assumptions it refuses to violate. Kyoto is built on three.

Premise 01

Volatility risk premium is the edge.

Implied volatility on Indian indices reliably trades at a premium to realised volatility. The platform is biased — by design — toward systematically selling that premium through defined-risk structures, not toward predicting direction.

Premise 02

The risk gate is the product.

A model that can place an order is not a trading system. A model that cannot place an order without passing eighteen SEBI-aware pre-trade checks — ELM, calendar-spread margin, illiquid-strike guards, cost hurdle, vega event warning — is.

Premise 03

Composition beats monoliths.

Nine narrow servers, each fluent in one concern, expose tools through MCP. The language model orchestrates. Every server is independently deployed, individually testable, and owned by a single phase of the trade lifecycle.

II Architecture

Nine servers, four phases.

Read the diagram top to bottom: data, then decision, then survival, then edge. Servers within a phase converse through Redis Streams; events between phases follow a small set of standardised contracts.

Phase 01 Foundation See the market clearly.
01 · :8001 · ✅

Market Data

spot · chain · candles · futures

Live REST surface against Upstox v3 — get_spot_price (5s cache), get_option_chain (30s), get_historical_candles (1h, v3 historical), get_futures_data (5s). WebSocket stream_quotes scheduled in chunk 1.3b.

02 · :8002 · ✅

Volatility Engine

IV · greeks · skew · term · regime

Seven tools live — calc_iv (Newton-Raphson + Brent, matched broker IV within 0.5%), get_greeks, get_skew, get_term_structure, get_vol_regime (ATM-IV proxy), get_iv_rank / get_iv_percentile (return null until history ingestion lands).

Phase 02 Decision Form a view, propose a trade.
03 · :8003

OI Analysis

PCR · max pain · OI shifts

Open-interest concentration, put/call ratio, OI interpolation between NSE three-minute snapshots.

04 · :8004

Strategy Builder

spreads · condors · payoffs

Constructs defined-risk structures, models payoff at expiry and intra-day, returns Pydantic-typed proposals.

Phase 03 Survival Be allowed to trade. Trade. Remember.
05 · :8005

Risk Manager

SEBI · ELM · kill switch

The gate. Eighteen pre-trade checks, delta-based OI position limits, settled-cash verification.

06 · :8006

Trade Executor

demo · paper · live

Single dispatch surface for three executors. Live mode requires explicit human confirmation per trade.

07 · :8007

Trade Journal

audit · attribution · review

Eight-year compliance audit trail; per-trade P&L attribution; structured for backtester replay.

Phase 04 Edge Learn from the past, react to the present.
08 · :8008

News Sentinel

events · keywords · vega warn

Watches institutional newsflow; emits regime-change and event-alert contracts that gate risk and vol.

09 · :8009

Backtester

DuckDB · OLAP · graduation

Replays journaled decisions against historical surfaces; the gate strategies must clear before paper, then live.

Vermillion · Lifecycle node Gold · Inter-phase event contract Teal · Read-only resource Crimson · Risk gate
III The Trade Lifecycle

Seven stages. One unforgiving gate.

Every order — paper or live — flows through the same seven stages. The Risk Manager sits in the middle as a hard gate: a rejected proposal never reaches the broker.

01

Market Data

Spot, depth, candles and option chain pulled from Upstox; cached at 5s / 30s.

02

Vol Engine

IV surface fit, rank, term spread, full Greeks and pricing models.

03

OI Analysis

PCR, max pain, OI clusters; interpolation across NSE 3-min snapshots.

04

Strategy

A defined-risk structure is proposed — typed, scored, costed.

05

Risk Gate

18 SEBI-aware checks. ELM, settled cash, OI limits, cost hurdle, kill-switch state.

06

Executor

Demo (instant), Paper (sim against live tape), or Live (human confirms, broker routes).

07

Journal

Every fill, slippage, fee and decision rationale persisted for eight years.

★ The gate is non-negotiable. A strategy that cannot pass Risk — for instance, an ITM short on expiry day where projected STT exceeds 30% of premium collected — is rejected at stage five and never reaches an executor. The same gate runs in paper and live; only the destination changes.

IV The Nine Servers

Each one, a narrow mind.

Every server speaks MCP. Every server returns the same response shape: a one-line summary, structured data, freshness/source context, and a list of related tools the model might call next.

Phase I · Foundation:8001

Market Data

Quotes, chains, candles, the tape itself.

The single source of truth for spot, depth, option chains and historical candles. Wraps Upstox v2 with circuit-breakers and short TTL caches; emits live tick streams the rest of the platform subscribes to.

22tools
RESTWSCACHE
Phase I · Foundation:8002

Volatility Engine

IV, greeks, skew, term — the maths.

Black-Scholes & QuantLib-backed pricing, full Greeks, IV rank and percentile, term-structure spread between current-week and next-month, surface fitting. The desk's calculator.

26tools
QUANTLIBSCIPY
Phase II · Decision:8003

OI Analysis

Where the institutions are positioned.

Concentration heatmaps, put/call ratio, change-in-OI clustering, max-pain. Synthetically interpolates OI between the NSE three-minute snapshots when confidence permits.

18tools
PCRMAX-PAIN
Phase II · Decision:8004

Strategy Builder

Translates a view into a position.

Constructs verticals, iron condors, butterflies, ratio spreads, calendars. Returns typed proposals with payoff models, breakevens, expected-value, and a costed round-trip estimate.

21tools
PYDANTICPLOTLY
Phase III · Survival:8005

Risk Manager

The gate. The kill switch. The conscience.

Eighteen pre-trade checks aware of SEBI rules: ELM on expiry, calendar-spread margin nullification, settled-cash verification, illiquid-strike guards, vega-event warnings, delta-based OI limits.

19tools
SEBIELMKILL-SW
Phase III · Survival:8006

Trade Executor

Demo, Paper, Live — one dispatch surface.

Single MCP surface dispatching to DemoExecutor, PaperExecutor, or LiveExecutor by TRADING_MODE. Live requires explicit human confirmation per trade. Reconciliation every 30–60 seconds against Upstox.

17tools
UPSTOX V2HUMAN-CONFIRM
Phase III · Survival:8007

Trade Journal

A desk that doesn't remember can't learn.

Every proposal, gate decision, fill, slippage and fee is persisted with eight-year retention to satisfy SEBI compliance — and structured so the Backtester can replay the exact decision context.

15tools
AUDITP&L
Phase IV · Edge:8008

News Sentinel

The market is also a news ticker.

Monitors institutional newsflow against a YAML-driven keyword → risk-multiplier map. Emits regime-change and event-alert contracts the Risk Manager and Vol Engine subscribe to.

12tools
EVENTSVEGA-WARN
Phase IV · Edge:8009

Backtester

The graduation gate from paper to live.

DuckDB-backed OLAP over historical chains and journal events. Replays past decisions against historical IV surfaces; strategies must clear backtest before paper, paper before live.

16tools
DUCKDBPARQUET
V Three Modes, One Surface

From simulated to settled.

The Trade Executor is the only path to a fill. The same MCP tools — place_strategy, modify_order, cancel_all, square_off_all — operate identically across modes; only the executor behind them changes.

TRADING_MODE = demo

Demo

For development & integration tests.

  • Instant simulated fills at last-traded price
  • No broker connection required
  • No slippage, no costs, no margin checks
  • Risk gate runs but is informational
Stage · Local
TRADING_MODE = paper

Paper

Realistic simulation against live tape.

  • Fill simulation against real-time WebSocket prices
  • Full cost modelling — STT, stamp duty, GST, brokerage
  • SPAN margin tracking; configurable starting capital
  • Identical risk gate as live; identical journal entries
Stage · Graduation
TRADING_MODE = live

Live

Real orders, real money, real consequences.

  • Mandatory human confirmation before every trade
  • Manual + automatic kill switch (drawdown, loss streaks, API)
  • Auto square-off, position monitoring, capital tier ramp
  • Compliance audit trail · 8-year retention
Stage · Production
VI The Stack

Boring choices for load-bearing code.

Each layer chosen for one reason. Async wherever the network is; typed wherever the data is; containerised wherever it runs.

Runtime
Python 3.11+
MCP server hosting and tool registration. Async-first, Pydantic everywhere.
Protocol
MCP SDK · FastMCP
Streamable HTTP transport for all nine servers; standardised tool, resource and prompt primitives.
Hot OLTP
PostgreSQL 16 · TimescaleDB
Live ingestion, candles, OI, IV history, portfolio state, audit trail. Six hypertables.
Cold OLAP
DuckDB + Parquet
Backtesting, historical analytics, journal reporting. Daily chunk export from Timescale.
Cache & Bus
Redis 7 · Streams
Quote caching, session state, inter-server event contracts.
Computation
NumPy · SciPy · QuantLib
Black-Scholes, full Greeks, Monte Carlo, surface fitting.
Broker
Upstox v2
Single broker — free API, ~25 req/s, single funded account. No runtime fallback.
Deployment
Docker Compose
All nine servers + Postgres + Redis on one shared network. make up is the entry point.
Observability
Prometheus · Grafana Cloud
Health, latency, error tracking. Alloy agent ships metrics out of the local stack.
VII Compliance & Risk

An algo desk in India is a regulated desk.

SEBI's August-2025 framework around algorithmic trading — static IPs, registered strategies, per-broker order-rate limits — is not a deployment detail. It shapes the architecture.

Pre-trade · 18 checks

SEBI risk gate

ELM (+2% on expiry day), calendar-spread margin nullification, settled-cash verification, delta-based OI position limits, illiquid-strike guards, cost hurdle, vega-event warning.

Audit · 8 years

Compliance trail

Every proposal, gate decision, fill, modification and rationale persisted to a TimescaleDB hypertable with referenced SEBI circulars in sebi_regulatory_params.

Live mode · always

Human-in-the-loop

Live trades require explicit operator confirmation within a configurable window. Default 60 seconds — silence is rejection. Confirmations are journaled.

Single point of failure

Kill switch

emergency_stop() squares off every position and blocks new orders. Manual and automatic (drawdown, consecutive losses, broker API faults). Re-enable is explicit.

Why a single broker.

An earlier draft of this design carried primary-and-fallback broker logic. Indian KYC, SEBI algo registration, static-IP allow-listing, and per-broker SPAN margin allocations make true cross-broker failover infeasible at retail scale. So Kyoto uses Upstox v2 alone — and on outage, the kill switch fires and the operator intervenes.

The most important property of a trading system is the trades it refuses to take.
VIII Roadmap

Four phases, ten to fourteen weeks.

The platform graduates by phase. Each phase ships a coherent slice of the trade lifecycle and is gated by tests and a working integration with the next phase down.

01
Foundation
Gate 1 ✅ closed 28 Apr 2026

Market Data + Volatility Engine shipping eleven tools with Redis caching. 153 unit + 18 live end-to-end tests green; calc_iv matched live broker IV inside half a percent. WebSocket streaming, instrument-master ingestion, IV history and India-VIX feed tracked as 1.3b / 1.4b / 1.7b / 1.7c follow-ups — none gate Phase 1.

02
Decision
Next · Gate 2

OI Analysis + Strategy Builder. Read what institutions are doing through OI snapshots and translate a view into a typed, costed structure with cost-adjusted POP.

03
Survival
Queued · Gate 3

Risk Manager + Trade Executor + Journal. The gate, the dispatcher, the memory. The first phase capable of touching real money.

04
Edge
Queued · Gate 4

News Sentinel + Backtester. Adaptation in real time and learning from the past. Strategies graduate through this gate.