An intraday NSE equity-futures signal and execution bot built on the Zerodha Kite API. It scans a NIFTY-50 futures watchlist, scores candidate long/short setups, filters them through a stack of quality and regime gates, sizes positions, and manages exits — with a shadow-logging layer that records the trades it declined to take so the gates can be evaluated after the fact.
Published as an engineering reference. Read the disclaimer first.
This is not financial, investment or trading advice. It is published for educational and engineering reference purposes only.
- Nothing here is a recommendation to trade any instrument or follow any strategy.
- Equity futures are leveraged. Automated execution can lose money faster than you can intervene.
- The author is not a SEBI-registered investment adviser or research analyst.
- The bot ships with no calibrated data. The adaptive-threshold state, watchlist and learned parameters it builds up over time are not in this repository — it starts from nothing and its behaviour on day one is not the behaviour of a tuned system.
- No warranty of any kind. See the additional notice in LICENSE.
Do not point this at a funded account until you have read it end to end and tested it yourself.
- Adaptive thresholds (
core/adaptive_threshold.py) — rather than a fixed score cutoff, a rolling window recomputes the entry threshold from the recent score distribution (p90 + buffer), so the bar moves with market conditions. - Entry quality gates (
core/entry_quality_gates.py) — four direction-aware gates applied before sizing: distance-from-N-day-extreme penalty, a hard R:R floor, volume-confirmed breakout, and a near-support/resistance score adjustment. Written as pure functions, so they're testable in isolation. - Shadow evaluators (
core/rsi_trend_bypass_shadow.py,core/near_miss_entry_shadow.py) — append-only, restart-safe loggers with locked schemas that record the trades a gate rejected. This is the part most bots skip: without it you can never tell whether a filter is saving money or costing it. - RSI outcome tracking (
core/rsi_outcome_tracker.py) — follows rejected symbols forward at 15/30/60-minute intervals and writes an end-of-day report, turning "the RSI gate blocked this" into a measurable claim. - Regime input (
core/molt_regime_reader.py,core/daily_bias_reader.py) — reads an external regime/bias process and applies a threshold offset, fail-safe to zero on stale or missing data. - Observation export (
core/molt_exporter.py) — structured JSONL of decisions, exits and risk events for offline analysis. Strictly one-way: nothing feeds back into live decisions.
- Python 3.10+
- A Zerodha Kite Connect subscription
pip install -r requirements.txt
git clone https://github.com/anandbaid/stockbot.git
cd stockbot
python -m venv .venv
.venv/bin/pip install -r requirements.txt
cp .env.example .env # add your Kite API keyCredentials are read only from the environment. Nothing is hardcoded, and the bot refuses to start without KITE_API_KEY rather than falling back to anything implicit.
python main.pyrefresh_watchlist.py rebuilds the tradeable symbol list.
main.py is ~11,700 lines. That is not a design I'd defend, but it is the honest shape of a system that grew through daily live iteration, and splitting it now would risk behaviour changes I couldn't verify. The reusable, well-factored parts were pulled out into core/ as they stabilised, and those are the modules worth reading first.
- Trading databases, order history, logs, terminal dumps and P&L exports
adaptive_thresholds.json,signal_rejections.jsonand the accumulated learned state- Backtests, research notebooks and the analysis that produced any parameter
- Credentials, tokens and machine-specific launchers
shared.risk_utils, a cross-bot risk governor from the original deployment — the import is optional and falls back to a permissive no-op
python -m pytest tests/MIT, with an additional no-advice / no-warranty notice for trading use — see LICENSE.
Built at Webgrity.