A portfolio can be diversified across different sectors and still lose a significant amount when markets fall together.
For example, suppose I have ₹10 lakh invested across Banking, IT, FMCG, Pharma and Auto. The allocation looks diversified, but that does not tell me how much the portfolio might lose during a bad trading day.
This is where Portfolio Value at Risk, or VaR, becomes useful.
VaR estimates a loss threshold over a specified period and confidence level. It does not predict the exact loss or tell us the worst possible outcome.
For this experiment, I use Python to estimate one-day VaR at 95% and 99% confidence levels. I compare a historical-style calculation with Monte Carlo simulation and then check which sectors contribute most to portfolio volatility.
The entire dataset is synthetic. It represents five Nifty-like sector baskets, not actual NSE index returns.
Starting with ₹10 lakh across five sectors
I allocate the portfolio across five sectors using fixed weights.
| Sector | Allocation | Investment |
|---|---|---|
| Banks | 30% | ₹3,00,000 |
| IT | 25% | ₹2,50,000 |
| FMCG | 15% | ₹1,50,000 |
| Pharma | 15% | ₹1,50,000 |
| Auto | 15% | ₹1,50,000 |
| Total | 100% | ₹10,00,000 |
The allocation is only an example for testing. It is not a recommended portfolio.
In the notebook, I assign different annualized return and volatility assumptions to each sector.
Banks have an assumed annualized volatility of 22%, IT 24%, FMCG 14%, Pharma 18% and Auto 25%.
These are simulation parameters, not volatility estimates calculated from actual market data.
I also define a correlation matrix to represent how sector returns move together.
For the return simulation, I use a Student’s t distribution with four degrees of freedom. Compared with a normal distribution, it produces more extreme observations in the tails.
This helps me test losses that are less common than ordinary daily price movements.
I use a fixed random seed so the notebook produces the same results whenever I run it.
The correlation matrix tells an important story

