86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
|
|
"""
|
||
|
|
Monte Carlo System Envelope Mapping for DOLPHIN NG
|
||
|
|
==================================================
|
||
|
|
|
||
|
|
Full-system operational envelope simulation and ML forewarning integration.
|
||
|
|
|
||
|
|
This package implements the Monte Carlo System Envelope Specification for
|
||
|
|
the Nautilus-Dolphin trading system. It provides:
|
||
|
|
|
||
|
|
1. Parameter space sampling (Latin Hypercube Sampling)
|
||
|
|
2. Internal consistency validation (V1-V4 constraint groups)
|
||
|
|
3. Trial execution harness (backtest runner)
|
||
|
|
4. Metric extraction (48 metrics, 10 classification labels)
|
||
|
|
5. Result persistence (Parquet + SQLite index)
|
||
|
|
6. ML envelope learning (One-Class SVM, XGBoost)
|
||
|
|
7. Live forewarning API (risk assessment for configurations)
|
||
|
|
|
||
|
|
Usage:
|
||
|
|
from nautilus_dolphin.mc import MCSampler, MCValidator, MCExecutor
|
||
|
|
|
||
|
|
# Run envelope testing
|
||
|
|
python run_mc_envelope.py --mode run --stage 1 --n-samples 500
|
||
|
|
|
||
|
|
# Train ML models on results
|
||
|
|
python run_mc_envelope.py --mode train --output-dir mc_results/
|
||
|
|
|
||
|
|
# Assess a live configuration
|
||
|
|
python run_mc_envelope.py --mode assess --assess my_config.json
|
||
|
|
|
||
|
|
Reference:
|
||
|
|
MONTE_CARLO_SYSTEM_ENVELOPE_SPEC.md - Complete specification document
|
||
|
|
"""
|
||
|
|
|
||
|
|
__version__ = "1.0.0"
|
||
|
|
__author__ = "DOLPHIN NG Team"
|
||
|
|
|
||
|
|
# Core modules (lazy import to avoid heavy dependencies on import)
|
||
|
|
def __getattr__(name):
|
||
|
|
if name == "MCSampler":
|
||
|
|
from .mc_sampler import MCSampler
|
||
|
|
return MCSampler
|
||
|
|
elif name == "MCValidator":
|
||
|
|
from .mc_validator import MCValidator
|
||
|
|
return MCValidator
|
||
|
|
elif name == "MCExecutor":
|
||
|
|
from .mc_executor import MCExecutor
|
||
|
|
return MCExecutor
|
||
|
|
elif name == "MCMetrics":
|
||
|
|
from .mc_metrics import MCMetrics
|
||
|
|
return MCMetrics
|
||
|
|
elif name == "MCStore":
|
||
|
|
from .mc_store import MCStore
|
||
|
|
return MCStore
|
||
|
|
elif name == "MCRunner":
|
||
|
|
from .mc_runner import MCRunner
|
||
|
|
return MCRunner
|
||
|
|
elif name == "MCML":
|
||
|
|
from .mc_ml import MCML
|
||
|
|
return MCML
|
||
|
|
elif name == "DolphinForewarner":
|
||
|
|
from .mc_ml import DolphinForewarner
|
||
|
|
return DolphinForewarner
|
||
|
|
elif name == "MCTrialConfig":
|
||
|
|
from .mc_sampler import MCTrialConfig
|
||
|
|
return MCTrialConfig
|
||
|
|
elif name == "MCTrialResult":
|
||
|
|
from .mc_metrics import MCTrialResult
|
||
|
|
return MCTrialResult
|
||
|
|
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
||
|
|
|
||
|
|
__all__ = [
|
||
|
|
# Core classes
|
||
|
|
"MCSampler",
|
||
|
|
"MCValidator",
|
||
|
|
"MCExecutor",
|
||
|
|
"MCMetrics",
|
||
|
|
"MCStore",
|
||
|
|
"MCRunner",
|
||
|
|
"MCML",
|
||
|
|
"DolphinForewarner",
|
||
|
|
"MCTrialConfig",
|
||
|
|
"MCTrialResult",
|
||
|
|
# Version
|
||
|
|
"__version__",
|
||
|
|
]
|