feat: Add comprehensive risk metrics to simulation results - #188
Merged
Conversation
- Add RiskMetrics dataclass and compute_risk_metrics() in src/simulation/risk_metrics.py computing 11 metrics: Sharpe, Sortino, max drawdown, drawdown duration, Calmar, win rate, profit factor, avg win/loss ratio, annualised volatility, VaR (95%), beta - Update TradingSimulator.simulate() to call compute_risk_metrics() and return results under the 'risk_metrics' key - Export RiskMetrics and compute_risk_metrics from src/simulation/__init__.py - Add tests/simulation/test_risk_metrics.py with 32 tests covering all metrics Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/481852c7-cde7-4c10-a0da-0dc8ac3e165a Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add comprehensive risk metrics to simulation results
feat: Add comprehensive risk metrics to simulation results
Apr 19, 2026
ch55secake
marked this pull request as ready for review
April 20, 2026 09:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The simulation returned only basic metrics (final value, return, buy-and-hold, trade count), insufficient to evaluate risk-adjusted strategy quality. This adds 11 standard risk metrics computed from the portfolio history and trade log.
Changes in this pull request
New:
src/simulation/risk_metrics.pyRiskMetricsdataclass with 11 fields; any field isNonewhen there's insufficient datacompute_risk_metrics(portfolio_history, trades, total_return)computing:pnl_pctper tradeModified:
src/simulation/trading_simulator.pysimulate()callscompute_risk_metrics()at the end; result exposed under"risk_metrics"keyModified:
src/simulation/__init__.pyRiskMetricsandcompute_risk_metricsNew:
tests/simulation/test_risk_metrics.pyNone), known-value assertions, sign checks, and integration tests onsimulate()output