Nifty 50 ML-Enhanced Portfolio Optimization

Nifty 50 universe Mean-variance optimization XGBoost return views Black-Litterman blending Walk-forward backtest Nifty 50 benchmark

Summary

This report studies how classical portfolio theory and machine-learning forecasts can be combined to allocate capital across Nifty 50 large-cap equities on the National Stock Exchange of India.

The investable universe comprises up to thirty liquid index constituents with a full price history from 2016 onward. The Nifty 50 index serves as the market benchmark. A risk-free rate of 6.5% (annualized) proxies the return on long-dated Indian government bonds.

Four portfolio constructions are tracked out-of-sample from late 2021: mean-variance (MV) optimized, ML-enhanced MV (forecast views blended via Black-Litterman, then re-optimized), a cap-weight reference portfolio, and the index itself. Results below are research illustrations of method behaviour—not product recommendations.

Research workflow and data processing

The study follows a repeatable institutional pipeline from raw market inputs to published performance tables. Each stage is designed to avoid look-ahead: only information available at the rebalance date enters the optimizer.

Stage 1 — Universe and prices. Current Nifty 50 membership is screened for listing history. Adjusted daily closing prices are aligned on a common calendar; names with fewer than roughly two years of observations are excluded so covariance and momentum features are stable.

Stage 2 — Feature engineering. For every surviving stock, price series are transformed into technical indicators: short and medium moving averages, relative strength (RSI), MACD, multi-horizon momentum, and rolling volatility. These become inputs to the forecasting model.

Stage 3 — Training window. At each quarterly rebalance, the prior ~30 months of data form the estimation sample. Expected returns and the covariance matrix are computed from daily log returns in this window only.

Stage 4 — Optimization. Two weight vectors are produced: (a) pure MV using historical mean returns, and (b) ML + MV using Black-Litterman posterior returns. Both respect long-only constraints, minimum and maximum position sizes, and a portfolio volatility ceiling.

Stage 5 — Walk-forward simulation. Optimized weights are held for the next quarter. Daily portfolio returns compound; 0.15% slippage is applied proportional to weight turnover at each rebalance. The process advances three months and repeats until the end of the sample.

Stage 6 — Risk analytics and reporting. Cumulative wealth paths, drawdowns, Sharpe and Sortino ratios, beta, alpha, value-at-risk, and sector concentration are summarized for the results section.

Quantitative framework

Daily returns. For stock on day : . The sample covariance matrix uses these returns over the training window; annualized figures scale by 252 trading days.

Mean-variance optimization. Portfolio weights maximize the Sharpe ratio subject to , box constraints , and . When no external view is supplied, expected returns are the sample mean daily returns times 252.

Machine-learning views. A gradient-boosted model predicts the forward five-day return from technical features. Training uses the first 80% of the estimation window chronologically; the last 20% estimates out-of-sample skill (), which maps to view confidence . The raw forecast is annualized and shrunk toward each stock’s historical mean return: .

Black-Litterman blending. Market-cap weights imply equilibrium returns proportional to index performance. Investor views carry diagonal uncertainty inversely related to confidence. With prior scaling , posterior expected returns are:

These posteriors replace in a second MV solve to obtain ML + MV weights.

Performance metrics. Cumulative return compounds daily portfolio returns. CAGR annualizes terminal wealth. Sharpe is excess return over the risk-free rate divided by annualized volatility. Sortino uses downside deviation only. Max drawdown is the worst peak-to-trough decline on the cumulative curve. Beta and alpha come from regressing strategy daily returns on Nifty returns. VaR and CVaR at 95% are historical quantiles of the daily return distribution.

How to interpret the results

Strategy comparison table. Compare CAGR (wealth growth), Sharpe (return per unit of total risk), and max drawdown (worst loss episode). A higher Sharpe with moderate drawdown suggests efficient risk-taking; a high CAGR with deep drawdown may reflect concentrated bets.

If ML + MV outperforms MV only, the machine-learning views are adding information beyond historical means—typically by tilting toward names with favourable short-term technical patterns while the optimizer enforces diversification. If MV only lags cap-weight, pure historical covariance may be a weak signal in fast-moving Indian large caps over this window.

Cumulative performance chart. Parallel wealth indices (rebased to zero excess return at the backtest start) show regime behaviour. Divergence between ML + MV and Nifty indicates periods of active risk; convergence suggests the strategy matched the index.

