feat: train forecasts on trade outcomes
This commit is contained in:
@@ -379,11 +379,19 @@ def _safe_parameters(value: Any) -> dict[str, Any]:
|
||||
"layers",
|
||||
"dropouts",
|
||||
"epochs",
|
||||
"validation_window",
|
||||
"holdout_window",
|
||||
"ensemble_seeds",
|
||||
"selection_folds",
|
||||
"learning_rate",
|
||||
"weight_decay",
|
||||
"horizon",
|
||||
"horizons",
|
||||
"patience",
|
||||
"context_symbols",
|
||||
"features",
|
||||
"seed",
|
||||
"interval",
|
||||
"pooled",
|
||||
"resume_candidate",
|
||||
}
|
||||
@@ -391,8 +399,12 @@ def _safe_parameters(value: Any) -> dict[str, Any]:
|
||||
for key, low, high in (
|
||||
("limit", 500, 20000),
|
||||
("epochs", 1, 200),
|
||||
("validation_window", 64, 2000),
|
||||
("holdout_window", 64, 1000),
|
||||
("selection_folds", 1, 12),
|
||||
("horizon", 1, 96),
|
||||
("patience", 1, 50),
|
||||
("seed", 1, 2_147_483_647),
|
||||
):
|
||||
if key not in result:
|
||||
continue
|
||||
@@ -414,9 +426,19 @@ def _safe_parameters(value: Any) -> dict[str, Any]:
|
||||
if item.strip().lower() in {"lstm", "gru"}
|
||||
]
|
||||
result["architectures"] = ",".join(architectures) or "lstm,gru"
|
||||
for key in ("lookbacks", "hidden_sizes", "layers", "dropouts", "ensemble_seeds"):
|
||||
for key in (
|
||||
"lookbacks",
|
||||
"hidden_sizes",
|
||||
"layers",
|
||||
"dropouts",
|
||||
"ensemble_seeds",
|
||||
"horizons",
|
||||
"context_symbols",
|
||||
"features",
|
||||
"interval",
|
||||
):
|
||||
if key in result:
|
||||
result[key] = str(result[key])[:200]
|
||||
result[key] = str(result[key])[: 4000 if key == "features" else 500]
|
||||
for key, low, high in (
|
||||
("learning_rate", 0.00001, 0.1),
|
||||
("weight_decay", 0.0, 0.1),
|
||||
@@ -471,10 +493,27 @@ def _validate_symbol_models(symbols: dict[str, Any]) -> None:
|
||||
raise ValueError(f"candidate model dimensions are invalid: {symbol}") from exc
|
||||
if not 4 <= lookback <= 512 or not 1 <= input_size <= 256 or not 1 <= hidden_size <= 1024:
|
||||
raise ValueError(f"candidate model dimensions are out of range: {symbol}")
|
||||
if not isinstance(entry.get("state_dict"), dict):
|
||||
raise ValueError(f"candidate recurrent state is missing: {symbol}")
|
||||
if not isinstance(entry.get("head_weight"), list) or not isinstance(entry.get("head_bias"), list):
|
||||
raise ValueError(f"candidate forecast head is missing: {symbol}")
|
||||
members = entry.get("ensemble_members")
|
||||
payloads = members if isinstance(members, list) and members else [entry]
|
||||
for payload in payloads:
|
||||
if not isinstance(payload, dict) or not isinstance(payload.get("state_dict"), dict):
|
||||
raise ValueError(f"candidate recurrent state is missing: {symbol}")
|
||||
merged = {**entry, **payload}
|
||||
if merged.get("multitask_head") is True:
|
||||
required = (
|
||||
"head_hidden_weight",
|
||||
"head_hidden_bias",
|
||||
"return_head_weight",
|
||||
"return_head_bias",
|
||||
"event_head_weight",
|
||||
"event_head_bias",
|
||||
)
|
||||
if any(not isinstance(merged.get(name), list) for name in required):
|
||||
raise ValueError(f"candidate multitask forecast head is missing: {symbol}")
|
||||
elif not isinstance(merged.get("head_weight"), list) or not isinstance(
|
||||
merged.get("head_bias"), list
|
||||
):
|
||||
raise ValueError(f"candidate forecast head is missing: {symbol}")
|
||||
|
||||
|
||||
def _compact_now() -> str:
|
||||
|
||||
Reference in New Issue
Block a user