How QuantLab works
Written by Bryan McGuire · Updated 15 October 2026
QuantLab takes a portfolio of 2 to 10 assets (shares, funds, currency pairs, crypto, commodities or bonds) and tells you how risky it is, whether a different mix would have done better for the same risk, and how it would have performed in the past. Every screen gives the answer in plain English first, then the numbers, then the maths behind them. This page explains that maths, one method at a time, with the exact settings QuantLab uses.
Prices are daily closing prices from Yahoo Finance over the last 1, 3 or 5 years. Different markets close on different days (crypto trades at weekends, London and New York have different bank holidays), so QuantLab only uses the days on which every asset in your portfolio traded. Each result shows the date of the latest price it used. QuantLab is an educational tool. Nothing here is investment advice, and past performance doesn't predict future results.
Returns and volatility
Volatility is how much your portfolio's value tends to swing. A volatility of 20% means that in a typical year the value ends up within about 20% either side of its average path.
QuantLab works out each day's percentage change in price, then averages them. The yearly figure is the daily average multiplied by 252, the usual number of trading days in a year. Volatility is the standard deviation of those daily changes multiplied by the square root of 252. The square root is there because day-to-day swings partly cancel out over time, so risk grows more slowly than return.
For the whole portfolio, QuantLab weights each asset's returns and also accounts for how the assets move together. Two volatile assets that tend to move in opposite directions can make a calm portfolio.
Annual return = mean daily return × 252. Annual volatility = standard deviation of daily returns × √252.
Sharpe ratio
The Sharpe ratio tells you how much return you got for each unit of risk. Higher is better. Above 1 is good for a portfolio; below 0.5 means you took a lot of swings for not much reward.
Example: a portfolio returning 12% a year with 15% volatility has a Sharpe ratio of 0.8. One returning 8% with 6% volatility scores 1.33, so it was the better deal per unit of risk even though it made less money.
QuantLab uses a 0% risk-free rate, so the Sharpe ratio is simply return divided by volatility. The textbook version subtracts the return you could have had from cash first. With UK savings rates around 4%, leaving that out makes every portfolio look a bit better than it is. It doesn't change which of two portfolios scores higher, which is what the optimiser cares about.
Sharpe = annual return ÷ annual volatility.
Value at Risk (VaR)
Value at Risk answers the question most people actually ask: how much could I lose on a bad day? QuantLab shows it in pounds, using the portfolio value you enter.
Example: a £10,000 portfolio with a 95% one-day VaR of 2.1% will, on about 1 trading day in 20, lose £210 or more. On the other 19 days it should do better than that.
QuantLab uses historical VaR. It takes every daily return of your portfolio over the period, sorts them, and reads off the 5th percentile: the point where 5% of days were worse. It also shows the 99% figure (1 day in 100) in "Show the maths". The historical method makes no assumption about the shape of returns, so if your portfolio has had a few nasty days, they count in full.
VaR (95%) = 5th percentile of daily portfolio returns × portfolio value.
Expected shortfall (CVaR)
VaR tells you where the bad days start. It doesn't tell you how bad they get. Conditional Value at Risk, also called expected shortfall, is the average loss across those worst 5% of days.
Example: the same £10,000 portfolio might have a VaR of £210 and a CVaR of £320. On the days when things go wrong, you'd expect to lose £320 on average, not £210. Regulators moved banks from VaR to expected shortfall for this reason: two portfolios can share a VaR while one has far worse tail days.
CVaR (95%) = average of all daily returns at or below the 5th percentile.
Maximum drawdown
Maximum drawdown is the biggest fall from a high point to a later low point. It's the number that tells you what holding the portfolio would have felt like at its worst.
Example: if the portfolio grew from £10,000 to £13,000 and then fell to £9,750 before recovering, the maximum drawdown is 25% (from £13,000 down to £9,750), even though you never lost more than 2.5% of your original money.
QuantLab tracks the portfolio's value every day, remembers the highest value so far, and records the largest percentage gap below it.
Max drawdown = the lowest value of (today's value ÷ highest value so far − 1).
Correlation and diversification
Correlation measures how closely two assets move together, on a scale from −1 to +1. At +1 they move in lockstep; at 0 they're unrelated; at −1 one goes up when the other goes down.
The heatmap on the health check shows every pair in your portfolio. Lots of dark cells close to +1 means you own several versions of the same bet, and diversification isn't doing much. A mix of shares and bonds, or assets from different regions, usually shows paler cells. Correlations tend to rise in a crash, so a portfolio that looks diversified in calm markets can still fall together.
Correlation of daily returns (Pearson), for each pair of assets.
Optimisation and the efficient frontier
The optimiser looks for the mix of your assets that would have given the highest Sharpe ratio over the period. It only uses the assets you chose, it never shorts anything, and it doesn't borrow: every weight is between 0% and 100% and they add up to 100%. This is Harry Markowitz's mean-variance method from 1952, solved numerically.
The efficient frontier chart shows the best return available at each level of risk. Any portfolio below the curve could have earned more for the same risk. The What-If sliders let you change weights and watch your dot move against the curve.
Treat the optimal mix as a starting point, not an instruction. It's built from past returns, and small changes in the data can swing the weights a lot. An asset that had one exceptional year will look better than it deserves. Many people use the optimal mix to see which direction to move, then move part of the way.
Maximise (return ÷ volatility) subject to every weight ≥ 0 and the weights summing to 1.
Rebalancing
Rebalancing turns the optimal mix into a list of trades. Enter what your portfolio is worth and QuantLab shows how much of each asset to buy or sell, in pounds, to get from your current weights to the optimal ones.
It only suggests a trade when an asset is more than 1 percentage point away from its target, so you're not told to make tiny trades. Anything more than 5 points out is marked high priority. If any asset is more than 10 points out, the overall advice is to rebalance soon. Trading costs and tax aren't included, and in a UK general investment account selling can trigger capital gains tax.
Backtest
The backtest answers: if I'd bought this mix 1, 3 or 5 years ago and left it alone, what would have happened? It compares the result with the S&P 500 index (^GSPC) over the same days.
It's buy and hold: the money is split by your weights on the first day and then never rebalanced, so winners grow to take a larger share. The results show the total return, the compound annual growth rate (CAGR), volatility, Sharpe ratio and maximum drawdown for both your portfolio and the index.
A backtest uses assets you've already picked, often because they did well. That makes almost any backtest look better than the same strategy chosen in advance would have done.
CAGR = (final value ÷ starting value)1 ÷ years − 1, where years = trading days ÷ 252.
Pairs trading
Some pairs of assets drift apart and then come back together, like two funds tracking the same index, or two oil companies. Pairs trading looks for those relationships. When the gap gets unusually wide, the idea is to buy the cheap one and sell the expensive one, betting the gap will close.
QuantLab tests every pair in your portfolio (up to 8 assets) with the Engle-Granger cointegration test and keeps pairs where the p-value is below 0.05. In plain terms, that means there's less than a 5% chance the relationship is a coincidence. For each pair it fits a hedge ratio (how many units of one asset move with one unit of the other), builds the spread from it, and measures today's spread in standard deviations from its average: the z-score. Beyond +2 or −2 the gap is unusually wide and QuantLab shows a signal.
Cointegration comes and goes. Two rivals in the same industry can pass the test one week and fail the next. Funds tracking the same index almost always pass. The "See an example" button runs the test on three well-known pairs so you can see both cases.
Price A = hedge ratio × price B + intercept. z-score = (today's spread − average spread) ÷ standard deviation of spread.
GARCH volatility forecast
Volatility clusters: calm days tend to follow calm days, and a big move is often followed by more big moves. GARCH is a model built around that pattern. QuantLab fits a GARCH(1,1) model to your portfolio's daily returns and forecasts volatility for each of the next 30 days.
The forecast usually starts near current volatility and drifts towards the long-run average. If markets have just been rough, the forecast starts high and comes down; if they've been unusually quiet, it starts low and rises. The chart's axis starts at zero so the size of the change isn't exaggerated. If the model can't fit your data, QuantLab falls back to an exponentially weighted average (EWMA) and says so.
Tomorrow's variance = ω + α × (today's return)² + β × today's variance.
Monte Carlo simulation
Monte Carlo simulation imagines 1,000 possible years for your portfolio and shows the spread of outcomes. Each path is random, but uses your portfolio's own historical return and volatility.
The model is geometric Brownian motion, the standard model for share prices: each day's change is random, with the right average and spread, and values can't go below zero. The results show the middle outcome (median), the range covering the middle half of paths (25th to 75th percentile), the range covering 90% of paths (5th to 95th), and the share of paths that end with a profit.
The simulation assumes the future looks like the past, with no crashes beyond what normal daily swings produce. Real markets have fatter tails, so the worst real outcomes are worse than the worst simulated ones.
Each day, value × exp((μ − σ²/2)Δt + σ√Δt × Z), where Z is a random draw from a standard normal distribution and Δt = 1/252.
Anomaly detection
Anomaly detection flags anything unusual about your assets in the last 7 trading days, so you can check the news before it surprises you.
A price move counts as unusual when it's more than 2.5 standard deviations from the asset's average daily move over the last 30 days, and high severity above 3. Volume counts as unusual when it's more than 2.5 times the 20-day average, and high severity above 4 times. An anomaly isn't a signal to trade. It means something happened worth reading about.
Frequently asked questions
Is this investment advice?
No. QuantLab shows what the numbers say about the past. It doesn't know your goals, your tax position or what you can afford to lose. If you need advice, speak to a regulated financial adviser.
Where does the data come from?
Daily closing prices from Yahoo Finance. If Yahoo Finance is unavailable, QuantLab uses its most recent saved prices and shows the date they're from.
Why do my numbers change from one day to the next?
Each run uses the latest prices, so the period moves forward by a day and the oldest day drops out. A single big day entering or leaving the window can shift VaR and drawdown noticeably.
Why historical VaR and not the normal-distribution version?
The normal-distribution version assumes bad days are rare in a neat, predictable way. Real markets have more extreme days than that, so it understates risk. Historical VaR uses what actually happened.
Do I need an account?
No. Every tool works without one. An account lets you save portfolios and open them on another device.
Is my portfolio stored?
Without an account, your portfolio stays in your own browser and isn't sent to us except to run each calculation, and calculations aren't saved. If you save a portfolio to an account, its name, tickers and weights are stored. The privacy policy lists everything.