A trading brain that grades its own homework
An autonomous research system for NSE equities: a four-layer model ensemble that generates signals, paper-trades them, and re-weights itself every market day on what actually happened.
Python · FastAPI · LightGBM · Kronos · TimescaleDB · React
The setup
Retail screeners surface patterns; none of them close the loop. A signal without a recorded outcome, a resolved P&L, and a consequence for the model that produced it is an opinion, not a system.
StockSense treats a trading decision as a pipeline with an audit trail — and treats yesterday’s outcomes as tomorrow’s training signal.
A confident number is not the same as a correct one.
The machine
The hard parts
On the record
The pipeline fires every thirty minutes during market hours. For each of roughly 2,500 tradeable names it loads ~300 daily candles, computes 40-plus engineered features, and asks four models in sequence: a LightGBM classifier supplies the directional prior with its top five SHAP features attached 1; a fine-tuned Kronos foundation model maps a one-to-five-day price path, from which the system interpolates a fractional “touches target in ~2.5 days” estimate; a small macro model scores fourteen sectors from live headlines and nudges confidence by at most ±0.10; and an LLM synthesis pass confirms or rejects the survivors.
The part worth reading twice is not the ensemble but the loop around it. Signals that clear the 0.55 confidence gate are paper-bought automatically, monitored every thirty minutes, and exited on target, stop, or expiry. Resolved trades become structured learnings that are injected into the next cycle’s synthesis prompt as retrieval context 2. Rolling per-model accuracy re-weights the combine hourly, and a drift tracker retrains the LightGBM model when accuracy decays 3.
Validated out of sample by year, the ensemble held 57% directional accuracy 4. The more valuable finding was where it failed — see the errata.
The numbers
| Measure | Value | Source |
|---|---|---|
| Universe | ~2,475 live EQ/BE names | ticker_sync, delisted names pruned |
| Cadence | signals every 30 min in market hours | APScheduler, 12 IST cron jobs |
| Directional accuracy | 57% out-of-sample | validation split by year |
| Autonomy | buy, monitor, exit — no manual buttons | auto_trader.py; watch-only holdings excluded |
Errata & Failures
The re-weighting overfit
The hourly re-weighting looked strong in backtest and decayed out of sample: it was overfitting to recent market regimes. That failure changed how I work — I stopped trusting a model because it returned a confident number and started asking whether it was actually right.
Thin evidence, no tuning
In quiet periods many signals expire without touching target or stop. The nightly calibration deliberately refuses to tune on such weak evidence and records zero changes — silence is a valid calibration result.
■ References