Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee5aa8e73c | ||
|
|
891bd0743d | ||
|
|
7460d5fe01 | ||
|
|
337f99222d |
+6
-15
@@ -1,34 +1,25 @@
|
||||
# TradeAC custom-qlib-code snapshot (auto-generated)
|
||||
# parent repo HEAD : 05ccf4722613c8c78862aec4579a6e58b03c51b4
|
||||
# parent repo HEAD : 891bd0743d81f4a49cd91fc4d5dc1d97873e750e
|
||||
# tac-qlib/tac_qlib/contrib
|
||||
# tac-qlib/tac_qlib/data
|
||||
# per-file hashes (git hash-object):
|
||||
1b6298c4a5652f2e863cbdc385a1014a570fcd59 tac-qlib/tac_qlib/contrib/__init__.py
|
||||
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
|
||||
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
|
||||
fc3d01d530d4e84b3386614b6ac94324e811920e tac-qlib/tac_qlib/contrib/data/handler.py
|
||||
b151d139a0dcde87d74b21e7c4b729176ba5c39b tac-qlib/tac_qlib/contrib/model/__init__.py
|
||||
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
|
||||
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
|
||||
839abb89ad40cd516eabcfd91fe1be626b9f091f tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py
|
||||
fe60bacdfedd48617863be31f24b7c7daebfac5a tac-qlib/tac_qlib/contrib/strategy/weekly_rebalance.py
|
||||
92e6e90eb0cd0a25142034560f27adb6b705b1a8 tac-qlib/tac_qlib/data/__init__.py
|
||||
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
|
||||
fa1090eb6f17b1b7835038e35fac86334294d165 tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc
|
||||
48629a1f51bd4058036ce78d79ed49454982c051 tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc
|
||||
ad7c9b726c9c52773fa82031fcd681337be97fa8 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,9 +15,6 @@ import os
|
||||
from inspect import getfullargspec
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from qlib.data.dataset import processor as processor_module
|
||||
from qlib.data.dataset.handler import DataHandlerLP
|
||||
from qlib.utils import get_callable_kwargs
|
||||
@@ -147,174 +144,6 @@ class DropAllNaN(processor_module.Processor):
|
||||
return df
|
||||
|
||||
|
||||
class BenchResidual(processor_module.Processor):
|
||||
"""Subtract a benchmark instrument's forward return from the label, per datetime.
|
||||
|
||||
Turns the training target from an absolute-return rank into a *residual* rank:
|
||||
``r_i - r_bench`` is ranked cross-sectionally by the downstream ``CSRankNorm`` /
|
||||
``CSZScoreNorm`` processors instead of ``r_i`` alone. Must be inserted BEFORE any
|
||||
per-date normalization so the ranking itself is computed on residual returns
|
||||
(ordering flips exactly where the benchmark trends).
|
||||
|
||||
Stateless: ``fit`` is a no-op and the benchmark forward return is recomputed from
|
||||
the lake parquet on first ``__call__``. Rows whose benchmark value is missing are
|
||||
left untouched. Accepts ``fit_start_time``/``fit_end_time`` (ignored) so
|
||||
``check_transform_proc`` can inject the fit window uniformly.
|
||||
|
||||
NOTE: under any cross-sectional normalization downstream (``CSRankNorm`` /
|
||||
``CSZScoreNorm``) this processor is a mathematical no-op: subtracting the same
|
||||
per-date constant preserves ranks, and z-scoring absorbs constant shifts. Use
|
||||
``BenchBetaResidual`` for a target that actually reorders.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
benchmark="SPY",
|
||||
fields_group="label",
|
||||
lake_root=None,
|
||||
market="US",
|
||||
timeframe=None,
|
||||
freq="day",
|
||||
fit_start_time=None,
|
||||
fit_end_time=None,
|
||||
):
|
||||
self.benchmark = benchmark
|
||||
self.fields_group = fields_group
|
||||
self.lake_root = lake_root
|
||||
self.market = market
|
||||
self.timeframe = timeframe or timeframe_for_freq(freq)
|
||||
self.fit_start_time = fit_start_time
|
||||
self.fit_end_time = fit_end_time
|
||||
self._bench_label = None
|
||||
|
||||
def _load_bench_label(self):
|
||||
if self._bench_label is not None:
|
||||
return self._bench_label
|
||||
cfg = LakeConfig(self.lake_root, self.market)
|
||||
p = cfg.bar_path(self.timeframe, self.benchmark)
|
||||
if not p.exists():
|
||||
raise FileNotFoundError(f"BenchResidual: benchmark bar file not found: {p}")
|
||||
df = pd.read_parquet(p)
|
||||
s = pd.Series(df["c"].astype(float).values, index=pd.to_datetime(df["t"])).sort_index()
|
||||
s.index = s.index.normalize()
|
||||
# mirror Ref($close,-6)/Ref($close,-1)-1 on the benchmark's own calendar
|
||||
bench_label = s.shift(-6) / s.shift(-1) - 1
|
||||
self._bench_label = bench_label[~bench_label.index.duplicated(keep="last")]
|
||||
return self._bench_label
|
||||
|
||||
def fit(self, df=None):
|
||||
return self
|
||||
|
||||
def __call__(self, df):
|
||||
bl = self._load_bench_label()
|
||||
cols = processor_module.get_group_columns(df, self.fields_group)
|
||||
dt = df.index.get_level_values("datetime")
|
||||
aligned = bl.reindex(pd.DatetimeIndex(dt.unique())).reindex(dt)
|
||||
mask = aligned.notna().values
|
||||
out = df.copy()
|
||||
for c in cols:
|
||||
vals = df[c].values
|
||||
res = vals.copy()
|
||||
res[mask] = np.asarray(vals[mask], dtype=float) - aligned[mask].values
|
||||
out[c] = res
|
||||
return out
|
||||
|
||||
|
||||
class BenchBetaResidual(processor_module.Processor):
|
||||
"""Residualize the label against a beta-scaled benchmark move: ``r_i - b_i * r_bench``.
|
||||
|
||||
Unlike a plain constant subtraction (see ``BenchResidual``), the name-specific rolling
|
||||
beta ``b_i`` makes this survive cross-sectional normalization: in up-weeks high-beta
|
||||
names lose rank, in down-weeks they gain — exactly the relative structure an absolute-
|
||||
return ranking hides.
|
||||
|
||||
Beta is estimated from *past* data only (rolling ``window`` trading days of daily close
|
||||
returns of each instrument vs the benchmark, both read up to and including ``t``), so
|
||||
no lookahead enters the target. The benchmark leg uses the same horizon as the label
|
||||
expression (``Ref($close,-6)/Ref($close,-1)-1`` by default via ``horizon``/``base``,
|
||||
matching the yaml's 6-day label). Rows with missing beta or benchmark values keep
|
||||
their raw label.
|
||||
|
||||
Requires ``$close`` to be present in the feature group (it always is for TACHandler).
|
||||
Stateless; accepts ``fit_start_time``/``fit_end_time`` (ignored) for uniform kwargs
|
||||
injection. Must be inserted BEFORE any per-date normalization processor.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
benchmark="SPY",
|
||||
fields_group="label",
|
||||
lake_root=None,
|
||||
market="US",
|
||||
timeframe=None,
|
||||
freq="day",
|
||||
window=63,
|
||||
horizon=6,
|
||||
base=1,
|
||||
feature_field="$close",
|
||||
fit_start_time=None,
|
||||
fit_end_time=None,
|
||||
):
|
||||
self.benchmark = benchmark
|
||||
self.fields_group = fields_group
|
||||
self.lake_root = lake_root
|
||||
self.market = market
|
||||
self.timeframe = timeframe or timeframe_for_freq(freq)
|
||||
self.window = int(window)
|
||||
self.horizon = int(horizon)
|
||||
self.base = int(base)
|
||||
self.feature_field = feature_field
|
||||
self.fit_start_time = fit_start_time
|
||||
self.fit_end_time = fit_end_time
|
||||
self._bench = None
|
||||
|
||||
def _load_bench_close(self):
|
||||
if self._bench is not None:
|
||||
return self._bench
|
||||
cfg = LakeConfig(self.lake_root, self.market)
|
||||
p = cfg.bar_path(self.timeframe, self.benchmark)
|
||||
if not p.exists():
|
||||
raise FileNotFoundError(f"BenchBetaResidual: benchmark bar file not found: {p}")
|
||||
df = pd.read_parquet(p)
|
||||
s = pd.Series(df["c"].astype(float).values, index=pd.to_datetime(df["t"])).sort_index()
|
||||
s.index = s.index.normalize()
|
||||
self._bench = s[~s.index.duplicated(keep="last")]
|
||||
return self._bench
|
||||
|
||||
def fit(self, df=None):
|
||||
return self
|
||||
|
||||
def __call__(self, df):
|
||||
bench = self._load_bench_close()
|
||||
|
||||
# benchmark forward return over the same horizon as the label expression
|
||||
fwd = bench.shift(-(self.base + self.horizon - 1)) / bench.shift(-self.base) - 1
|
||||
|
||||
px_col = ("feature", self.feature_field)
|
||||
if px_col not in df.columns:
|
||||
raise KeyError(f"BenchBetaResidual: {self.feature_field} not found in features")
|
||||
px = df[px_col].unstack("instrument").sort_index()
|
||||
rets = px / px.shift(1) - 1
|
||||
bret = bench.reindex(px.index).pct_change()
|
||||
|
||||
# rolling beta per instrument using data <= t (no lookahead)
|
||||
cov = rets.rolling(self.window, min_periods=max(10, self.window // 2)).cov(bret)
|
||||
var = bret.rolling(self.window, min_periods=max(10, self.window // 2)).var()
|
||||
beta = cov.div(var, axis=0)
|
||||
|
||||
contrib = beta.mul(fwd.reindex(px.index), axis=0)
|
||||
cols = list(processor_module.get_group_columns(df, self.fields_group))
|
||||
out = df.copy()
|
||||
for c in cols:
|
||||
lab = df[c].unstack("instrument").reindex(px.index)
|
||||
resid = lab - contrib.where(contrib.notna() & lab.notna(), 0.0)
|
||||
new_vals = resid.stack()
|
||||
new_vals.index.names = df.index.names
|
||||
# residual where available, raw label otherwise (e.g. beta warm-up rows)
|
||||
out[c] = new_vals.reindex(out.index).fillna(df[c])
|
||||
return out
|
||||
|
||||
|
||||
class TACHandler(DataHandlerLP):
|
||||
"""DataHandlerLP backed by the TradeAC parquet lake.
|
||||
|
||||
@@ -417,12 +246,10 @@ class TACHandler(DataHandlerLP):
|
||||
return get_common_feature_fields(lake_root, market, timeframe_for_freq(freq))
|
||||
|
||||
|
||||
__all__ = ["TACHandler", "DropAllNaN", "BenchResidual", "BenchBetaResidual", "get_common_feature_fields"]
|
||||
__all__ = ["TACHandler", "DropAllNaN", "get_common_feature_fields"]
|
||||
|
||||
|
||||
# Make `DropAllNaN`/`BenchResidual`/`BenchBetaResidual` resolvable by bare name from processor
|
||||
# configs (e.g. the default ``infer_processors`` and workflow yamls that reference them without a
|
||||
# ``module_path``), mirroring how qlib registers its own processors in ``qlib.data.dataset.processor``.
|
||||
# Make `DropAllNaN` resolvable by bare name from processor configs (e.g. the default
|
||||
# ``infer_processors`` and workflow yamls that reference it without a ``module_path``),
|
||||
# mirroring how qlib registers its own processors in ``qlib.data.dataset.processor``.
|
||||
processor_module.DropAllNaN = DropAllNaN
|
||||
processor_module.BenchResidual = BenchResidual
|
||||
processor_module.BenchBetaResidual = BenchBetaResidual
|
||||
|
||||
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,20 +37,11 @@ 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,
|
||||
rebalance_every_n_weeks: int = 1,
|
||||
rebalance_every_n_days: int = 0, **kwargs):
|
||||
def __init__(self, *, topk, n_drop, hold_band_pct: float = DEFAULT_HOLD_BAND_PCT, **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:
|
||||
@@ -62,24 +53,12 @@ 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)
|
||||
|
||||
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:
|
||||
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:
|
||||
# not the first trading day of this ISO week -> hold
|
||||
return TradeDecisionWO([], self)
|
||||
|
||||
pred_start_time, pred_end_time = self.trade_calendar.get_step_time(trade_step, shift=1)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,140 +0,0 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
# QUEUE-01 — M2 reproduction: risk-adjusted 22d Sharpe drift (sp_sharpe_22).
|
||||
#
|
||||
# Hypothesis (book ch.01/ch.07, EVIDENCE#018 -> exp 30): adding the
|
||||
# risk-adjusted 22d Sharpe drift feature (sp_sharpe_22) to the compact
|
||||
# stochastic reference IMPROVES net portfolio performance (exp 30: net +6.53%
|
||||
# IR 0.62 vs reference +2.13% IR 0.21) while rank metrics dip (RankIC 0.0576 vs
|
||||
# 0.0663). exp 30 is a SINGLE clean-lake run, unreproduced -> HYPOTHESIS.
|
||||
#
|
||||
# Change vs exp-26 reference (EVIDENCE#015, run 21afc6af...): ONE feature added,
|
||||
# feature_fields = compact set + sp_sharpe_22. Everything else byte-identical.
|
||||
#
|
||||
# Acceptance: net_ann_return > +2.13% AND net_IR > 0.21 (else HYPOTHESIS -> REFUTED).
|
||||
# Run: rd_run_workflow config_path=<repo>/experiments/queue/workflows/q01_m2_sharpe22_repro.yaml \
|
||||
# experiment_name=tac-rd-q01-m2-sharpe22-repro
|
||||
# -----------------------------------------------------------------------------
|
||||
{%- set LAKE = TAC_LAKE_DIR %}
|
||||
{%- set UNIVERSE = "SPY,QQQ,DIA,IWM,MDY,VTI,VOO,VEA,VWO,VT,EFA,EEM,TLT,IEF,SHY,AGG,BND,LQD,HYG,JNK,EMB,GLD,SLV,USO,UNG,DBA,DBC,XLK,XLF,XLE,XLV,XLI,XLY,XLP,XLU,XLB,XLRE,ARKK,SMH,SOXX,IBB,XBI,ITA,XAR,ICLN,TAN,FDN,IGV,ESPO,REM" %}
|
||||
{%- set FEATURES = "$open,$high,$low,$close,$vwap,$volume,sp_ret,sp_jump_ratio,sp_jump_flag,sp_jump_tail,sp_max_move,sp_rv1,sp_rv5,sp_rv22,sp_vol_ratio_5_22,sp_vol_ratio_1_22,sp_trend_slope_5,sp_trend_slope_20,sp_trend_slope_60,sp_logp,sp_hurst_exponent,sp_sig_level1_lead,sp_sig_level1_lag,sp_sig_level2_lead_lag,sp_sig_level2_lag_lead,sp_sharpe_22" %}
|
||||
|
||||
qlib_init:
|
||||
provider_uri: "{{ LAKE }}"
|
||||
region: us
|
||||
expression_cache: null
|
||||
dataset_cache: null
|
||||
|
||||
calendar_provider:
|
||||
class: tac_qlib.data.providers.LakeCalendarProvider
|
||||
kwargs:
|
||||
lake_root: "{{ LAKE }}"
|
||||
market: US
|
||||
instrument_provider:
|
||||
class: tac_qlib.data.providers.LakeInstrumentProvider
|
||||
kwargs:
|
||||
lake_root: "{{ LAKE }}"
|
||||
market: US
|
||||
markets: {}
|
||||
feature_provider:
|
||||
class: tac_qlib.data.providers.LakeFeatureProvider
|
||||
kwargs:
|
||||
lake_root: "{{ LAKE }}"
|
||||
market: US
|
||||
|
||||
exp_manager:
|
||||
class: MLflowExpManager
|
||||
module_path: qlib.workflow.expm
|
||||
kwargs:
|
||||
uri: "sqlite:///{{ LAKE }}/mlruns.db"
|
||||
default_exp_name: "tac-rd-q01-m2-sharpe22-repro"
|
||||
|
||||
task:
|
||||
model:
|
||||
class: RankICEnsembleLGBModel
|
||||
module_path: tac_qlib.contrib.model.rank_ensemble
|
||||
kwargs:
|
||||
loss: mse
|
||||
learning_rate: 0.02
|
||||
num_leaves: 31
|
||||
n_estimators: 3000
|
||||
num_boost_round: 3000
|
||||
early_stopping_rounds: 200
|
||||
min_data_in_leaf: 20
|
||||
lambda_l2: 0.5
|
||||
colsample_bytree: 0.8
|
||||
subsample: 0.8
|
||||
subsample_freq: 1
|
||||
reg_alpha: 0.1
|
||||
reg_lambda: 1.0
|
||||
seeds: "42,7,2026,99,123"
|
||||
parallel: 5
|
||||
|
||||
dataset:
|
||||
class: DatasetH
|
||||
module_path: qlib.data.dataset
|
||||
kwargs:
|
||||
handler:
|
||||
class: TACHandler
|
||||
module_path: tac_qlib.contrib.data.handler
|
||||
kwargs:
|
||||
instruments: "{{ UNIVERSE }}"
|
||||
start_time: 2015-01-03
|
||||
end_time: 2026-08-10
|
||||
fit_start_time: 2016-01-04
|
||||
fit_end_time: 2025-09-01
|
||||
freq: day
|
||||
lake_root: "{{ LAKE }}"
|
||||
market: US
|
||||
label: "Ref($close,-6)/Ref($close,-1)-1"
|
||||
feature_fields: "{{ FEATURES }}"
|
||||
infer_processors:
|
||||
- class: DropAllNaN
|
||||
kwargs: {}
|
||||
- class: ProcessInf
|
||||
kwargs: {}
|
||||
- class: CSRankNorm
|
||||
kwargs: {}
|
||||
- class: ZScoreNorm
|
||||
kwargs: {}
|
||||
- class: Fillna
|
||||
kwargs: {}
|
||||
segments:
|
||||
train: [2016-01-04, 2025-09-01]
|
||||
valid: [2025-09-03, 2026-01-03]
|
||||
test: [2026-01-04, 2026-08-10]
|
||||
|
||||
record:
|
||||
- class: SignalRecord
|
||||
module_path: qlib.workflow.record_temp
|
||||
kwargs: {}
|
||||
- class: SigAnaRecord
|
||||
module_path: qlib.workflow.record_temp
|
||||
kwargs:
|
||||
ana_long_short: true
|
||||
ann_scaler: 252
|
||||
- class: PortAnaRecord
|
||||
module_path: qlib.workflow.record_temp
|
||||
kwargs:
|
||||
config:
|
||||
strategy:
|
||||
class: TopkDropoutStrategy
|
||||
module_path: qlib.contrib.strategy
|
||||
kwargs:
|
||||
signal: "<PRED>"
|
||||
topk: 10
|
||||
n_drop: 1
|
||||
only_tradable: true
|
||||
risk_degree: 0.95
|
||||
backtest:
|
||||
start_time: 2026-01-04
|
||||
end_time: 2026-08-10
|
||||
account: 1000000
|
||||
benchmark: SPY
|
||||
exchange_kwargs:
|
||||
codes: "{{ UNIVERSE }}"
|
||||
deal_price: $close
|
||||
freq: day
|
||||
open_cost: 0.0005
|
||||
close_cost: 0.0015
|
||||
min_cost: 5.0
|
||||
risk_analysis_freq: 1d
|
||||
@@ -1,99 +0,0 @@
|
||||
# M2 isolation run: base compact set + risk-adjusted drift sp_sharpe_22.
|
||||
# Exact copy of exp26 (reference: expId=25 run=21afc6afdb674a399b59dd76c97628ce)
|
||||
# except feature_fields. 5-seed ensemble.
|
||||
{%- set LAKE = TAC_LAKE_DIR %}
|
||||
{%- set UNIVERSE = "SPY,QQQ,DIA,IWM,MDY,VTI,VOO,VEA,VWO,VT,EFA,EEM,TLT,IEF,SHY,AGG,BND,LQD,HYG,JNK,EMB,GLD,SLV,USO,UNG,DBA,DBC,XLK,XLF,XLE,XLV,XLI,XLY,XLP,XLU,XLB,XLRE,ARKK,SMH,SOXX,IBB,XBI,ITA,XAR,ICLN,TAN,FDN,IGV,ESPO,REM" %}
|
||||
{%- set FEATURES = "$open,$high,$low,$close,$vwap,$volume,sp_ret,sp_jump_ratio,sp_jump_flag,sp_jump_tail,sp_max_move,sp_rv1,sp_rv5,sp_rv22,sp_vol_ratio_5_22,sp_vol_ratio_1_22,sp_trend_slope_5,sp_trend_slope_20,sp_trend_slope_60,sp_logp,sp_hurst_exponent,sp_sig_level1_lead,sp_sig_level1_lag,sp_sig_level2_lead_lag,sp_sig_level2_lag_lead,sp_sharpe_22" %}
|
||||
|
||||
qlib_init:
|
||||
provider_uri: "{{ LAKE }}"
|
||||
region: us
|
||||
expression_cache: null
|
||||
dataset_cache: null
|
||||
calendar_provider:
|
||||
class: tac_qlib.data.providers.LakeCalendarProvider
|
||||
kwargs: { lake_root: "{{ LAKE }}", market: US }
|
||||
instrument_provider:
|
||||
class: tac_qlib.data.providers.LakeInstrumentProvider
|
||||
kwargs: { lake_root: "{{ LAKE }}", market: US, markets: {} }
|
||||
feature_provider:
|
||||
class: tac_qlib.data.providers.LakeFeatureProvider
|
||||
kwargs: { lake_root: "{{ LAKE }}", market: US }
|
||||
exp_manager:
|
||||
class: MLflowExpManager
|
||||
module_path: qlib.workflow.expm
|
||||
kwargs: { uri: "sqlite:///mlruns.db", default_exp_name: "tac-rd-exp30-m2-sharpe" }
|
||||
|
||||
task:
|
||||
model:
|
||||
class: RankICEnsembleLGBModel
|
||||
module_path: tac_qlib.contrib.model.rank_ensemble
|
||||
kwargs:
|
||||
loss: mse
|
||||
learning_rate: 0.02
|
||||
num_leaves: 31
|
||||
n_estimators: 3000
|
||||
num_boost_round: 3000
|
||||
early_stopping_rounds: 200
|
||||
min_data_in_leaf: 20
|
||||
lambda_l2: 0.5
|
||||
colsample_bytree: 0.8
|
||||
subsample: 0.8
|
||||
subsample_freq: 1
|
||||
reg_alpha: 0.1
|
||||
reg_lambda: 1.0
|
||||
seeds: "42,7,2026,99,123"
|
||||
|
||||
dataset:
|
||||
class: DatasetH
|
||||
module_path: qlib.data.dataset
|
||||
kwargs:
|
||||
handler:
|
||||
class: TACHandler
|
||||
module_path: tac_qlib.contrib.data.handler
|
||||
kwargs:
|
||||
instruments: "{{ UNIVERSE }}"
|
||||
start_time: 2015-01-03
|
||||
end_time: 2026-08-10
|
||||
fit_start_time: 2016-01-04
|
||||
fit_end_time: 2025-09-01
|
||||
freq: day
|
||||
lake_root: "{{ LAKE }}"
|
||||
market: US
|
||||
label: "Ref($close,-6)/Ref($close,-1)-1"
|
||||
feature_fields: "{{ FEATURES }}"
|
||||
infer_processors:
|
||||
- { class: DropAllNaN, kwargs: { fit_start_time: "2016-01-04", fit_end_time: "2025-09-01" } }
|
||||
- { class: ProcessInf, kwargs: {} }
|
||||
- { class: CSRankNorm, kwargs: {} }
|
||||
- { class: ZScoreNorm, kwargs: { fit_start_time: "2016-01-04", fit_end_time: "2025-09-01" } }
|
||||
- { class: Fillna, kwargs: {} }
|
||||
segments:
|
||||
train: [2016-01-04, 2025-09-01]
|
||||
valid: [2025-09-03, 2026-01-03]
|
||||
test: [2026-01-04, 2026-08-10]
|
||||
|
||||
record:
|
||||
- { class: SignalRecord, module_path: qlib.workflow.record_temp, kwargs: {} }
|
||||
- { class: SigAnaRecord, module_path: qlib.workflow.record_temp, kwargs: { ana_long_short: true, ann_scaler: 252 } }
|
||||
- class: PortAnaRecord
|
||||
module_path: qlib.workflow.record_temp
|
||||
kwargs:
|
||||
config:
|
||||
strategy:
|
||||
class: TopkDropoutStrategy
|
||||
module_path: qlib.contrib.strategy
|
||||
kwargs: { signal: "<PRED>", topk: 10, n_drop: 1, only_tradable: true, risk_degree: 0.95 }
|
||||
backtest:
|
||||
start_time: 2026-01-04
|
||||
end_time: 2026-08-10
|
||||
account: 1000000
|
||||
benchmark: SPY
|
||||
exchange_kwargs:
|
||||
codes: "{{ UNIVERSE }}"
|
||||
deal_price: $close
|
||||
freq: day
|
||||
open_cost: 0.0005
|
||||
close_cost: 0.0015
|
||||
min_cost: 5.0
|
||||
risk_analysis_freq: 1d
|
||||
@@ -1,99 +0,0 @@
|
||||
# M3 isolation run: base compact set + GARCH(1,1) vol-regime trio.
|
||||
# Exact copy of exp26 (reference: expId=25 run=21afc6afdb674a399b59dd76c97628ce)
|
||||
# except feature_fields. 5-seed ensemble.
|
||||
{%- set LAKE = TAC_LAKE_DIR %}
|
||||
{%- set UNIVERSE = "SPY,QQQ,DIA,IWM,MDY,VTI,VOO,VEA,VWO,VT,EFA,EEM,TLT,IEF,SHY,AGG,BND,LQD,HYG,JNK,EMB,GLD,SLV,USO,UNG,DBA,DBC,XLK,XLF,XLE,XLV,XLI,XLY,XLP,XLU,XLB,XLRE,ARKK,SMH,SOXX,IBB,XBI,ITA,XAR,ICLN,TAN,FDN,IGV,ESPO,REM" %}
|
||||
{%- set FEATURES = "$open,$high,$low,$close,$vwap,$volume,sp_ret,sp_jump_ratio,sp_jump_flag,sp_jump_tail,sp_max_move,sp_rv1,sp_rv5,sp_rv22,sp_vol_ratio_5_22,sp_vol_ratio_1_22,sp_trend_slope_5,sp_trend_slope_20,sp_trend_slope_60,sp_logp,sp_hurst_exponent,sp_sig_level1_lead,sp_sig_level1_lag,sp_sig_level2_lead_lag,sp_sig_level2_lag_lead,sp_garch_cond_var,sp_garch_persistence,sp_garch_std_resid" %}
|
||||
|
||||
qlib_init:
|
||||
provider_uri: "{{ LAKE }}"
|
||||
region: us
|
||||
expression_cache: null
|
||||
dataset_cache: null
|
||||
calendar_provider:
|
||||
class: tac_qlib.data.providers.LakeCalendarProvider
|
||||
kwargs: { lake_root: "{{ LAKE }}", market: US }
|
||||
instrument_provider:
|
||||
class: tac_qlib.data.providers.LakeInstrumentProvider
|
||||
kwargs: { lake_root: "{{ LAKE }}", market: US, markets: {} }
|
||||
feature_provider:
|
||||
class: tac_qlib.data.providers.LakeFeatureProvider
|
||||
kwargs: { lake_root: "{{ LAKE }}", market: US }
|
||||
exp_manager:
|
||||
class: MLflowExpManager
|
||||
module_path: qlib.workflow.expm
|
||||
kwargs: { uri: "sqlite:///mlruns.db", default_exp_name: "tac-rd-exp31-m3-garch" }
|
||||
|
||||
task:
|
||||
model:
|
||||
class: RankICEnsembleLGBModel
|
||||
module_path: tac_qlib.contrib.model.rank_ensemble
|
||||
kwargs:
|
||||
loss: mse
|
||||
learning_rate: 0.02
|
||||
num_leaves: 31
|
||||
n_estimators: 3000
|
||||
num_boost_round: 3000
|
||||
early_stopping_rounds: 200
|
||||
min_data_in_leaf: 20
|
||||
lambda_l2: 0.5
|
||||
colsample_bytree: 0.8
|
||||
subsample: 0.8
|
||||
subsample_freq: 1
|
||||
reg_alpha: 0.1
|
||||
reg_lambda: 1.0
|
||||
seeds: "42,7,2026,99,123"
|
||||
|
||||
dataset:
|
||||
class: DatasetH
|
||||
module_path: qlib.data.dataset
|
||||
kwargs:
|
||||
handler:
|
||||
class: TACHandler
|
||||
module_path: tac_qlib.contrib.data.handler
|
||||
kwargs:
|
||||
instruments: "{{ UNIVERSE }}"
|
||||
start_time: 2015-01-03
|
||||
end_time: 2026-08-10
|
||||
fit_start_time: 2016-01-04
|
||||
fit_end_time: 2025-09-01
|
||||
freq: day
|
||||
lake_root: "{{ LAKE }}"
|
||||
market: US
|
||||
label: "Ref($close,-6)/Ref($close,-1)-1"
|
||||
feature_fields: "{{ FEATURES }}"
|
||||
infer_processors:
|
||||
- { class: DropAllNaN, kwargs: { fit_start_time: "2016-01-04", fit_end_time: "2025-09-01" } }
|
||||
- { class: ProcessInf, kwargs: {} }
|
||||
- { class: CSRankNorm, kwargs: {} }
|
||||
- { class: ZScoreNorm, kwargs: { fit_start_time: "2016-01-04", fit_end_time: "2025-09-01" } }
|
||||
- { class: Fillna, kwargs: {} }
|
||||
segments:
|
||||
train: [2016-01-04, 2025-09-01]
|
||||
valid: [2025-09-03, 2026-01-03]
|
||||
test: [2026-01-04, 2026-08-10]
|
||||
|
||||
record:
|
||||
- { class: SignalRecord, module_path: qlib.workflow.record_temp, kwargs: {} }
|
||||
- { class: SigAnaRecord, module_path: qlib.workflow.record_temp, kwargs: { ana_long_short: true, ann_scaler: 252 } }
|
||||
- class: PortAnaRecord
|
||||
module_path: qlib.workflow.record_temp
|
||||
kwargs:
|
||||
config:
|
||||
strategy:
|
||||
class: TopkDropoutStrategy
|
||||
module_path: qlib.contrib.strategy
|
||||
kwargs: { signal: "<PRED>", topk: 10, n_drop: 1, only_tradable: true, risk_degree: 0.95 }
|
||||
backtest:
|
||||
start_time: 2026-01-04
|
||||
end_time: 2026-08-10
|
||||
account: 1000000
|
||||
benchmark: SPY
|
||||
exchange_kwargs:
|
||||
codes: "{{ UNIVERSE }}"
|
||||
deal_price: $close
|
||||
freq: day
|
||||
open_cost: 0.0005
|
||||
close_cost: 0.0015
|
||||
min_cost: 5.0
|
||||
risk_analysis_freq: 1d
|
||||
Reference in New Issue
Block a user