FRENESDE

Rebalancing

Rebalancing means periodically resetting the portfolio weights to their targets. Without it, the asset that rises most ends up dominating and the actual risk drifts away from the chosen risk.
In Backtrader, you schedule a timer in __init__: self.add_timer(when=bt.Timer.SESSION_START, monthdays=[1], monthcarry=True). At the start of each month, Backtrader calls notify_timer(self, timer, when, *args, **kwargs), where you put the order_target_percent calls.
monthcarry=True moves the trigger to the next trading day if the 1st falls on a weekend or a holiday. For a weekly rhythm, use weekdays=[1] (Monday).
The trade-off is about frequency: rebalancing every day sticks to the targets but piles up fees; once a quarter or a year costs little but lets the weights drift. Another option: only rebalance when a weight strays from its target by more than a few points.

Examples

Key terms

Rebalancing
Periodically resetting portfolio weights to their targets
add_timer
Method that schedules a recurring trigger
notify_timer
Method called when a timer fires
Drift threshold
Maximum gap tolerated between an actual weight and its target
Take the mission on Doji Academy

← Back to the index