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
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.