f42fec9fac
Nuova strategia MT01: squeeze 15m + momentum EMA 1h BTC 15m: 82.7% acc, 503 trades, DD 5.9%, 9/9 anni, worst 72% ETH 15m: 81.2% acc, 404 trades, DD 2.9%, 9/9 anni, worst 73% Strategie testate e scartate (waste W23-W28): IB01 inside bar (58.7%, no edge) DC01 donchian (48%, sotto random) SB01 retest (52%, no edge) MR01 mean reversion RSI (62.9%, DD 29%) VO01 volume spike (64.2%, DD 34%) HY01 squeeze+MR (64.6%, DD 14.5%) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""Import dinamico delle classi Strategy da scripts/strategies/."""
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from src.strategies.base import Strategy
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
|
STRATEGIES_DIR = PROJECT_ROOT / "scripts" / "strategies"
|
|
|
|
_REGISTRY: dict[str, type[Strategy]] = {}
|
|
|
|
MODULE_MAP = {
|
|
"SQ01_squeeze_base": ("SQ01_squeeze_base", "SqueezeBase"),
|
|
"SQ02_antifake_vol": ("SQ02_squeeze_antifake_vol", "SqueezeAntifakeVol"),
|
|
"SQ03_filtered": ("SQ03_squeeze_all_filters", "SqueezeFiltered"),
|
|
"SQ04_ultimate": ("SQ04_squeeze_ultimate", "SqueezeUltimate"),
|
|
"ML01_squeeze_gbm": ("ML01_squeeze_gbm", "SqueezeGBM"),
|
|
"MT01_squeeze_mtf": ("MT01_squeeze_mtf_momentum", "SqueezeMTFMomentum"),
|
|
}
|
|
|
|
|
|
def load_strategy(name: str) -> Strategy:
|
|
"""Carica e istanzia una Strategy per nome."""
|
|
if name in _REGISTRY:
|
|
return _REGISTRY[name]()
|
|
|
|
if name not in MODULE_MAP:
|
|
raise ValueError(f"Strategia sconosciuta: {name}. Disponibili: {list(MODULE_MAP)}")
|
|
|
|
module_file, class_name = MODULE_MAP[name]
|
|
module_path = STRATEGIES_DIR / f"{module_file}.py"
|
|
|
|
if not module_path.exists():
|
|
raise FileNotFoundError(f"File strategia non trovato: {module_path}")
|
|
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
spec = importlib.util.spec_from_file_location(f"strategies.{module_file}", module_path)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
|
|
cls = getattr(module, class_name)
|
|
_REGISTRY[name] = cls
|
|
return cls()
|
|
|
|
|
|
def list_available() -> list[str]:
|
|
return list(MODULE_MAP.keys())
|