You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reimplement the per-run BacktestMetrics and cross-window BacktestSummaryMetrics calculations in Rust, exposed as PyO3 functions. Achieve numerical parity with the existing Python implementation (within agreed float tolerance) and benchmark the speedup.
Tasks
Catalog every metric currently produced (sources of truth: investing_algorithm_framework/services/metrics/ and docusaurus/docs/Getting Started/metrics.md). Group by domain: returns, risk-adjusted, drawdown, per-trade, win/loss, exposure, multi-window robustness.
Define Rust-side input types: PortfolioSnapshot, Trade, RiskFreeRate. Use polars Series / ndarray for timeseries inputs to enable zero-copy conversion from numpy / pandas.
Implement summary aggregator: stability score, consistency score, number of profitable windows, cross-window roll-ups.
Optional metrics: List[str] filter parity with Python.
PyO3 functions: compute_backtest_metrics(snapshots, trades, risk_free_rate, metrics) -> dict and compute_backtest_summary(per_run_metrics) -> dict. Return plain dicts so the Python layer can populate the existing dataclasses unchanged.
Parity test suite: for every backtest fixture under tests/resources/, assert Rust output equals Python output within rtol=1e-9 on counts and rtol=1e-6, atol=1e-12 on float metrics. Document any unavoidable divergence (e.g. parallel reduction order) with a tighter tolerance.
Property-based tests with hypothesis on the Python wrapper, comparing pure-Python vs native paths.
pytest-benchmark comparison: pure-Python vs native on a 100-window summary. Target ≥ 20× speedup.
Acceptance criteria
All existing metric tests pass with IAF_NATIVE=1 and IAF_NATIVE=0.
New parity test suite green.
Benchmark report committed to the repo (markdown + JSON).
No public Python API change.
Dependencies
Phase 1 (crate scaffold) must be merged.
Part of the Epic: hybrid Python + Rust acceleration.
Goal
Reimplement the per-run
BacktestMetricsand cross-windowBacktestSummaryMetricscalculations in Rust, exposed as PyO3 functions. Achieve numerical parity with the existing Python implementation (within agreed float tolerance) and benchmark the speedup.Tasks
investing_algorithm_framework/services/metrics/anddocusaurus/docs/Getting Started/metrics.md). Group by domain: returns, risk-adjusted, drawdown, per-trade, win/loss, exposure, multi-window robustness.PortfolioSnapshot,Trade,RiskFreeRate. UsepolarsSeries /ndarrayfor timeseries inputs to enable zero-copy conversion from numpy / pandas.metrics: List[str]filter parity with Python.compute_backtest_metrics(snapshots, trades, risk_free_rate, metrics) -> dictandcompute_backtest_summary(per_run_metrics) -> dict. Return plain dicts so the Python layer can populate the existing dataclasses unchanged.tests/resources/, assert Rust output equals Python output withinrtol=1e-9on counts andrtol=1e-6, atol=1e-12on float metrics. Document any unavoidable divergence (e.g. parallel reduction order) with a tighter tolerance.hypothesison the Python wrapper, comparing pure-Python vs native paths.pytest-benchmarkcomparison: pure-Python vs native on a 100-window summary. Target ≥ 20× speedup.Acceptance criteria
IAF_NATIVE=1andIAF_NATIVE=0.Dependencies
Part of the Epic: hybrid Python + Rust acceleration.