Portfolio LabKnowledgeSign inCreate account

Backtest methodology: data, process, rebalancing and costs

In depth12 min read · updated 24 October 2026 · 6 sources

This backtest methodology describes step by step what happens when you click “Start a backtest”: which prices are used, in what order return, costs, inflows and outflows and rebalancing are booked in each period, and how the metrics are derived from them. It follows the code that actually runs.

Price data and period

The basis is prices with reinvested distributions (total return): a fund's dividends and interest are included in the price, as if they were reinvested immediately. The fund costs (TER) have already been deducted from these prices. Prices in other currencies are converted into the selected base currency at daily exchange rates; prices quoted in subunits such as pence are converted into the main currency when fetched (divided by 100).

  • Common period: a backtest only starts once all components have prices. The app names the security with the shortest history, which limits the start.
  • Proxy: if a proxy is stored for a security, its series is extended backwards with the proxy's returns; the level joins up with the first real price.
  • Gaps: if a price is missing on a trading day (for example because of a public holiday on one exchange), the last price is carried forward for at most seven days.
  • Frequency: calculations use month-end prices (the last price of the month) or daily prices, depending on the setting. If asset classes with monthly values are in the grid, the app always calculates monthly.
  • Data checks: conspicuous price series (jumps, frozen prices, unit changes) are flagged but not altered. The only exception: when loading, the app deletes isolated outlier days that reverse on the following day (see Data checks).

Process per period

The backtest starts with the initial capital (default 10,000) at the target weights on the first trading day. It then runs through each period (day or month) in a fixed order:

  1. Each position grows with its price return for the period.
  2. Ongoing additional costs, for example for discretionary portfolio management, are deducted on top of the TER.
  3. If a contribution or withdrawal is due, the app buys or sells.
  4. If a rebalancing is due, the portfolio is reset to the target weights.
  5. The value at the end of the period is recorded.

The returns shown are time-weighted: inflows and outflows are stripped out, while all costs remain in. That way the return does not depend on when and how much money flowed. This is the same logic funds use to measure their performance. Dichev (2007) shows how much time-weighted and money-weighted returns can differ (see time-weighted return).

r_t = (V_t − CF_t) / V_(t−1) − 1
V_t
portfolio value at the end of period t
CF_t
inflow (+) or withdrawal (−) in the period
V_(t−1)
value at the end of the previous period

Ongoing additional costs p.a. are converted per period so that exactly the annual rate has been deducted after one year: factor (1 − costs)^(1/n) with n = 12 for monthly data and n = 252 for daily data. At 0.2% p.a., that is 0.0167% per month.

Rebalancing

Without rebalancing, the weights drift with prices. The app resets them to the target weights at the closing price of the last trading day of a period. The default is quarterly.

SettingDate
Monthlylast trading day of each month
Quarterlyend of March, June, September, December
Semi-annuallyend of June and December
Annuallyend of December
Tolerance bandas soon as a weight deviates from its target by more than the band (default ± 5 percentage points)
No rebalancingnever (buy and hold)

With monthly data, the tolerance band is checked at every month end; with daily prices, every day. If the app calculates internally with daily prices because an execution day is set, it still only checks the band at month end. With time-varying weights (table, glide path, value threshold, file), every change in the target weights triggers a rebalancing. The effect of rebalancing is described by Perold and Sharpe (1988); Masters (2003) examines bands with costs. More in the article Rebalancing.

Savings plans and withdrawals

  • Frequency: monthly, quarterly or annually, each at the end of the period (quarterly in March, June, September and December, annually in December).
  • Execution day: with trading costs, you can choose a day from 1–28. The app then calculates internally with daily prices (the first trading day on or after that day) and condenses the result to month ends.
  • Fixed amount: optionally grows with an annual increase p.a. and/or with inflation (price index relative to the start).
  • Withdrawal in percent: on each date, a pro rata share of the annual rate is withdrawn from the current value; at 4% p.a. and monthly withdrawals, that is 4% × 1/12 of the value.
  • Allocation: contributions according to the target weights or first into underweight positions (rebalancing without selling); withdrawals pro rata or first from overweight positions.

Time-varying weights

Instead of fixed target weights, each portfolio can have a schedule. Every change in the target weights triggers a rebalancing:

  • Table: weights from a given date, valid until the next row. The switch takes place at the closing price of the last trading day before the date (with monthly data, at the end of the previous month), so that the return from the date onwards already counts.
  • Glide path: linear from the portfolio's own weights to those of another portfolio between two dates, in monthly, quarterly or annual steps, as with a target-date fund.
  • Value threshold: the portfolio's own weights until the portfolio value reaches a threshold (or falls to it), then, once, the weights of another portfolio. The check takes place in each period after inflows and outflows, and the switch happens at the closing price of the same period; there is no way back. Optionally, the threshold grows with inflation (purchasing power at the start).
  • File: weights per date from CSV or Excel, such as signals from your own model. The switch takes place at the closing price on the date or on the next trading day, without look-ahead; until the first date, the weights from the grid apply.

