Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66cf0a149f | ||
|
|
6a1b05db2e | ||
|
|
c7fc73180c | ||
|
|
483a86e47f | ||
|
|
e660b4f2dd | ||
|
|
4e1debccba | ||
|
|
cb18467a6d | ||
|
|
894ac260a6 | ||
|
|
c455000a1e | ||
|
|
5c7b2265f4 |
+13
-13
@@ -1,27 +1,27 @@
|
|||||||
# TradeAC custom-qlib-code snapshot (auto-generated)
|
# TradeAC custom-qlib-code snapshot (auto-generated)
|
||||||
# parent repo HEAD : 59e733d88dcc4482f6a762ee79c989d8f817cb09
|
# parent repo HEAD : 6a1b05db2ee70d7661d695f5fd0b77b19c70e18a
|
||||||
# tac-qlib/tac_qlib/contrib
|
# tac-qlib/tac_qlib/contrib
|
||||||
# tac-qlib/tac_qlib/data
|
# tac-qlib/tac_qlib/data
|
||||||
# per-file hashes (git hash-object):
|
# per-file hashes (git hash-object):
|
||||||
1b6298c4a5652f2e863cbdc385a1014a570fcd59 tac-qlib/tac_qlib/contrib/__init__.py
|
1b6298c4a5652f2e863cbdc385a1014a570fcd59 tac-qlib/tac_qlib/contrib/__init__.py
|
||||||
0cca460303eb00586c00fa4c50f40772d7af9e2c tac-qlib/tac_qlib/contrib/__pycache__/__init__.cpython-312.pyc
|
b419ee55ed455a1c45423d1c9025ca5cc0a98576 tac-qlib/tac_qlib/contrib/__pycache__/__init__.cpython-312.pyc
|
||||||
c76a9f17f680e74eea766eff27f7624359749ed6 tac-qlib/tac_qlib/contrib/data/__init__.py
|
c76a9f17f680e74eea766eff27f7624359749ed6 tac-qlib/tac_qlib/contrib/data/__init__.py
|
||||||
d3bb8e52f9329f356dfce45c6103ebeaabc60e30 tac-qlib/tac_qlib/contrib/data/__pycache__/__init__.cpython-312.pyc
|
2f6c67620aa2f9e6aaaef3369361d9b3eac3d6ca tac-qlib/tac_qlib/contrib/data/__pycache__/__init__.cpython-312.pyc
|
||||||
bca85df83e0fdd57ddc8750bd94e5ee22b9459cb tac-qlib/tac_qlib/contrib/data/__pycache__/handler.cpython-312.pyc
|
fdd5923a70a399e8680913593ff111641947898e tac-qlib/tac_qlib/contrib/data/__pycache__/handler.cpython-312.pyc
|
||||||
0dd25ef161c6e0f15eafc84886e7e1381deb38c3 tac-qlib/tac_qlib/contrib/data/handler.py
|
0dd25ef161c6e0f15eafc84886e7e1381deb38c3 tac-qlib/tac_qlib/contrib/data/handler.py
|
||||||
b151d139a0dcde87d74b21e7c4b729176ba5c39b tac-qlib/tac_qlib/contrib/model/__init__.py
|
b151d139a0dcde87d74b21e7c4b729176ba5c39b tac-qlib/tac_qlib/contrib/model/__init__.py
|
||||||
6fdf879e404d47dc8fd617549a35db96f0f38628 tac-qlib/tac_qlib/contrib/model/__pycache__/__init__.cpython-312.pyc
|
08dec87ccdf6bb5d2cf611ca3032a4280aaab8cf tac-qlib/tac_qlib/contrib/model/__pycache__/__init__.cpython-312.pyc
|
||||||
c520d643e3b28c47aca92ab08395f5e3342f7185 tac-qlib/tac_qlib/contrib/model/__pycache__/rank_ensemble.cpython-312.pyc
|
6fb61946ea9a83dfb560de3717f5fbf482c4c00e tac-qlib/tac_qlib/contrib/model/__pycache__/rank_ensemble.cpython-312.pyc
|
||||||
66cf55a366e9a1c2841c7332cce772d87dcc12a1 tac-qlib/tac_qlib/contrib/model/__pycache__/rank_gbdt.cpython-312.pyc
|
3e80f2e08b661ddd2f58ffe5a6196063fa41ae51 tac-qlib/tac_qlib/contrib/model/__pycache__/rank_gbdt.cpython-312.pyc
|
||||||
d3f051f3a8650c42fedc7b367b966f7c74fb5789 tac-qlib/tac_qlib/contrib/model/rank_ensemble.py
|
d3f051f3a8650c42fedc7b367b966f7c74fb5789 tac-qlib/tac_qlib/contrib/model/rank_ensemble.py
|
||||||
ccfe7d554989aa7f3e5a2128ae663e51b2207149 tac-qlib/tac_qlib/contrib/model/rank_gbdt.py
|
d03e6611338918d4aac5eea4adf26f85a3763652 tac-qlib/tac_qlib/contrib/model/rank_gbdt.py
|
||||||
4afcf9058231111c412925f4c4b84e81d656db87 tac-qlib/tac_qlib/contrib/strategy/__init__.py
|
4afcf9058231111c412925f4c4b84e81d656db87 tac-qlib/tac_qlib/contrib/strategy/__init__.py
|
||||||
085e53604ed7517b07ffaf0992e81e62dc181ae1 tac-qlib/tac_qlib/contrib/strategy/__pycache__/__init__.cpython-312.pyc
|
6ad10c2ebe37c16417e67c7aeb731ad1fcb6da2f tac-qlib/tac_qlib/contrib/strategy/__pycache__/__init__.cpython-312.pyc
|
||||||
abac3e3e68e5d917e8ce1358fd3667759a58a7e7 tac-qlib/tac_qlib/contrib/strategy/__pycache__/optimal_stop.cpython-312.pyc
|
8d684b3216b040071d9ee4fa920a0e0c7486d278 tac-qlib/tac_qlib/contrib/strategy/__pycache__/optimal_stop.cpython-312.pyc
|
||||||
79aaad9e39fcc740a773f4f63c512ce1086cfde0 tac-qlib/tac_qlib/contrib/strategy/optimal_stop.py
|
79aaad9e39fcc740a773f4f63c512ce1086cfde0 tac-qlib/tac_qlib/contrib/strategy/optimal_stop.py
|
||||||
92e6e90eb0cd0a25142034560f27adb6b705b1a8 tac-qlib/tac_qlib/data/__init__.py
|
92e6e90eb0cd0a25142034560f27adb6b705b1a8 tac-qlib/tac_qlib/data/__init__.py
|
||||||
b6dc9ced54f4044f5954b60ddd199acae9eef456 tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc
|
7c4e6c345fad1978efe8860c0d977d0c02d6f8d9 tac-qlib/tac_qlib/data/__pycache__/__init__.cpython-312.pyc
|
||||||
5cede5184d17910b0232d343f8ecca460098ea11 tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc
|
99e602392d51663cb06d5c425000b1ed1e5a916b tac-qlib/tac_qlib/data/__pycache__/config.cpython-312.pyc
|
||||||
3a5accd6d239f342354cf1fa9410a6d2fb921de0 tac-qlib/tac_qlib/data/__pycache__/providers.cpython-312.pyc
|
020dcdcf288e4832c8cf2386351f78d5ceb4fe13 tac-qlib/tac_qlib/data/__pycache__/providers.cpython-312.pyc
|
||||||
53c9007a928841fd3c3b08450f9a6520ce1ac091 tac-qlib/tac_qlib/data/config.py
|
53c9007a928841fd3c3b08450f9a6520ce1ac091 tac-qlib/tac_qlib/data/config.py
|
||||||
8d0644f6f0d1efb94798ed444cc73e63b643459b tac-qlib/tac_qlib/data/providers.py
|
8d0644f6f0d1efb94798ed444cc73e63b643459b tac-qlib/tac_qlib/data/providers.py
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -53,23 +53,61 @@ from qlib.workflow import R
|
|||||||
__all__ = ["RankICLGBModel", "rankic_feval"]
|
__all__ = ["RankICLGBModel", "rankic_feval"]
|
||||||
|
|
||||||
|
|
||||||
|
def _group_averaged_rank(values: np.ndarray, gid: np.ndarray, offs: np.ndarray) -> np.ndarray:
|
||||||
|
"""Averaged (tie-corrected) rank of ``values`` within each group, vectorized.
|
||||||
|
|
||||||
|
``gid`` maps each row to its group id; ``offs`` holds the cumulative row
|
||||||
|
offsets so that group ``i`` occupies rows ``[offs[i], offs[i+1])``. Returns
|
||||||
|
the same result as ``pandas.Series.rank(method='average')`` applied per
|
||||||
|
group, but in one pass (``np.lexsort`` is the only non-linear step).
|
||||||
|
"""
|
||||||
|
n = len(values)
|
||||||
|
order = np.lexsort((values, gid))
|
||||||
|
ord_rank = np.empty(n, dtype=np.float64)
|
||||||
|
ord_rank[order] = np.arange(n, dtype=np.float64) - offs[gid[order]] + 1.0
|
||||||
|
sg = gid[order]
|
||||||
|
sv = values[order]
|
||||||
|
newblock = np.empty(n, dtype=bool)
|
||||||
|
newblock[0] = True
|
||||||
|
newblock[1:] = (sg[1:] != sg[:-1]) | (sv[1:] != sv[:-1])
|
||||||
|
blockid = np.cumsum(newblock) - 1
|
||||||
|
block_mean = np.bincount(blockid, weights=ord_rank[order]) / np.bincount(blockid)
|
||||||
|
out = np.empty(n)
|
||||||
|
out[order] = block_mean[blockid]
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def _per_day_spearman(preds: np.ndarray, labels: np.ndarray, group: np.ndarray) -> float:
|
def _per_day_spearman(preds: np.ndarray, labels: np.ndarray, group: np.ndarray) -> float:
|
||||||
"""Mean per-day Spearman rank correlation of preds vs labels.
|
"""Mean per-day Spearman rank correlation of preds vs labels.
|
||||||
|
|
||||||
``group`` holds the number of rows of each trading day (query group), in
|
``group`` holds the number of rows of each trading day (query group), in
|
||||||
order. Days with <3 valid rows or a constant pred/label are skipped.
|
order. Days with <3 valid rows or a constant pred/label are skipped.
|
||||||
|
|
||||||
|
Vectorized: per-day Spearman == Pearson of the per-day rank transforms,
|
||||||
|
and the Pearson moments (``sum``, ``sum`` of products/squares) aggregate
|
||||||
|
over each day with ``np.bincount``. Runs ~10x faster than the per-day
|
||||||
|
``pd.Series.rank()`` loop that preceded it — this feval is invoked on the
|
||||||
|
train and valid panels every boosting round, per seed.
|
||||||
"""
|
"""
|
||||||
if group is None or len(group) == 0:
|
if group is None or len(group) == 0:
|
||||||
return 0.0
|
return 0.0
|
||||||
offs = np.concatenate([[0], np.cumsum(group.astype(int))])
|
offs = np.concatenate([[0], np.cumsum(group.astype(int))])
|
||||||
vals = []
|
gid = np.repeat(np.arange(len(group)), group.astype(int))
|
||||||
for i in range(len(group)):
|
rp = _group_averaged_rank(preds, gid, offs)
|
||||||
s = slice(offs[i], offs[i + 1])
|
rl = _group_averaged_rank(labels, gid, offs)
|
||||||
p, l = preds[s], labels[s]
|
n_g = group.astype(float)
|
||||||
if len(p) < 3 or np.std(p) == 0 or np.std(l) == 0:
|
s_p = np.bincount(gid, weights=rp)
|
||||||
continue
|
s_l = np.bincount(gid, weights=rl)
|
||||||
vals.append(np.corrcoef(pd.Series(p).rank(), pd.Series(l).rank())[0, 1])
|
s_pl = np.bincount(gid, weights=rp * rl)
|
||||||
return float(np.mean(vals)) if vals else 0.0
|
s_pp = np.bincount(gid, weights=rp * rp)
|
||||||
|
s_ll = np.bincount(gid, weights=rl * rl)
|
||||||
|
cov = n_g * s_pl - s_p * s_l
|
||||||
|
var_p = n_g * s_pp - s_p ** 2
|
||||||
|
var_l = n_g * s_ll - s_l ** 2
|
||||||
|
denom = np.sqrt(var_p * var_l)
|
||||||
|
valid = (n_g >= 3) & (denom > 0)
|
||||||
|
corr = np.where(valid, cov / np.where(denom == 0, 1, denom), 0.0)
|
||||||
|
return float(corr[valid].mean()) if valid.any() else 0.0
|
||||||
|
|
||||||
|
|
||||||
def rankic_feval(preds, dataset):
|
def rankic_feval(preds, dataset):
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,140 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
# Compact stochastic feature set with reduced turnover: n_drop=1 instead of 2.
|
||||||
|
# Same setup as exp24 (compact baseline) but replacing the TopkDropout n_drop 2 with 1.
|
||||||
|
{%- 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" %}
|
||||||
|
|
||||||
|
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-exp22-stochastic-general" }
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# 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