start experiment 76 (exp/76-scheduled-algo-retrain-on-2026-09-16-tac)
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -37,11 +37,20 @@ class WeeklyRebalanceDropoutStrategy(TopkDropoutStrategy):
|
||||
forbid_all_trade_at_limit : same as ``TopkDropoutStrategy``.
|
||||
hold_band_pct : skip order for a name whose deviation from target weight is
|
||||
below this fraction of the target (no-trade buffer band).
|
||||
rebalance_every_n_weeks : rebalance every N ISO weeks instead of every week
|
||||
(default 1 = weekly; 2 = biweekly). Ignored when
|
||||
``rebalance_every_n_days`` is set.
|
||||
rebalance_every_n_days : rebalance every N trading days (daily when N=1).
|
||||
When set, overrides the weekly gating logic entirely.
|
||||
"""
|
||||
|
||||
def __init__(self, *, topk, n_drop, hold_band_pct: float = DEFAULT_HOLD_BAND_PCT, **kwargs):
|
||||
def __init__(self, *, topk, n_drop, hold_band_pct: float = DEFAULT_HOLD_BAND_PCT,
|
||||
rebalance_every_n_weeks: int = 1,
|
||||
rebalance_every_n_days: int = 0, **kwargs):
|
||||
super().__init__(topk=topk, n_drop=n_drop, **kwargs)
|
||||
self.hold_band_pct = hold_band_pct
|
||||
self.rebalance_every_n_weeks = rebalance_every_n_weeks
|
||||
self.rebalance_every_n_days = rebalance_every_n_days
|
||||
|
||||
@staticmethod
|
||||
def _iso_week(ts) -> tuple:
|
||||
@@ -53,13 +62,25 @@ class WeeklyRebalanceDropoutStrategy(TopkDropoutStrategy):
|
||||
trade_step = self.trade_calendar.get_trade_step()
|
||||
trade_start_time, trade_end_time = self.trade_calendar.get_step_time(trade_step)
|
||||
|
||||
cur_week = self._iso_week(trade_start_time)
|
||||
prev_week = getattr(self, "_last_week", None)
|
||||
self._last_week = cur_week
|
||||
if self.rebalance_every_n_days > 0:
|
||||
# daily gating: count trading steps since last rebalance
|
||||
step_num = trade_step
|
||||
if hasattr(self, "_last_rebal_step"):
|
||||
if (step_num - self._last_rebal_step) < self.rebalance_every_n_days:
|
||||
return TradeDecisionWO([], self)
|
||||
self._last_rebal_step = step_num
|
||||
else:
|
||||
cur_week = self._iso_week(trade_start_time)
|
||||
prev_week = getattr(self, "_last_week", None)
|
||||
self._last_week = cur_week
|
||||
|
||||
if prev_week is not None and prev_week == cur_week:
|
||||
# not the first trading day of this ISO week -> hold
|
||||
return TradeDecisionWO([], self)
|
||||
if prev_week is not None and prev_week == cur_week:
|
||||
return TradeDecisionWO([], self)
|
||||
|
||||
if self.rebalance_every_n_weeks > 1:
|
||||
week_num = cur_week[1]
|
||||
if prev_week is not None and (week_num % self.rebalance_every_n_weeks) != 1:
|
||||
return TradeDecisionWO([], self)
|
||||
|
||||
pred_start_time, pred_end_time = self.trade_calendar.get_step_time(trade_step, shift=1)
|
||||
pred_score = self.signal.get_signal(start_time=pred_start_time, end_time=pred_end_time)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user