Work

Side project · Nov 2026

AlphaX, a live market-data pipeline for Indian equities

AlphaX is my personal screener for NSE and BSE stocks. It reads live ticks over the broker's WebSocket, turns them into candles, runs a strategy on every closed bar and alerts me on Telegram. It places no orders. I built it to work on the kind of problem mobile rarely gives you: correctness under at-least-once delivery, with a clock that does not stop.

Role
Sole engineer
Status
In development, runs locally
Platforms
Backend, Telegram
Stack
Python 3, asyncio, FastAPI, TimescaleDB, PostgreSQL 17, Redis Streams, SQLAlchemy 2, Alembic, Hypothesis, mypy (strict), import-linter, Docker
from bar close to alert
1–3 sfrom bar close to alert
tests, including property tests
284tests, including property tests
architecture rules enforced in CI
7architecture rules enforced in CI

The pipeline

AlphaX market-data pipelineTicks arrive over the Kite WebSocket, are validated, and are aggregated into candles anchored to the session open. Candles are upserted into a TimescaleDB hypertable and a CandleCompleted event is published on a Redis stream. The strategy runner consumes completed candles, fills gaps from Kite history, evaluates on bar close, records the signal in a table that is unique per bar, and sends batched Telegram alerts.publishconsumefill missing barsKite WebSocketbinary tick frames~234 instrumentsTick validatordrops duplicate, lateand future ticksCandle aggregator1m to 1h bucketsanchored to session openTimescaleDBmarket_candleshypertableRedis hashlatest priceper instrumentmd.candles streamCandleCompletedUUIDv5 id, versionedsignals tableunique per bar,so replays are no-opsKite historygap repair, warm-up1,200 barsStrategy runnerEMA200 + Stoch RSIon bar close onlyTelegrambatched per bar,dropped if > 120s oldsignal path: bar close to alert in about 1–3 s
At-least-once delivery everywhere; exactly-once effects come from deterministic ids and unique constraints.

About 234 instruments stream over a single broker connection, well under its limit of 3,000. Ticks are checked for duplicates, out-of-order arrival and timestamps in the future before they touch a candle. Candles are anchored to the market’s session open, not the wall clock, so a 15-minute bar matches what traders see on their charts.

Decisions and their costs

At-least-once delivery, exactly-once effects. Every event can arrive twice. Instead of fighting that, each effect is made idempotent: candle events get deterministic UUIDv5 ids, so a restart regenerates the same ids, and the signals table is unique per strategy, instrument, timeframe, bar and side, so a replayed signal is a no-op. Event envelopes carry a schema version; an envelope with an unknown version goes to a dead-letter stream instead of being half-understood.

My own indicators, checked against a second implementation. Standard libraries seed their averages differently from the charting platform I compare against, so their numbers disagree for the first few hundred bars. I wrote streaming versions of each indicator and tested them against a separate reference implementation that shares no code with them, using property-based tests over random walks of 2,000 to 4,000 bars.

Never repaint. The strategy evaluates only on a closed bar. Before it starts, it replays at least five times its slowest period of history (1,200 bars). If a bar is missing, it is fetched from history; if it cannot be, that instrument is muted, because a skipped bar silently shifts every indicator after it.

Fail closed, except where failing closed is worse. The worker refuses to start if the exchange holiday calendar for the year is not loaded. But if the database is down when a signal fires, the alert still goes out: a possible duplicate is better than a missed alert.

Boundaries that cannot erode. Seven import-linter contracts fail CI if a module reaches across a layer it should not. Documentation-only boundaries do not survive a busy week.

Status

It runs on my machine against live market data. There is no API authentication yet, so the API binds to localhost only. Research tooling and production hardening are the next two phases.