Compare commits

..
8 changed files with 787 additions and 51 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# TradeAC custom-qlib-code snapshot (auto-generated) # TradeAC custom-qlib-code snapshot (auto-generated)
# parent repo HEAD : 59839ff48760b632a2d1bb40877766b1da105891 # parent repo HEAD : 507846cee16eeee11daf33c4176e8aec79b985b2
# 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):
+35
View File
@@ -0,0 +1,35 @@
# Q08 — Risk-limit A/B re-validation (trace 40)
**Status:** DONE (verdict: REFUTED as an IR edge; safety-net value retained)
## Input
- Reference signal: exp-26 pred, run `21afc6afdb674a399b59dd76c97628ce` (mlflow exp 25)
- Window: 2026-01-04 → 2026-08-10, Topk10 n_drop1, SPY benchmark, $1M, 5/15bp/$5
- Tool: `rd_risk_calibrate` (A/B + sensitivity grid). Full JSON: `risk_calibration.json`
## Candidate spec (round-3 live spec)
`{"liquidity_floor_adv": 5000000, "size_cap_pct": 0.12, "concentration_cap_pct": 0.95, "drawdown_pause_pct": 0.10}`
## Results (net, with cost)
| Config | IR | Ann. return | Max DD |
|---|---|---|---|
| baseline (no limits) | 1.5804 | +27.50% | −6.91% |
| **candidate (5M floor + caps)** | **1.5121** | +2.20% | **−0.65%** |
| liquidity $10M | 1.5457 | +2.25% | −0.64% |
## Findings
- **Floor binds, not a no-op**: $5M liquidity floor dropped 8 symbols —
`DBA, DBC, ESPO, FDN, REM, TAN, UNG, XAR`.
- **No IR edge from the gate**: candidate IR (1.512) is BELOW baseline (1.580).
The exp-18 direction (floor IR 0.81→0.98) does NOT reproduce on the clean-lake
reference signal.
- **Drawdown cut is pure defunding**: size_cap 0.12 × concentration 0.95 fold
the effective risk_degree to ~0.0095 → ~$9.5k deployed of $1M (~100x less).
Sensitivity grid shows both caps are no-ops (conc 20–50% identical,
size_cap 5–20% identical); only the liquidity floor moves returns, marginally.
- **Conclusion**: keep the live spec as a safety net; there is no risk-limit
gate IR edge to harvest when the signal is the bottleneck (exp-20 pattern).
## Artifacts on this branch
- `evidence/q08-risklimit/risk_calibration.json` — full calibration dump
- `queue/designs/q08_risk_limit_ab.md` — the pre-registered design doc
@@ -0,0 +1,401 @@
{
"rows": [
{
"label": "baseline (no limits)",
"mean": 0.001155,
"std": 0.011279,
"annualized_return": 0.274989,
"information_ratio": 1.580427,
"max_drawdown": -0.069145
},
{
"label": "liquidity $10,000,000",
"mean": 9.4e-05,
"std": 0.000942,
"annualized_return": 0.022464,
"information_ratio": 1.545736,
"max_drawdown": -0.006389
},
{
"label": "conc 20%",
"mean": 0.000115,
"std": 0.001168,
"annualized_return": 0.027285,
"information_ratio": 1.513718,
"max_drawdown": -0.008104
},
{
"label": "conc 30%",
"mean": 0.000115,
"std": 0.001168,
"annualized_return": 0.027285,
"information_ratio": 1.513718,
"max_drawdown": -0.008104
},
{
"label": "conc 40%",
"mean": 0.000115,
"std": 0.001168,
"annualized_return": 0.027285,
"information_ratio": 1.513718,
"max_drawdown": -0.008104
},
{
"label": "conc 50%",
"mean": 0.000115,
"std": 0.001168,
"annualized_return": 0.027285,
"information_ratio": 1.513718,
"max_drawdown": -0.008104
},
{
"label": "candidate {\"liquidity_floor_adv\": 5000000.0, \"size_cap_pct\": 0.12, \"concentration_cap_pct\": 0.95, \"drawdown_pause_pct\": 0.1}",
"mean": 9.2e-05,
"std": 0.000943,
"annualized_return": 0.021991,
"information_ratio": 1.512051,
"max_drawdown": -0.00653
},
{
"label": "size_cap 5%",
"mean": 9.2e-05,
"std": 0.000943,
"annualized_return": 0.021991,
"information_ratio": 1.512051,
"max_drawdown": -0.00653
},
{
"label": "size_cap 10%",
"mean": 9.2e-05,
"std": 0.000943,
"annualized_return": 0.021991,
"information_ratio": 1.512051,
"max_drawdown": -0.00653
},
{
"label": "size_cap 15%",
"mean": 9.2e-05,
"std": 0.000943,
"annualized_return": 0.021991,
"information_ratio": 1.512051,
"max_drawdown": -0.00653
},
{
"label": "size_cap 20%",
"mean": 9.2e-05,
"std": 0.000943,
"annualized_return": 0.021991,
"information_ratio": 1.512051,
"max_drawdown": -0.00653
},
{
"label": "liquidity $5,000,000",
"mean": 9.2e-05,
"std": 0.000943,
"annualized_return": 0.021991,
"information_ratio": 1.512051,
"max_drawdown": -0.00653
},
{
"label": "liquidity $1,000,000",
"mean": 9.1e-05,
"std": 0.000929,
"annualized_return": 0.021625,
"information_ratio": 1.508748,
"max_drawdown": -0.006376
},
{
"label": "liquidity $2,500,000",
"mean": 7.1e-05,
"std": 0.000918,
"annualized_return": 0.017,
"information_ratio": 1.199721,
"max_drawdown": -0.007158
}
],
"runs": {
"baseline": {
"risk": {
"mean": 0.0011554172081987572,
"std": 0.01127853762493476,
"annualized_return": 0.27498929555130425,
"information_ratio": 1.5804272791471323,
"max_drawdown": -0.06914515336341577
},
"applied": {}
},
"candidate": {
"risk": {
"mean": 9.239707947451976e-05,
"std": 0.0009427144352738658,
"annualized_return": 0.0219905049149357,
"information_ratio": 1.5120514373488407,
"max_drawdown": -0.006530482262119444
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"size_cap 5%": {
"risk": {
"mean": 9.239707947451976e-05,
"std": 0.0009427144352738658,
"annualized_return": 0.0219905049149357,
"information_ratio": 1.5120514373488407,
"max_drawdown": -0.006530482262119444
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"size_cap 10%": {
"risk": {
"mean": 9.239707947451976e-05,
"std": 0.0009427144352738658,
"annualized_return": 0.0219905049149357,
"information_ratio": 1.5120514373488407,
"max_drawdown": -0.006530482262119444
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"size_cap 15%": {
"risk": {
"mean": 9.239707947451976e-05,
"std": 0.0009427144352738658,
"annualized_return": 0.0219905049149357,
"information_ratio": 1.5120514373488407,
"max_drawdown": -0.006530482262119444
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"size_cap 20%": {
"risk": {
"mean": 9.239707947451976e-05,
"std": 0.0009427144352738658,
"annualized_return": 0.0219905049149357,
"information_ratio": 1.5120514373488407,
"max_drawdown": -0.006530482262119444
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"conc 20%": {
"risk": {
"mean": 0.00011464156491316718,
"std": 0.0011683839517000441,
"annualized_return": 0.027284692449333788,
"information_ratio": 1.5137180903503433,
"max_drawdown": -0.008103887185240407
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"conc 30%": {
"risk": {
"mean": 0.00011464156491316718,
"std": 0.0011683839517000441,
"annualized_return": 0.027284692449333788,
"information_ratio": 1.5137180903503433,
"max_drawdown": -0.008103887185240407
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"conc 40%": {
"risk": {
"mean": 0.00011464156491316718,
"std": 0.0011683839517000441,
"annualized_return": 0.027284692449333788,
"information_ratio": 1.5137180903503433,
"max_drawdown": -0.008103887185240407
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"conc 50%": {
"risk": {
"mean": 0.00011464156491316718,
"std": 0.0011683839517000441,
"annualized_return": 0.027284692449333788,
"information_ratio": 1.5137180903503433,
"max_drawdown": -0.008103887185240407
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"liquidity $1,000,000": {
"risk": {
"mean": 9.086210454881382e-05,
"std": 0.0009290831160004576,
"annualized_return": 0.021625180882617688,
"information_ratio": 1.508747982736451,
"max_drawdown": -0.006376134679664126
},
"applied": {
"dropped_liquidity": [
"ESPO"
]
}
},
"liquidity $2,500,000": {
"risk": {
"mean": 7.142665167642606e-05,
"std": 0.0009184775632266332,
"annualized_return": 0.016999543098989402,
"information_ratio": 1.1997208834083914,
"max_drawdown": -0.0071582979845040825
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"REM",
"XAR"
]
}
},
"liquidity $5,000,000": {
"risk": {
"mean": 9.239707947451976e-05,
"std": 0.0009427144352738658,
"annualized_return": 0.0219905049149357,
"information_ratio": 1.5120514373488407,
"max_drawdown": -0.006530482262119444
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"REM",
"TAN",
"UNG",
"XAR"
]
}
},
"liquidity $10,000,000": {
"risk": {
"mean": 9.438545151345752e-05,
"std": 0.0009420158170657147,
"annualized_return": 0.02246373746020289,
"information_ratio": 1.5457360696934006,
"max_drawdown": -0.006388809561209335
},
"applied": {
"dropped_liquidity": [
"DBA",
"DBC",
"ESPO",
"FDN",
"ICLN",
"ITA",
"MDY",
"REM",
"SHY",
"TAN",
"UNG",
"XAR"
]
}
}
},
"candidate": {
"liquidity_floor_adv": 5000000.0,
"size_cap_pct": 0.12,
"concentration_cap_pct": 0.95,
"drawdown_pause_pct": 0.1
}
}
+34
View File
@@ -0,0 +1,34 @@
# QUEUE-08 — Risk-limit A/B re-validation: $5M liquidity floor on the exp-26 reference
**Status:** QUEUED · **Priority:** P1 · **Effort:** tool-only (no new code)
## Hypothesis (prove)
The $5M liquidity floor improves net IR and cuts drawdown on the **post-reset**
reference signal (pre-reset exp 18, EVIDENCE#008: net IR 0.81→0.98, cumDD
7.93%→5.44%), while size/concentration caps hurt by cutting deployed capital.
Needs re-validation on the exp-26 lineage because exp 18 is pre-clean-lake and
not comparable (EVIDENCE#009/010). Source: `book/CLAIMS.md` open question +
`book/README.md` `TODO(evidence-needed: reconciliation of exp 18 risk-limit spec
on the post-reset reference signal)`.
## Change vs exp-26 reference (ONE variable)
- Reference: the saved exp-26 prediction (run `21afc6af…`, mlflow exp 25).
- A/B via `rd_risk_calibrate` (runs limit-vs-no-limit A/B + sensitivity grid
over size_cap_pct, concentration_cap_pct, liquidity_floor_adv) and/or
`rd_backtest` with `risk_limits` on the SAME saved `pred.pkl`:
- baseline: no limits (this must reproduce the exp-26 net +2.13% / IR 0.21);
- candidate: `{"liquidity_floor_adv": 5000000, "size_cap_pct": 0.12,
"concentration_cap_pct": 0.95, "drawdown_pause_pct": 0.10}` (round-3 spec).
- Pick the spec (B2 calibration) that keeps live ≈ backtest.
## Acceptance
- Candidate spec: `net_IR > 0.21` AND `net_max_drawdown < 7.69%` vs no-limit on
the same pred. Size/concentration caps expected to REDUCE deployed capital
(record the direction as confirmation of exp 18).
- If the floor is a no-op (gates don't bind at this signal) → report that gates
are no-ops when the signal is the bottleneck (exp 20 pattern) as a PROVEN
clean-lake result.
## Execution prerequisites
- None (uses saved pred + `rd_risk_calibrate`/`rd_backtest`). Trace the A/B as
an experiment; record the spec chosen for the next live round.
@@ -0,0 +1,133 @@
# -----------------------------------------------------------------------------
# ABLATION A (baseline): LightGBM with RankIC early-stopping on the 50-ETF SP-5d
# panel, using ALL 24 sp_* feature columns (ou,hmm,jump,har,trend,hurst,
# signature). Copy of the canonical workflow_lgb_sp5d_rankic.yaml with a
# distinct experiment name so the ablation runs are isolated.
#
# Run:
# rd_run_workflow config_path=tac-qlib/workflows/ablate_baseline_all_sp_fields.yaml \
# experiment_name=tac-rd-rank-ablate
# -----------------------------------------------------------------------------
{%- 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 SP_FIELDS = "sp_ret,sp_ou_zscore,sp_ou_half_life,sp_ou_revert,sp_hmm_p_regime1,sp_hmm_state,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:///{{ LAKE }}/mlruns.db"
default_exp_name: "tac-rd-rank-ablate"
task:
model:
class: RankICLGBModel
module_path: tac_qlib.contrib.model.rank_gbdt
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
seed: 42
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: 2015-01-03
fit_end_time: 2025-09-01
freq: day
lake_root: "{{ LAKE }}"
market: US
label: "Ref($close,-6)/Ref($close,-1)-1"
feature_fields: "$open,$high,$low,$close,$vwap,$volume,{{ SP_FIELDS }}"
infer_processors:
- class: DropAllNaN
kwargs: {}
- class: ProcessInf
kwargs: {}
- class: CSRankNorm
kwargs: {}
- class: ZScoreNorm
kwargs: {}
- class: Fillna
kwargs: {}
segments:
train: [2015-01-03, 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: 2
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,25 +1,17 @@
# QUEUE-ly # -----------------------------------------------------------------------------
# Weekly rebalance (Q07): TopkDropout recomputed once per ISO week, hold otherwise (turnover relief). # ABLATION B (generic-only): same panel/model as the baseline, but feature
# Acceptance: total_cost/turnover strictly below reference AND net_IR > 0.21 AND net_ann > +2.13%. # fields restricted to the model-free / generic stochastic-process families
# (jump,har,trend,hurst,signature). Drops the model-specific ou (OU/AR-1
# half-life) and hmm (2-state regime) families to test whether the generic
# families alone dominate the rank dimension.
#
# Run:
# rd_run_workflow config_path=tac-qlib/workflows/ablate_generic_only_sp_fields.yaml \
# experiment_name=tac-rd-rank-ablate
# -----------------------------------------------------------------------------
{%- set LAKE = TAC_LAKE_DIR %} {%- 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 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" %} {%- set SP_FIELDS = "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: qlib_init:
provider_uri: "{{ LAKE }}" provider_uri: "{{ LAKE }}"
@@ -49,12 +41,12 @@ qlib_init:
module_path: qlib.workflow.expm module_path: qlib.workflow.expm
kwargs: kwargs:
uri: "sqlite:///{{ LAKE }}/mlruns.db" uri: "sqlite:///{{ LAKE }}/mlruns.db"
default_exp_name: "tac-rd-q07-weekly" default_exp_name: "tac-rd-rank-ablate"
task: task:
model: model:
class: RankICEnsembleLGBModel class: RankICLGBModel
module_path: tac_qlib.contrib.model.rank_ensemble module_path: tac_qlib.contrib.model.rank_gbdt
kwargs: kwargs:
loss: mse loss: mse
learning_rate: 0.02 learning_rate: 0.02
@@ -69,8 +61,7 @@ task:
subsample_freq: 1 subsample_freq: 1
reg_alpha: 0.1 reg_alpha: 0.1
reg_lambda: 1.0 reg_lambda: 1.0
seeds: "42,7,2026,99,123" seed: 42
parallel: 5
dataset: dataset:
class: DatasetH class: DatasetH
@@ -83,13 +74,13 @@ task:
instruments: "{{ UNIVERSE }}" instruments: "{{ UNIVERSE }}"
start_time: 2015-01-03 start_time: 2015-01-03
end_time: 2026-08-10 end_time: 2026-08-10
fit_start_time: 2016-01-04 fit_start_time: 2015-01-03
fit_end_time: 2025-09-01 fit_end_time: 2025-09-01
freq: day freq: day
lake_root: "{{ LAKE }}" lake_root: "{{ LAKE }}"
market: US market: US
label: "Ref($close,-6)/Ref($close,-1)-1" label: "Ref($close,-6)/Ref($close,-1)-1"
feature_fields: "{{ FEATURES }}" feature_fields: "$open,$high,$low,$close,$vwap,$volume,{{ SP_FIELDS }}"
infer_processors: infer_processors:
- class: DropAllNaN - class: DropAllNaN
kwargs: {} kwargs: {}
@@ -102,7 +93,7 @@ task:
- class: Fillna - class: Fillna
kwargs: {} kwargs: {}
segments: segments:
train: [2016-01-04, 2025-09-01] train: [2015-01-03, 2025-09-01]
valid: [2025-09-03, 2026-01-03] valid: [2025-09-03, 2026-01-03]
test: [2026-01-04, 2026-08-10] test: [2026-01-04, 2026-08-10]
@@ -120,12 +111,12 @@ task:
kwargs: kwargs:
config: config:
strategy: strategy:
class: WeeklyRebalanceDropoutStrategy class: TopkDropoutStrategy
module_path: tac_qlib.contrib.strategy.weekly_rebalance module_path: qlib.contrib.strategy
kwargs: kwargs:
signal: "<PRED>" signal: "<PRED>"
topk: 10 topk: 10
n_drop: 1 n_drop: 2
only_tradable: true only_tradable: true
risk_degree: 0.95 risk_degree: 0.95
backtest: backtest:
@@ -140,4 +131,4 @@ task:
open_cost: 0.0005 open_cost: 0.0005
close_cost: 0.0015 close_cost: 0.0015
min_cost: 5.0 min_cost: 5.0
risk_analysis_freq: 1d risk_analysis_freq: 1d
+141
View File
@@ -0,0 +1,141 @@
# -----------------------------------------------------------------------------
# ISOLATION: multi-seed RankIC ensemble, ablate-B generic-only feature set.
#
# Isolates the ensemble effect on the SP-5d rank signal. Same panel, segments,
# history (full backfilled 2016+) and feature set as the exp-9 ablate-B winner
# (generic-only sp_* families: jump,har,trend,hurst,signature), but replaces the
# single RankICLGBModel with a 5-seed RankICEnsembleLGBModel (42,7,2026,99,123)
# that averages per-day predictions.
#
# Differs from exp-15 (tac-rd-rank-ensemble, mlflow exp 15) ONLY by dropping the
# TA subset (rsi_14,roc_10,macd_hist,willr_14,atr_14) and the inter-asset xr_*
# features, so any change vs exp-15 is attributable to the feature set alone,
# and any change vs exp-9 is attributable to the ensemble + full history alone.
#
# Run:
# rd_run_workflow config_path=experiments/workflows/exp12_isolation_ensemble.yaml \
# experiment_name=tac-rd-rank-ensemble-isolated
# -----------------------------------------------------------------------------
{%- 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 SP_FIELDS = "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-rank-ensemble-isolated"
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-14
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: "$open,$high,$low,$close,$vwap,$volume,{{ SP_FIELDS }}"
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: 2
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,22 +1,23 @@
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# QUEUE-03 — topk 20 vs 10 diversification on the compact reference. # EXP 18 - Risk-limit control: reference model + TopkDropout baseline (A).
# #
# Hypothesis (book ch.05/chat-ideas): the effective independent names in the # Signal/model identical to the reference (tac-rd-rank-ensemble-isolated,
# 50-ETF book is small (~4, chat-derived eigenvalue analysis); raising topk # run 0cea66d9...): RankICEnsembleLGBModel (parallel, 5 seeds) on the 50-ETF
# diversifies the book and should cut drawdown / raise net IR without hurting # SP-5d panel, test 2026-01-04..2026-08-10. This workflow reproduces the
# the (weak) rank signal — cost relief by spreading the book wider. # unconstrained TopkDropout baseline net-of-cost so the risk-limited variant
# (same pred, liquidity/size/concentration caps) can be compared 1:1.
# #
# Change vs exp-26 reference: ONE variable — strategy topk 10 -> 20 (n_drop 1). # The risk_limits spec itself is applied via rd_backtest / rd_strategy_targets
# Everything else identical. # (tool-level param, not a YAML key); this run records the unconstrained
# baseline that the limit A/B is measured against.
# #
# Acceptance: net_IR > 0.21 AND net_max_drawdown < 7.69% AND net_ann_return >= # Run:
# +2.13%; watch total_cost — more names held must not raise turnover/cost. # rd_run_workflow config_path=experiments/workflows/exp18-risk-limit/a_baseline.yaml \
# Run: rd_run_workflow config_path=<repo>/experiments/queue/workflows/q03_topk20.yaml \ # experiment_name=tac-rd-risk-limit
# experiment_name=tac-rd-q03-topk20
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
{%- set LAKE = TAC_LAKE_DIR %} {%- 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 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" %} {%- set SP_FIELDS = "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: qlib_init:
provider_uri: "{{ LAKE }}" provider_uri: "{{ LAKE }}"
@@ -46,7 +47,7 @@ qlib_init:
module_path: qlib.workflow.expm module_path: qlib.workflow.expm
kwargs: kwargs:
uri: "sqlite:///{{ LAKE }}/mlruns.db" uri: "sqlite:///{{ LAKE }}/mlruns.db"
default_exp_name: "tac-rd-q03-topk20" default_exp_name: "tac-rd-risk-limit"
task: task:
model: model:
@@ -79,14 +80,14 @@ task:
kwargs: kwargs:
instruments: "{{ UNIVERSE }}" instruments: "{{ UNIVERSE }}"
start_time: 2015-01-03 start_time: 2015-01-03
end_time: 2026-08-10 end_time: 2026-08-14
fit_start_time: 2016-01-04 fit_start_time: 2016-01-04
fit_end_time: 2025-09-01 fit_end_time: 2025-09-01
freq: day freq: day
lake_root: "{{ LAKE }}" lake_root: "{{ LAKE }}"
market: US market: US
label: "Ref($close,-6)/Ref($close,-1)-1" label: "Ref($close,-6)/Ref($close,-1)-1"
feature_fields: "{{ FEATURES }}" feature_fields: "$open,$high,$low,$close,$vwap,$volume,{{ SP_FIELDS }}"
infer_processors: infer_processors:
- class: DropAllNaN - class: DropAllNaN
kwargs: {} kwargs: {}
@@ -121,8 +122,8 @@ task:
module_path: qlib.contrib.strategy module_path: qlib.contrib.strategy
kwargs: kwargs:
signal: "<PRED>" signal: "<PRED>"
topk: 20 topk: 10
n_drop: 1 n_drop: 2
only_tradable: true only_tradable: true
risk_degree: 0.95 risk_degree: 0.95
backtest: backtest:
@@ -137,4 +138,4 @@ task:
open_cost: 0.0005 open_cost: 0.0005
close_cost: 0.0015 close_cost: 0.0015
min_cost: 5.0 min_cost: 5.0
risk_analysis_freq: 1d risk_analysis_freq: 1d