start experiment 58 (exp/58-signal-quality-gate-5-year-walk-forward)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Precompute the signal-quality gate series and save to pickle.
|
||||
|
||||
Usage:
|
||||
python precompute_signal_quality_gate.py <pred_path> <output_path> [topk] [lookback] [threshold]
|
||||
|
||||
Example:
|
||||
python precompute_signal_quality_gate.py \
|
||||
/home/data/lake/mlruns/49/34165f27e4a34378ad54843a079a78c0/artifacts/pred.pkl \
|
||||
/app/experiments/book/data/signal_quality_gate/sq_gate_5d_0.50.pkl \
|
||||
10 5 0.5
|
||||
"""
|
||||
import sys
|
||||
import pickle
|
||||
from pathlib import Path
|
||||
|
||||
# Add tac-qlib to path
|
||||
sys.path.insert(0, "/app/tac-qlib")
|
||||
|
||||
from tac_qlib.contrib.strategy.signal_quality_gate import compute_signal_quality_gate
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
print(__doc__)
|
||||
sys.exit(1)
|
||||
|
||||
pred_path = sys.argv[1]
|
||||
output_path = sys.argv[2]
|
||||
topk = int(sys.argv[3]) if len(sys.argv) > 3 else 10
|
||||
lookback = int(sys.argv[4]) if len(sys.argv) > 4 else 5
|
||||
threshold = float(sys.argv[5]) if len(sys.argv) > 5 else 0.5
|
||||
|
||||
lake_root = "/home/data/lake"
|
||||
|
||||
print(f"Computing signal-quality gate: topk={topk}, lookback={lookback}, threshold={threshold}")
|
||||
gate = compute_signal_quality_gate(
|
||||
pred_path,
|
||||
lake_root=lake_root,
|
||||
topk=topk,
|
||||
lookback=lookback,
|
||||
threshold=threshold,
|
||||
)
|
||||
|
||||
print(f"Gate: {gate.sum()}/{len(gate)} days open ({gate.mean():.1%})")
|
||||
|
||||
with open(output_path, "wb") as f:
|
||||
pickle.dump(gate, f)
|
||||
print(f"Saved to {output_path}")
|
||||
Reference in New Issue
Block a user