With the value threshold, you can choose where contributions go after the switch: into the weights of the target portfolio (then everything is one pot) or still into the portfolio's own weights. In the second case the app keeps two pots in one account: the switched holdings and the contributions since the switch. Each pot is rebalanced to its own weights, so the account as a whole is rebalanced to the value-weighted mix of both sets of weights. Withdrawals, ongoing costs and trading costs are borne by both pots pro rata; purchases and sales of the same position are netted, as in a real brokerage account.

w_t = (A_t · w_target + B_t · w_own) / (A_t + B_t)
A_t
value of the switched pot
B_t
value of the contributions since the switch
w_target, w_own
weights of the target portfolio and of the portfolio itself

Because the timing depends on the path, each run determines it itself: taxes and trading costs reduce the portfolio value and can delay the switch. The notes in the results give the date and value of the switch in the run shown.

Trading costs and ongoing costs

Optionally, the app calculates with costs like those of a broker. Purchases are made at the ask price and sales at the bid price, each half a bid-ask spread above or below the closing price. Order fees consist of a fixed amount plus a percentage, subject to a minimum fee; savings plan executions have their own fee per position. Rebalancing trades of up to one currency unit per position are not executed. For comparison, the app runs each backtest a second time without trading costs and shows the final value alongside.

The cost templates (neobroker, online bank, high-street bank) are sample values, not the prices of any particular provider.

Benchmark and analyses

The benchmark runs with the same inflows and outflows, but without additional costs. All metrics are derived from the time-weighted returns. How they are defined is explained in the metrics methodology. In addition:

  • Inflation: a price index for the selected region (default Germany) is interpolated log-linearly between monthly values; real values = nominal values divided by the price level relative to the start.
  • Calendar years, monthly table, trailing returns (3 months to 10 years, annualised from one year) and rolling returns over 1, 3, 5, 7 and 10 years.
  • Return triangle: annualised return for every pair of start and end year, using full calendar years only.
  • Crises: return and drawdown in nine fixed periods, from the 1973/74 oil crisis to the 2022 interest rate turnaround, provided the backtest covers them.
  • Rising and falling markets: months with a positive or non-positive benchmark return, each with the average return and hit rate.
  • Contributions: the return contribution of each position from the actual changes in value, and the risk contribution from target weights and covariance (see risk contribution).
  • Turnover: the sum of rebalancing trades per year of the backtest period, halved (a purchase and a sale together count once).

Leverage per security

Optionally, each security with a weight can be given its own leverage L, for example to replicate a 2× or 3× ETF on an index. Before the actual backtest, the app calculates a leveraged price from the security's prices, with the same starting value: in each price period, L times the return applies, so the leverage is reset in every period, as with a leveraged ETF. Leverage 1 means no leverage. Background on securities-based lending, margin calls and leveraged ETFs is covered in the article Leverage in the portfolio.

SettingDefaultAllowed
Leverage per security1 (no leverage)0.1 to 5
Spread p.a. over the money market rate1%0 to 10%
Money market ratefrom the settingsfixed rate or historical money market rates

For each leveraged security and each period from the previous to the current trading day:

R_L = L × r + (1 − L) × g − max(L − 1, 0) × s
R_L
return of the leveraged price in the period
r
return of the security in the base currency, with reinvested distributions
g
money market return for the period: for a fixed rate (1 + rate)^(days/365.25) − 1, for historical money market rates the return over the same calendar days (before the interest rate data begin, the fixed rate)
s
spread for the period: (1 + spread)^(days/365.25) − 1
days
calendar days since the previous price, so three from Friday to Monday

Above 1, the portion L − 1 is financed at the money market rate plus the spread, much as a leveraged ETF pays for its additional exposure through swaps. There is no floor on the rate: a negative money market rate lowers the cost. Below 1, the remainder 1 − L is held as cash at the money market rate, without a spread. The financing is thus embedded in the price and reduces its gain in value; there is no separate interest payment or credit line.

Because the leverage applies afresh in every period, the result depends on the entire price path, not just on the start and end prices. Over longer periods, a leveraged security therefore does not deliver L times the return: fluctuations without a trend cost value (the volatility drag), while trends deliver more than L times the return.

Avellaneda and Zhang (2010) derive this path dependence exactly: besides the index return, the realised variance determines the outcome. Anyone who wants to achieve a fixed multiple of the index over a longer period with such a fund has to rebalance their position themselves; the authors conclude:

“leveraged ETFs as currently designed may be unsuitable for buy-and-hold investors”
Avellaneda and Zhang (2010)

