Coverage for src / monte_neo / monte_carlo / types.py: 100%

38 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-28 16:27 +0200

1"""Types for Monte Carlo simulations.""" 

2 

3from __future__ import annotations 

4 

5from dataclasses import dataclass, field 

6from typing import TYPE_CHECKING 

7 

8if TYPE_CHECKING: 

9 pass 

10 

11 

12@dataclass 

13class MCConfig: 

14 """Monte Carlo configuration.""" 

15 

16 iterations: int = 10000 

17 use_shuffling: bool = True 

18 use_noise: bool = True 

19 use_sensitivity: bool = True 

20 use_walk_forward: bool = True 

21 use_block_bootstrap: bool = True 

22 use_sequential: bool = False 

23 sensitivity_range: float = 0.10 # ±10% 

24 walk_forward_splits: int = 5 

25 n_workers: int | None = None 

26 random_seed: int | None = None 

27 

28 # Risk Management 

29 use_sl_tp: bool = False 

30 sl_pct: float = 0.0 

31 tp_pct: float = 0.0 

32 

33 # Validation 

34 pass_threshold: float = 0.95 # 95% threshold by default 

35 

36 # Hardware Acceleration 

37 use_gpu: bool = True 

38 gpu_precision: str = "float32" # float32, float16, float8 

39 metal_driver: str = "cpp" # cpp, objc, swift 

40 

41 # Capital and Leverage 

42 initial_capital: float = 100000.0 

43 leverage: float = 1.0 

44 

45 

46@dataclass 

47class MCStepResult: 

48 """Result of a single Monte Carlo step.""" 

49 

50 method_name: str 

51 passed: bool 

52 pass_rate: float 

53 metrics_summary: dict 

54 advice: str 

55 iterations: int = 0 

56 

57 

58@dataclass 

59class MCResult: 

60 """Monte Carlo simulation result.""" 

61 

62 passed: bool 

63 pass_rate: float 

64 iterations_run: int 

65 elapsed_time: float 

66 metrics_summary: dict = field(default_factory=dict) 

67 detailed_results: list = field(default_factory=list) 

68 step_results: list[MCStepResult] = field(default_factory=list) 

69 timing_stats: dict[str, float] = field(default_factory=dict)