You state your limits. It returns a ranked book.
Tell it your risk profile, your capital and the limits you will not cross. It scores every stock on four kinds of evidence and marks each one with one of four calls. Change the profile and the same stocks get different answers.
The pillars agree and every limit you set is cleared with room to spare.
Enough evidence, and inside your limits for volatility, drawdown and position size.
Close, but something holds it back. It stays visible with the reason, so a near miss is never dressed up as a pick.
Not enough evidence for this profile. If nothing qualifies, the book says so.
Four kinds of evidence, each one on show.
A single score hides disagreement. Here the four pillars sit side by side for every stock, and you can watch them add up to the call.
Technical
What the price has been doing. Momentum, trend and how jumpy the stock is. Strong momentum adds to the score; high volatility takes away from it.
Fundamental
What the business looks like. Valuation, profitability, debt, margins, dividends and growth, each compared with the other stocks in the universe.
Built from today's ratios only, so it stays out of the trained model. It is a separate score, and it is not part of the validated forecast.Model forecast
What the model expects. Three forecasts for the next 21 trading days: a pessimistic case (P10), a median (P50) and an optimistic case (P90). A wide gap means low confidence.
Portfolio fit
What it does to your book. Recent volatility, worst fall, and how closely the stock moves with what you would already hold.
Then it sizes each position, and shows the cash left over.
Sizing uses Hierarchical Risk Parity. Stocks that move together are grouped, and risk is shared between groups before it is shared within them, so three similar bank stocks do not quietly become half your portfolio.
- Group the chosen stocks by how alike their price moves are.
- Split capital down the tree, group by group.
- Cap any position that exceeds your profile's limit.
- Round to whole shares at your capital.
- Show the cash that could not be placed, instead of hiding it.
Ask why, and get an answer per stock.
Every stock page lists the inputs that pushed its forecast up or down, and by how much. If a call rests on one noisy signal, you can see that before you act on it.
The method is SHAP, a standard way to attribute a model's output to its inputs. It starts from the average forecast and adds each input's push until it reaches this stock's number.
21 trading days ahead +1.1%
Tested on data the model never saw.
The model is tuned by walking forward through history five times. Each fold trains on the past and is judged on the block that follows, and the training window grows each time. Because every label looks 21 trading days ahead, 31 trading days are cut out before each test block so nothing leaks backwards.
Then a final stretch that was never used for tuning or feature selection decides the numbers below.
Purged walk-forward validation, drawn to the real dates
of real 21-day outcomes in the hold-out landed inside the P10 to P90 range. A well-calibrated range would hold 80%.
The range held up.The stock-picking did not.
A simple backtest that held the five highest forecasts did not beat holding every stock equally.
So this is a tool for calibrated ranges, visible evidence and sizing discipline. It is not a way to beat the market, and it does not claim to be.
Figures for the current model are published on the Validation page of the app. These are backtest measurements on past data. They are not live performance and they do not predict or promise future returns. This is a research and education tool, not investment advice.
A plan for getting in, in stages.
The portfolio page lays out a staged schedule for building the positions instead of one large order. It is a plan for you to read and adapt. The product sends nothing to a broker.
Live NSE prices, kept apart from the forecast.
Connect an Upstox or Zerodha market feed and live quotes appear as an overlay. The daily forecast is not quietly recalculated on every tick. If live price action weakens a BUY to a WATCH, the page tells you the change came from the live layer, and shows the feed's status and last tick.
Under the hood
For the examiners. Built for the course AI and ML for Digital Business Managers as a capstone, in Python end to end. Eight steps take daily prices to a sized, explained book.
60 NSE large caps, 12 sectors
Five liquid large caps from each of 12 sectors. Daily adjusted prices and volume from Yahoo Finance, 19 Feb 2018 to 8 Oct 2026. The target is each stock's return over the next 21 trading days.
A known gap: the universe is today's large caps, so companies that failed or shrank earlier are missing. That flatters any backtest.
19 candidate features, 10 kept
Every input is a return, ratio or oscillator built from price and volume. Many measure the same thing, so a mutual-information selection with a redundancy penalty keeps one of each kind. It runs on development data only.
Company fundamentals are not model inputs. Only today's ratios exist, and using them on past dates would leak the future. They feed the app's separate fundamental score instead.
Purged walk-forward, then a hold-out
Five expanding folds. Each trains on the past and validates on the next block, with 31 trading days removed in between: 21 for the label's look-ahead and 10 more as an embargo. A final hold-out period is kept away from tuning and feature selection.
Reported: pinball loss, mean absolute error, RMSE, directional accuracy, rank information coefficient, range coverage and realised return by signal.
Three quantile models, tuned small
Three LightGBM regressors with quantile (pinball) loss at 0.10, 0.50 and 0.90. The gap between P10 and P90 is the uncertainty measure. A random search tried 25 hyperparameter settings across 5 folds and 3 quantiles.
The search picked very small trees: 4 leaves, 100 trees. With a weak signal, complex trees fit noise. Against a baseline that uses no features at all, the tuned model was level in cross-validation and slightly ahead on the hold-out.
Four scores, weighted by profile
The technical score, the fundamental score, the model forecast and portfolio fit are combined with weights that depend on your risk profile. Gates on volatility, drawdown and forecast confidence can hold a stock back whatever its score.
The result is one of four states: STRONG BUY, BUY, WATCH or PASS, each with its reason.
Hierarchical Risk Parity, capped
Positions are sized on the correlation structure of the chosen stocks, tilted by the composite evidence, capped per position, and rounded to whole shares at your capital. Whatever cannot be placed is shown as cash.
SHAP on the median model
Each stock page shows that stock's own SHAP values for the current forecast, computed from the trained median model. Across the hold-out the largest drivers were market volatility, six-month momentum, the fractionally differenced price and 63-day volatility.
An optional overlay, clearly labelled
Upstox Market Data Feed V3 or Zerodha Kite WebSocket adapters bring in live quotes. Without one, the app shows a labelled delayed fallback, or no quote at all. The forecast itself only changes when the model is run again.
Run it yourself
One command trains everything from a data snapshot committed to the repository, in about a minute. It writes one artifact; the app reads it and refuses to produce recommendations if it is missing or malformed.
Streamlit interface, optional FastAPI service, LightGBM, SHAP and scikit-learn. 22 tests.
pip install -r requirements.txt
python -m src.model # train, validate, export
streamlit run app.py
What this is not.
It is a research and education tool. Use it to study how evidence, uncertainty and sizing fit together, then make your own decisions.
- It does not beat the market. In the hold-out backtest, its top five picks did worse than holding every stock equally.
- It places no trades. There is no broker connection for orders. Nothing is bought or sold.
- It is not a registered investment adviser. Nothing here is personal investment advice.
- It promises no returns. A forecast is an estimate with a range, and the real outcome can fall outside it.
- A backtest is not a track record. Validation figures describe past data only.
- It is a capstone, not a production system. Real use would still need taxes and market impact, point-in-time fundamentals, paper trading and an independent review.