From c1e7a9fc7203e5bd7702c0b231bb98bb188b338d Mon Sep 17 00:00:00 2001 From: zhaoli Date: Tue, 6 Oct 2026 12:02:06 +0000 Subject: [PATCH] start experiment 88 (exp/88-scheduled-algo-retrain-on-2026-10-05-tac) --- code/MANIFEST.txt | 28 +++++++------- .../__pycache__/__init__.cpython-312.pyc | Bin 374 -> 374 bytes .../data/__pycache__/__init__.cpython-312.pyc | Bin 216 -> 216 bytes .../data/__pycache__/handler.cpython-312.pyc | Bin 21533 -> 21533 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 319 -> 319 bytes .../__pycache__/rank_ensemble.cpython-312.pyc | Bin 9461 -> 9461 bytes .../__pycache__/rank_gbdt.cpython-312.pyc | Bin 12288 -> 12288 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 301 -> 301 bytes .../__pycache__/long_short.cpython-312.pyc | Bin 19672 -> 19672 bytes .../__pycache__/optimal_stop.cpython-312.pyc | Bin 10428 -> 10428 bytes .../contrib/strategy/weekly_rebalance.py | 35 ++++++++++++++---- .../data/__pycache__/__init__.cpython-312.pyc | Bin 522 -> 522 bytes .../data/__pycache__/config.cpython-312.pyc | Bin 11507 -> 11507 bytes .../__pycache__/providers.cpython-312.pyc | Bin 13340 -> 13340 bytes 14 files changed, 42 insertions(+), 21 deletions(-) diff --git a/code/MANIFEST.txt b/code/MANIFEST.txt index 4beca79..b620ba7 100644 --- a/code/MANIFEST.txt +++ b/code/MANIFEST.txt @@ -1,34 +1,34 @@ # TradeAC custom-qlib-code snapshot (auto-generated) -# parent repo HEAD : ce2e0c1a7cf2277108b3c6e469e225579f9cf259 +# parent repo HEAD : 742e009e674f14236fc1671e43705266175e1877 # tac-qlib/tac_qlib/contrib # tac-qlib/tac_qlib/data # per-file hashes (git hash-object): 1b6298c4a5652f2e863cbdc385a1014a570fcd59 tac-qlib/tac_qlib/contrib/__init__.py - 6c57851807631dfa1a525f87538a1b0a495fd7b2 tac-qlib/tac_qlib/contrib/__pycache__/__init__.cpython-312.pyc + d1a8ec0c9e6c38839e966f687b08ec412f87ec20 tac-qlib/tac_qlib/contrib/__pycache__/__init__.cpython-312.pyc 2224424d0ff193be4f55d1b791f8fce89439c5d2 tac-qlib/tac_qlib/contrib/backtest/__init__.py 0bf40dee440ddbded357d7bbb4efc67c62c4b084 tac-qlib/tac_qlib/contrib/backtest/tradeac_exchange.py c76a9f17f680e74eea766eff27f7624359749ed6 tac-qlib/tac_qlib/contrib/data/__init__.py - 1acd2cb845eac1bcee54450004a4af36484544ed tac-qlib/tac_qlib/contrib/data/__pycache__/__init__.cpython-312.pyc - 2ef18965f77e8955580334d2edc09bd381204355 tac-qlib/tac_qlib/contrib/data/__pycache__/handler.cpython-312.pyc + c1543fabfc22e07c7e9942015c4462f84acc1e91 tac-qlib/tac_qlib/contrib/data/__pycache__/__init__.cpython-312.pyc + 89f5cfc15b946b6ea1fb7724f021024967cdb6c5 tac-qlib/tac_qlib/contrib/data/__pycache__/handler.cpython-312.pyc 3bba0f1696e4ab4b3deebec3f31f269b2e713899 tac-qlib/tac_qlib/contrib/data/handler.py b151d139a0dcde87d74b21e7c4b729176ba5c39b tac-qlib/tac_qlib/contrib/model/__init__.py - c975d2b978f2cc08a388a5d921938704a3dd592d tac-qlib/tac_qlib/contrib/model/__pycache__/__init__.cpython-312.pyc - 009ebd83c5156ca3d7039a112e0d277dd416ca86 tac-qlib/tac_qlib/contrib/model/__pycache__/rank_ensemble.cpython-312.pyc - 1716b680b5623394229f7600ad4c81ad07fa6a2b tac-qlib/tac_qlib/contrib/model/__pycache__/rank_gbdt.cpython-312.pyc + f4e9bf0a78d22e256cade0d794a6958aaa7c6721 tac-qlib/tac_qlib/contrib/model/__pycache__/__init__.cpython-312.pyc + c35c166a8449c14fa3cd4972c363d3d9d58620ef tac-qlib/tac_qlib/contrib/model/__pycache__/rank_ensemble.cpython-312.pyc + 98be60fe19fedb3d9cb21c3f91ef0e176bd93287 tac-qlib/tac_qlib/contrib/model/__pycache__/rank_gbdt.cpython-312.pyc d3f051f3a8650c42fedc7b367b966f7c74fb5789 tac-qlib/tac_qlib/contrib/model/rank_ensemble.py d03e6611338918d4aac5eea4adf26f85a3763652 tac-qlib/tac_qlib/contrib/model/rank_gbdt.py 184f80da8edf944bad3c8fb4d4d3d189bf4f082b tac-qlib/tac_qlib/contrib/strategy/__init__.py - 9c9f7743970b1a3827bb72768bb6e8be03040759 tac-qlib/tac_qlib/contrib/strategy/__pycache__/__init__.cpython-312.pyc - 6e38a7fa8584b80410ccc88e5feff228a7ece38b tac-qlib/tac_qlib/contrib/strategy/__pycache__/long_short.cpython-312.pyc - f983d5c2472cd16ef9f14a240674ec0a7f41e81c tac-qlib/tac_qlib/contrib/strategy/__pycache__/optimal_stop.cpython-312.pyc + 69684c9c9624cb16c63f3a18a864c49a7db37fa9 tac-qlib/tac_qlib/contrib/strategy/__pycache__/__init__.cpython-312.pyc + 4d3a5433e57e65e5dc96c6d2999f9d473b696dc4 tac-qlib/tac_qlib/contrib/strategy/__pycache__/long_short.cpython-312.pyc + 53e72f512b47207a5292a918efef7fee162deef3 tac-qlib/tac_qlib/contrib/strategy/__pycache__/optimal_stop.cpython-312.pyc 896ef74ae47bcd1ed388e1e5d9c8d70c28097fe9 tac-qlib/tac_qlib/contrib/strategy/kelly_dropout.py 9090fc6dfbd339f2f4df4b0c9b87f400ecb5c9d5 tac-qlib/tac_qlib/contrib/strategy/long_short.py 79aaad9e39fcc740a773f4f63c512ce1086cfde0 tac-qlib/tac_qlib/contrib/strategy/optimal_stop.py 5b9acfb4340111b204249add7760bd53c6ae03f1 tac-qlib/tac_qlib/contrib/strategy/regime_gate.py - fe60bacdfedd48617863be31f24b7c7daebfac5a tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py + 839abb89ad40cd516eabcfd91fe1be626b9f091f tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py 92e6e90eb0cd0a25142034560f27adb6b705b1a8 tac-qlib/tac_qlib/data/__init__.py - a0e969bd6504bb8d9220f4641cc01e960c3120e4 tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc - 2f8c537d11135155539276bee342d087aad8743e tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc - 53cf7828c425f6b5032b206b93a238607111a6ed tac-qlib/tac_qlib/data/__pycache__/providers.cpython-312.pyc + 0f1eb6f41d44bd9064b1f16f529dac6bb9d7c3fd tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc + cf99dd8a481f6e2d1f323f8d8d754730eadb357a tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc + ddac5bab6578399c0301390d71bae13511a56cb1 tac-qlib/tac_qlib/data/__pycache__/providers.cpython-312.pyc 1953fb2a6371525db7f7b0e1c9dfbf3492d82110 tac-qlib/tac_qlib/data/config.py 8d0644f6f0d1efb94798ed444cc73e63b643459b tac-qlib/tac_qlib/data/providers.py diff --git a/code/tac-qlib/tac_qlib/contrib/__pycache__/__init__.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/__pycache__/__init__.cpython-312.pyc index 6c57851807631dfa1a525f87538a1b0a495fd7b2..d1a8ec0c9e6c38839e966f687b08ec412f87ec20 100644 GIT binary patch delta 20 acmeyy^o@!8G%qg~0}wpZSi6xsn-Ks(qXo_Y delta 20 acmeyy^o@!8G%qg~0}w>)>fOkl%?JQMjRmp* diff --git a/code/tac-qlib/tac_qlib/contrib/data/__pycache__/__init__.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/data/__pycache__/__init__.cpython-312.pyc index 1acd2cb845eac1bcee54450004a4af36484544ed..c1543fabfc22e07c7e9942015c4462f84acc1e91 100644 GIT binary patch delta 19 Zcmcb?c!QDqG%qg~0}wpZSUZvXEC4rs1)>Yd1a763Mb1+@SG diff --git a/code/tac-qlib/tac_qlib/contrib/data/__pycache__/handler.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/data/__pycache__/handler.cpython-312.pyc index 2ef18965f77e8955580334d2edc09bd381204355..89f5cfc15b946b6ea1fb7724f021024967cdb6c5 100644 GIT binary patch delta 22 ccmbQcf^qH&M()$Ryj%=G@JwUvMsA@H08d;7WB>pF delta 22 ccmbQcf^qH&M()$Ryj%=G5V5OwBezfp08T~*NB{r; diff --git a/code/tac-qlib/tac_qlib/contrib/model/__pycache__/__init__.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/model/__pycache__/__init__.cpython-312.pyc index c975d2b978f2cc08a388a5d921938704a3dd592d..f4e9bf0a78d22e256cade0d794a6958aaa7c6721 100644 GIT binary patch delta 20 acmdnbw4aIlG%qg~0}wpZSi6zigb@Ha3k4|v delta 20 acmdnbw4aIlG%qg~0}w>)>fOj~!UzC2^#u(8 diff --git a/code/tac-qlib/tac_qlib/contrib/model/__pycache__/rank_ensemble.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/model/__pycache__/rank_ensemble.cpython-312.pyc index 009ebd83c5156ca3d7039a112e0d277dd416ca86..c35c166a8449c14fa3cd4972c363d3d9d58620ef 100644 GIT binary patch delta 20 acmezB`PGyAG%qg~0}wpZSi6z?l?nh%ng;v; delta 20 acmezB`PGyAG%qg~0}w>)>fOlwN(BH*ga+UM diff --git a/code/tac-qlib/tac_qlib/contrib/model/__pycache__/rank_gbdt.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/model/__pycache__/rank_gbdt.cpython-312.pyc index 1716b680b5623394229f7600ad4c81ad07fa6a2b..98be60fe19fedb3d9cb21c3f91ef0e176bd93287 100644 GIT binary patch delta 20 acmZojXh`5b&CAQh00hr8)^6nfst*7@nFdw> delta 20 acmZojXh`5b&CAQh00a@cdN*=^)dv7Qg9bVP diff --git a/code/tac-qlib/tac_qlib/contrib/strategy/__pycache__/__init__.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/strategy/__pycache__/__init__.cpython-312.pyc index 9c9f7743970b1a3827bb72768bb6e8be03040759..69684c9c9624cb16c63f3a18a864c49a7db37fa9 100644 GIT binary patch delta 20 acmZ3>w3dncG%qg~0}wpZSi6y1i4g!cI|TCp delta 20 acmZ3>w3dncG%qg~0}w>)>fOk##0UU2B?Q+1 diff --git a/code/tac-qlib/tac_qlib/contrib/strategy/__pycache__/long_short.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/strategy/__pycache__/long_short.cpython-312.pyc index 6e38a7fa8584b80410ccc88e5feff228a7ece38b..4d3a5433e57e65e5dc96c6d2999f9d473b696dc4 100644 GIT binary patch delta 22 ccmcaHlkvt(M()$Ryj%=G@JwUvM((pd09W(}ZvX%Q delta 22 ccmcaHlkvt(M()$Ryj%=G5V5OwBllS!09M`yQvd(} diff --git a/code/tac-qlib/tac_qlib/contrib/strategy/__pycache__/optimal_stop.cpython-312.pyc b/code/tac-qlib/tac_qlib/contrib/strategy/__pycache__/optimal_stop.cpython-312.pyc index f983d5c2472cd16ef9f14a240674ec0a7f41e81c..53e72f512b47207a5292a918efef7fee162deef3 100644 GIT binary patch delta 20 acmdlJxF?YNG%qg~0}wpZSi6yXqXqy()&^w& delta 20 acmdlJxF?YNG%qg~0}w>)>fOk_Q3C)&zy?VG diff --git a/code/tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py b/code/tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py index fe60bac..839abb8 100644 --- a/code/tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py +++ b/code/tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py @@ -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) diff --git a/code/tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc b/code/tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc index a0e969bd6504bb8d9220f4641cc01e960c3120e4..0f1eb6f41d44bd9064b1f16f529dac6bb9d7c3fd 100644 GIT binary patch delta 20 acmeBT>0;qN&CAQh00hr8)^6nf&j0;qN&CAQh00a@cdN*?aX9NH-^#yVO diff --git a/code/tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc b/code/tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc index 2f8c537d11135155539276bee342d087aad8743e..cf99dd8a481f6e2d1f323f8d8d754730eadb357a 100644 GIT binary patch delta 20 acmewy`8ksNG%qg~0}wpZSi6z?g$@8tk_R3D delta 20 acmewy`8ksNG%qg~0}w>)>fOlwLI(g%d)>fOjKXaWF12nC}6