Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion opes/backtester.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def backtest(
- `optimize` must output weights for the timestep.

!!! note "Note"
- The backtest assumes portfolio weights are applied at the open of each timestep, with zero execution delay.
- Re-optimization does not automatically imply rebalancing. When the portfolio is re-optimized at a given timestep, weights may or may not be updated depending on the value of `rebalance_freq`.
- To ensure a coherent backtest, a common practice is to choose frequencies such that `reopt_freq % rebalance_freq == 0`. This guarantees that whenever optimization occurs, a rebalance is also performed.
- Also note that within a given timestep, rebalancing, if it occurs, is performed after optimization when optimization is scheduled for that timestep.
Expand Down Expand Up @@ -401,8 +402,11 @@ def backtest(
# ---------- REBALANCING BLOCK ----------
# Computing drifted weights
# This is necessary for turnover and slippage modelling
# NOTE: weights and returns of the previous timestep are passed in to compute drifted weights
# This is because weights[0], which is to be set on the beginning of the zeroth day is separately computed
# Therefore, as the loop starts from 1, the return from the zeroth day will cause the first drifted weights on the start of the first day (end of zeroth day)
drifted_weights = self._compute_drifted_weights(
weights[t - 1], test_data[t]
weights[t - 1], test_data[t - 1]
)

# Assigning computed weights to weight array
Expand Down