Skip to content
All build stories

Python · C++ · Trading

Streaming Kotak Neo market data into AmiBroker in real time

By Rohan Mondal · · 2 min read

A trader wanted live one-minute candles from the Kotak Neo Trade API inside AmiBroker, which has no native connector for it. The result is a market-data bridge: a Python Windows service that talks to Kotak, and a C++ AmiBroker plugin that reads from it. It's market-data only; the source contains no order placement, modification or cancellation calls.

Two programs, one job each

The 64-bit Python service owns everything network-related: the Kotak connection, building one-minute bars, local history and the control interface. The AmiBroker plugin is a 32-bit (x86) C++ DLL, because that's what AmiBroker Standard needs. Keeping them separate means a network hiccup can never freeze the charting software.

Talking over named pipes

The service and plugin communicate over local Windows named pipes using a small, versioned binary protocol, with separate pipes for data and control. Pipe input and output run on worker threads, and AmiBroker's entry points only read thread-safe caches, so they never wait on Kotak or the database.

Honest history

Kotak's scoped Trade API has no documented historical-candle endpoint, so the bridge builds its own history and is careful about it:

  • One-minute bars are stored locally in SQLite with write-ahead logging
  • The live minute is checkpointed every five seconds
  • 365 days are retained by default
  • Candles are never invented to fill an outage; legitimate CSV history can be imported

AmiBroker then builds 5-minute, 15-minute, hourly, daily and higher charts from the one-minute data.

Respecting account limits

The architecture supports up to 3,000 instruments across channels, but a new account stays at 200 until a live capacity probe proves the account can subscribe to more. A failed or inconclusive probe changes nothing, and the service never silently drops instruments. A Nifty 500 import is staged until the limit allows it.

Security for a trading login

Only the consumer key, client code and mobile number are stored, in a restricted file. The TOTP, MPIN and session tokens are never saved: they're entered each morning through hidden prompts and kept only in memory. Logs redact every secret, and release builds refuse to package real secrets or databases.

Related services: Web App & SaaS Development

Want something like this built?

Share a few details and within 24 hours I'll send ideas, a timeline and a free, fixed quote.