Risk profile (ML + MV). Beta near one implies market-like sensitivity; below one suggests defensive positioning. Positive alpha is average return unexplained by index exposure. Information ratio scales active return by tracking error versus Nifty. VaR/CVaR describe typical and tail daily losses under the historical distribution.

Sector allocation. Aggregated weights reveal industry concentration—e.g. overweight Financials or IT if the model and optimizer favour those names. Large sector tilts increase idiosyncratic risk relative to the index.

Trading signals. Each row combines a 50-day trend (price versus moving average) with an annualized return forecast. Strong Buy appears when trend and forecast align bullishly; Hold when they conflict. Signals are illustrative rankings at the last training date, not live orders.

Extended analytics. Calendar-year return tables decompose performance by regime. Drawdown and monthly-return charts show *when* risk materialized, not only headline CAGR. Up/down capture and tracking error quantify how closely ML + MV follows or diverges from Nifty in rallies and corrections.

Limitations

Published closing prices may differ from exchange official figures; corporate actions are handled via standard adjustment conventions.

The study uses a subset of thirty Nifty names for computational stability; conclusions may not transfer identically to the full fifty-stock index.

Transaction costs are stylized (slippage on turnover only). Securities transaction tax, stamp duty, brokerage, and market impact are not fully modeled.

Machine-learning forecasts are noisy; out-of-sample is often low for individual stocks, so views are deliberately shrunk toward historical means.

Past backtest performance does not guarantee future results. This document is research output, not investment advice.

Empirical exhibits (below)

The interactive section provides the strategy scorecard (including total return and excess versus Nifty), active-risk analytics, calendar-year returns, drawdown and monthly-return charts, cumulative wealth paths, sector weights, and cross-sectional signals.

Use the scorecard for headline performance, the chart for timing of out- and under-performance, and sector/signal tables for understanding *why* weights shifted—not for trading without independent validation.

Empirical results

Out-of-sample performance from the walk-forward design described above: strategy scorecard, risk analytics, cumulative wealth paths, sector concentration, and cross-sectional signals. Figures refresh when market data are updated.

Empirical results for this study are not loaded yet. Please refresh after the latest market data have been processed.

QuantifiedTrader logoQuantifiedTrader

Independent quantitative research on trading methods, backtesting, and market analytics.

Research disclaimer

QuantifiedTrader is operated by an independent quantitative research group. We study, document, and compare different methods of trading, portfolio construction, risk management, and investment analysis. Our work is exploratory and academic in nature—we build tools, run backtests, and publish findings to advance understanding, not to promote any particular strategy or product.

Not investment advice. Nothing on this website constitutes investment, trading, financial, tax, legal, or other professional advice. We do not recommend, endorse, or solicit the purchase or sale of any security, derivative, or financial instrument, nor do we suggest that any strategy, model, or result presented here is suitable for any individual or institution. Any examples, simulations, or performance figures are illustrative research outputs only.

No client or advisory relationship. We do not provide investment advisory, brokerage, portfolio-management, custody, or asset-management services to any person or entity. Browsing this site, using our tools, or contacting us does not create a client, fiduciary, or advisory relationship. We do not manage money on behalf of third parties and do not act as agents for any financial institution.

Research & education only. Content, datasets, backtests, charts, code, and software made available here are for informational and educational research. Materials may be incomplete, simulated, hypothetical, or derived from third-party sources that we do not control. Past performance, backtested results, and historical analyses are not indicative of future results. Market conditions change; models may fail; assumptions may be wrong. You are solely responsible for evaluating any information and for all decisions you make.

No responsibility or liability. To the fullest extent permitted by applicable law, QuantifiedTrader and its contributors disclaim all responsibility and liability for any loss, damage, cost, or expense—direct or indirect—arising from access to, use of, or reliance on this website, its content, or its tools. All materials are provided “as is” and “as available,” without warranties of any kind, whether express or implied, including but not limited to accuracy, completeness, fitness for a particular purpose, or non-infringement.

Non-commercial research sharing. This site does not aim to profit from the knowledge, tools, or datasets published here. Materials are shared for non-commercial research and learning, subject to applicable open-source or site terms where noted. We are a research collective, not a commercial product or service provider.

Contact. For questions about this notice, the site, or published research materials, contact support@quantedx.com. Correspondence is for administrative and research purposes only and does not constitute advice or create any professional obligation on our part.

© 2026 QuantifiedTrader. All rights reserved.