Total loss: if R_L reaches −100% or less in a period, the security is worthless. Without interest, this happens at a period return of −1/L or lower: −50% at leverage 2, −33.33% at leverage 3, −20% at leverage 5. The price then falls to one trillionth of the previous price and stays there. Whatever a rebalancing or a contribution subsequently puts into the security keeps its value but earns no further return; the results state the date of the total loss.

  • All portfolios: the leveraged price replaces the security's price in every portfolio that holds it. Single assets, contributions, metrics and taxes are all calculated with this price.
  • Benchmark: it runs without leverage, unless it is itself a leveraged security in one of the portfolios; it then runs with the same leveraged price, and the app points this out.
  • Daily prices: leverage is applied to daily prices before the app condenses them to the calculation frequency, even when it calculates with month-end prices. Only with asset classes (monthly values) is the leverage applied monthly; the volatility drag is then smaller, and total losses within a month remain invisible.
  • Base currency: it is the return in the base currency that is leveraged, so the exchange rate is leveraged too. Products that apply leverage in the index currency behave differently: if a dollar index rises by 2% and the dollar falls by 1% against the euro, a fund leveraged 2× in dollars returns 1.04 × 0.99 − 1 = 2.96% in euros, while the app gives 2 × 0.98% = 1.96%.
  • Taxes: leverage and taxes can be combined. The tax calculation treats the leveraged price according to the security's tax category, which you choose, or have suggested, as for any security. For tax purposes, a leveraged ETF is a fund and a factor certificate is a debt security; whether a leveraged ETF counts as an equity fund with partial exemption (Teilfreistellung) depends on how much it invests in equities under its investment terms.

The Leverage tab shows, for each leveraged security, metrics without and with leverage over the same period, calculated at the backtest's calculation frequency. In the report, the leverage per security is listed under the settings, together with the spread.

ColumnMeaning
Leveragefactor set
CAGR, Vol, Max. drawdowneach without → with leverage
Avg. financing p.a.financing per period as a percentage of the leveraged value, summed up to the end or to the total loss and divided by the years in the period; negative for leverage below 1 (interest on cash)
Total lossdate or “no”

Limitations of leverage: the backtest only sees closing prices. It does not capture intraday movements or the rules that real products use to cushion large daily losses. The ongoing costs of a real leveraged ETF and its deviations from the index are missing; if you want to account for them, increase the spread (it only acts on L − 1) or the portfolio's additional costs. The spread stays the same over the whole period, although financing can become scarcer and more expensive in crises (Brunnermeier and Pedersen 2009). The backtest does not model a securities-based loan with drifting leverage, minimum margin and margin calls.

Limitations

The backtest trades at the closing price of the same day on which the rebalancing is due. In practice, this is only possible afterwards. It knows no minimum lot sizes and no execution risks. It only calculates taxes when they are switched on (see Taxes). Results apply to the selected securities: anyone who places today's known winners in the past is subject to survivorship bias, as described by Brown et al. (1992). And past values are not a forecast.

Frequently asked questions

Why does my backtest start later than expected?

Because all securities must have prices. The app names the security with the shortest history; a proxy can extend it.

Are dividends included?

Yes. The prices include reinvested distributions; the TER has already been deducted.

When exactly does rebalancing take place?

At the closing price of the last trading day of the period, so with quarterly rebalancing at the end of March, June, September and December.

Why does a contribution not change the return?

The returns are time-weighted: inflows and outflows are stripped out so that the return measures the investment, not the timing of the payments.

Does the benchmark run with costs?

With the same inflows and outflows and trading costs, but without the portfolio's ongoing additional costs.

How does the backtest calculate with leverage?

For each security as with a leveraged ETF: in every period (daily with daily prices), return = leverage × price return − (leverage − 1) × (money market rate + spread). Below 1, the remainder is held as cash at the money market rate. The leveraged price applies in all portfolios that hold the security; the benchmark stays unleveraged.

Can leverage be combined with taxes?

Yes. The leveraged price is taxed according to the tax category that applies to the security, which can be chosen as for any other. The financing is embedded in the price and reduces the gain; there is no separate interest payment.

Why does leverage 2 not deliver twice the return?

Because the leverage applies afresh in every period: fluctuations without a trend cost value (volatility drag), and the borrowed portion costs interest. The Leverage tab shows CAGR, volatility and max. drawdown without and with leverage side by side.

Literature

  1. Avellaneda, Marco; Zhang, Stanley (2010): Path-Dependence of Leveraged ETF Returns. SIAM Journal on Financial Mathematics 1 (1), pp. 586–603. doi:10.1137/090760805
  2. Brown, Stephen J.; Goetzmann, William; Ibbotson, Roger G.; Ross, Stephen A. (1992): Survivorship Bias in Performance Studies. Review of Financial Studies 5 (4), pp. 553–580. doi:10.1093/rfs/5.4.553
  3. Brunnermeier, Markus K.; Pedersen, Lasse Heje (2009): Market Liquidity and Funding Liquidity. Review of Financial Studies 22 (6), pp. 2201–2238. doi:10.1093/rfs/hhn098
  4. Dichev, Ilia D (2007): What Are Stock Investors' Actual Historical Returns? Evidence from Dollar-Weighted Returns. American Economic Review 97 (1), pp. 386–401. doi:10.1257/aer.97.1.386
  5. Masters, Seth J. (2003): Rebalancing. The Journal of Portfolio Management 29 (3), pp. 52–57. doi:10.3905/jpm.2003.319883
  6. Perold, Andre F.; Sharpe, William F. (1988): Dynamic Strategies for Asset Allocation. Financial Analysts Journal 44 (1), pp. 16–27. doi:10.2469/faj.v44.n1.16

Full bibliography

This page describes how Portfolio Lab calculates; past results are not a forecast. All terms in the glossary.