The first chart shows the correlation between the five sector returns.
Banks and Auto have the highest correlation at approximately 0.60 in the generated sample.
Banks and IT have a correlation of approximately 0.42.
IT and FMCG are less correlated, at around 0.26.
All five sectors have positive correlations with one another in this dataset.
That means diversification can reduce some risk, but the sectors are not completely independent.
For example, if Banking and Auto tend to move in the same direction, holding both does not provide the same diversification benefit as holding two assets with a much lower correlation.
Correlation is only one part of the calculation. The amount invested and the volatility of each sector also affect the total portfolio risk.
The risk calculation therefore uses the portfolio weights, sector volatilities and the relationships between their returns.
Comparing two ways of calculating VaR
I calculate VaR using two approaches.
The first uses 500 generated daily return observations, representing approximately two trading years of synthetic history.
I calculate the portfolio profit or loss for each observation, sort the results and identify the loss threshold at the required percentile.
This follows the percentile calculation used in historical VaR, although the observations here are simulated rather than actual historical market returns.
The second approach uses Monte Carlo simulation.
I generate 10,000 possible one-day return scenarios using the assumed sector returns, volatilities and correlations.
For every scenario, Python calculates the weighted portfolio return and converts it into a rupee profit or loss.
The results are:
| Method | 95% VaR | 99% VaR |
|---|---|---|
| Synthetic historical sample | ₹13,756 | ₹23,635 |
| Monte Carlo | ₹14,768 | ₹24,647 |
The Monte Carlo 95% VaR is approximately ₹1,012 higher than the historical-style estimate.
Both calculations use returns generated from the same underlying assumptions, but they draw different random samples. The difference does not establish that Monte Carlo is more accurate.
The 500-observation sample is also much smaller than the 10,000-run simulation.
With actual market data, the results could be different.
What does ₹14,768 of VaR mean?
The second chart shows the distribution of the 10,000 simulated one-day portfolio profit and loss outcomes.
Most observations are concentrated near zero, with smaller numbers of larger gains and losses.
The orange dashed line marks the 95% VaR of approximately ₹14,768.
Under the simulation assumptions, about 95% of one-day outcomes have losses that do not exceed this amount. The remaining 5% have losses beyond that threshold.
It is not correct to say the portfolio cannot lose more than ₹14,768.
At the 99% confidence level, the VaR increases to approximately ₹24,647.
This represents a more extreme loss threshold. Around 1% of simulated outcomes fall beyond it.
However, VaR alone does not tell me how large those losses become.
The notebook also calculates Expected Shortfall at 99%.
99% Expected Shortfall = ₹33,801
This is the average loss among simulated scenarios that exceed the 99% VaR threshold.
The difference matters.
VaR identifies a point in the loss distribution. Expected Shortfall looks at the average loss beyond that point.
Both measures are still dependent on the model assumptions.
A market event that is not represented well by the simulation may produce losses beyond these estimates.
Looking beyond one day
A one-day loss estimate is useful, but a portfolio may continue losing value over several trading sessions.
The third chart shows the possible portfolio value over the next 20 trading days.
For this part, I simulate 2,000 paths, each containing 20 daily portfolio returns.
The notebook compounds the returns along each path and calculates the distribution of portfolio values for every future day.
The chart shows the median outcome, a 5th-to-95th-percentile range, and a wider 1st-to-99th-percentile range.
At day 20, the simulated median portfolio value is approximately ₹10.09 lakh.
The middle 90% of outcomes fall between approximately ₹9.38 lakh and ₹10.84 lakh.
The wider 1st-to-99th-percentile range extends from around ₹9.09 lakh to ₹11.22 lakh.
These are simulated ranges, not price targets or confidence intervals validated against actual market returns.
The model assumes the portfolio maintains the selected sector weights during the simulated paths. It does not calculate transaction costs or taxes for maintaining those weights.
The range becomes wider over time because uncertainty accumulates across trading days.
The chart is useful for understanding how different return paths affect the portfolio, but it does not replace a dedicated stress test.
Portfolio weight is not the same as risk contribution
The fourth chart compares each sector’s allocation with its contribution to portfolio volatility.
This is where the result becomes more interesting.
| Sector | Portfolio Weight | Share of Portfolio Volatility |
|---|---|---|
| Banks | 30% | 34.7% |
| IT | 25% | 30.4% |
| FMCG | 15% | 7.5% |
| Pharma | 15% | 9.6% |
| Auto | 15% | 17.8% |
Banks account for 30% of the investment but contribute approximately 34.7% of the portfolio’s volatility.
IT contributes another 30.4%, despite representing only 25% of the portfolio.
Together, Banks and IT represent 55% of the portfolio weight but approximately 65% of its volatility contribution.
FMCG is different. It has a 15% allocation but contributes only around 7.5% of portfolio volatility.
This happens because risk contribution depends on sector volatility, correlation and allocation, not just investment amount.
One distinction is important here.
The notebook calculates these contributions using the covariance matrix of the simulated sector returns. They are contributions to portfolio standard deviation, not contributions to VaR or Expected Shortfall.
A sector can contribute differently to ordinary volatility and extreme downside losses.
That requires separate analysis.
Where the model is limited
This test provides a useful starting point, but the data is deliberately generated.
The sector return assumptions are fixed. Volatility and correlation do not change in response to market conditions during the simulation.
Real markets behave differently.
Correlations can increase during a broad sell-off, and volatility can rise sharply during stressful periods. Liquidity may also become a problem when investors attempt to exit positions.
The simulation does not model those effects directly.
Another limitation is the comparison between the two VaR methods.
The historical-style dataset contains 500 generated observations, not actual sector price history. Both calculations therefore depend on the same synthetic return-generating process.
A stronger test needs actual historical sector returns, carefully defined return series and a consistent portfolio allocation.
The next check is backtesting.
For example, if a model produces a daily 95% VaR estimate, I can compare that threshold against subsequent observed losses and count how often the portfolio exceeds it.
That helps determine whether the model produces reasonable risk estimates across different market periods.
It is also worth comparing the simulation with explicit stress scenarios, such as a sharp banking-sector decline or simultaneous falls across all five sectors.
What stands out from this experiment
The Monte Carlo simulation estimates a one-day 95% VaR of ₹14,768 and a 99% VaR of ₹24,647 for the synthetic ₹10 lakh portfolio.
The 99% Expected Shortfall is higher, at approximately ₹33,801.
The historical-style estimates are slightly lower, but neither approach uses real market observations in this test.
The most useful finding is the difference between portfolio allocation and risk contribution.
Banks and IT account for 55% of the investment but approximately 65% of the portfolio’s volatility contribution.
That shows why equal or diversified-looking allocations do not necessarily produce evenly distributed risk.
The next step is to repeat the analysis using actual market data and check how the risk estimates perform over time.
A VaR number is useful as a summary of modeled risk. It becomes more meaningful when the assumptions are understood, the results are backtested, and the losses beyond the threshold are considered.
All returns, correlations and portfolio outcomes in this experiment are synthetic. This is personal research and learning, not investment advice.