@@ -71,18 +71,18 @@ def run(self, weight_scheme: str = "rank") -> Dict:
7171 # Track rebalancing
7272 prev_rebalance_date = None
7373 current_weights = pd .Series (0.0 , index = self .prices .columns )
74-
74+
7575 # Compute daily weights from signals (rebalance only on rebalance dates)
7676 weights_list = []
7777 for date in returns_df .index :
7878 if self ._should_rebalance (date , prev_rebalance_date ):
7979 # Rebalance: compute new target weights
8080 current_weights = self ._calculate_weights (aligned_signals .loc [date ], weight_scheme )
8181 prev_rebalance_date = date
82-
82+
8383 # Append current weights (maintain between rebalances)
8484 weights_list .append (current_weights )
85-
85+
8686 weights = pd .DataFrame (weights_list , index = returns_df .index , columns = self .prices .columns ).fillna (0.0 )
8787
8888 # Previous day weights for PnL calculation
@@ -116,18 +116,18 @@ def run(self, weight_scheme: str = "rank") -> Dict:
116116
117117 def _should_rebalance (self , date : pd .Timestamp , prev_rebalance_date : Optional [pd .Timestamp ] = None ) -> bool :
118118 """Check if we should rebalance on given date.
119-
119+
120120 Args:
121121 date: Current date to check
122122 prev_rebalance_date: Last rebalance date (None for first rebalance)
123-
123+
124124 Returns:
125125 True if should rebalance, False otherwise
126126 """
127127 # Always rebalance on first date
128128 if prev_rebalance_date is None :
129129 return True
130-
130+
131131 if self .rebalance_freq == "D" :
132132 # Daily rebalancing
133133 return True
0 commit comments