feat: 15% monthly return target — infrastructure + daily signal resampling

Phase 1 — Infrastructure:
- RiskMgmt_RISK_PER_TRADE 0.5% → 1.5% (vbt_backtest.py)
- min_monthly_return_pct=15% acceptance filter (strategy_orchestrator)
- --min-monthly-return 15 CLI option (nexquant.py)
- {{ min_monthly_return }}% in strategy prompts
- MIN_MONTHLY_RETURN_PCT=15.0 in gen_strategies_real_bt + smart_strategy_gen
- realistic_backtest_all.py target_monthly 4→15%

Phase 2 — Factor quality:
- IC thresholds: prompt 0.05→0.08, bandit IC weight 0.10→0.20
- Explicite IC > 0.04 target in RAG prompt
- min_ic filters: data_loader 0.0→0.04, strategy_worker 0.02→0.04, ml_trainer 0.01→0.04

Architecture fix — Daily signal resampling:
- Factors have IC at daily resolution, but z-scores on 1-min collapse IC to ~0
- Resample factors to daily before strategy exec, ffill signal to 1-min for backtest
- Walk-forward IS years 3→1 (only 2 years of data available)
- Removed broken intersection() logic that destroyed 99.99% of 1-min data
- ffill stale propagation limited to 2880 bars (2 trading days)
- Fixed logger crash in _load_strategies
- Preflight: removed constant-signal check (false positive on random sandbox data)
- Tests: test_daily_signal_resampling.py (8 tests)

Non-negotiable rules: R1-R10 in AGENTS.md
This commit is contained in:
TPTBusiness
2026-05-16 19:06:09 +02:00
parent 847a30a787
commit e0000a18d2
10 changed files with 633 additions and 481 deletions
@@ -42,8 +42,8 @@ EXTREME_BAR_THRESHOLD = 0.05 # |ret| > 5% on a single 1-min bar → suspicious
FTMO_INITIAL_CAPITAL = 100_000.0
FTMO_MAX_DAILY_LOSS = 0.05 # 5% of initial → block new trades rest of day
FTMO_MAX_TOTAL_LOSS = 0.10 # 10% of initial → simulation ends
# Risk-based position sizing: 0.5% equity risk per trade, 10-pip stop, max 1:30 leverage
FTMO_RISK_PER_TRADE = 0.005
# Risk-based position sizing: 1.5% equity risk per trade, 10-pip stop, max 1:30 leverage
FTMO_RISK_PER_TRADE = 0.015
FTMO_STOP_PIPS = 10
FTMO_PIP = 0.0001
FTMO_MAX_LEVERAGE = 30
@@ -343,7 +343,7 @@ def _apply_ftmo_mask(
OOS_START_DEFAULT = "2024-01-01"
# Rolling walk-forward default windows (IS years, OOS years, step years)
WF_IS_YEARS = 3
WF_IS_YEARS = 1
WF_OOS_YEARS = 1
WF_STEP_YEARS = 1
@@ -387,6 +387,10 @@ class QlibFactorRunner(CachedRunner[QlibFactorExperiment]):
warnings.append(
f"IC is near zero ({ic_float:.6f}) — factor may not predict returns",
)
if abs(ic_float) < 0.04:
warnings.append(
f"IC below target ({ic_float:.4f}) — factor will be excluded from strategy building (min IC=0.04)",
)
except (ValueError, TypeError):
warnings.append(f"IC value is not numeric: {ic_value}")
+1 -1
View File
@@ -94,7 +94,7 @@ class LinearThompsonTwoArm:
class EnvController:
def __init__(self, weights: Tuple[float, ...] = None) -> None:
self.weights = np.asarray(weights or (0.1, 0.1, 0.05, 0.05, 0.25, 0.15, 0.1, 0.2))
self.weights = np.asarray(weights or (0.2, 0.1, 0.05, 0.05, 0.25, 0.1, 0.1, 0.15))
self.bandit = LinearThompsonTwoArm(dim=8, prior_var=10.0, noise_var=0.5)
def reward(self, m: Metrics) -> float:
@@ -108,7 +108,7 @@ class QlibQuantHypothesisGen(FactorAndModelHypothesisGen):
if len(trace.hist) < 6:
qaunt_rag = "Try the easiest and fastest factors to experiment with from various perspectives first."
else:
qaunt_rag = "Now, you need to try factors that can achieve high IC (e.g., machine learning-based factors)! Do not include factors that are similar to those in the SOTA factor library!"
qaunt_rag = "Now, you need to try factors that can achieve high IC (target |IC| > 0.04, e.g., machine learning-based factors)! Do not include factors that are similar to those in the SOTA factor library!"
elif action == "model":
qaunt_rag = "1. In Quantitative Finance, market data could be time-series, and GRU model/LSTM model are suitable for them. Do not generate GNN model as for now.\n2. The training data consists of approximately 478,000 samples for the training set and about 128,000 samples for the validation set. Please design the hyperparameters accordingly and control the model size. This has a significant impact on the training results. If you believe that the previous model itself is good but the training hyperparameters or model hyperparameters are not optimal, you can return the same model and adjust these parameters instead.\n"