Skip to main content
The backtesting engine provides comprehensive performance metrics and statistics to evaluate strategy quality.

BacktestMetrics

The primary metrics structure is defined in nano-backtest/src/metrics.rs:10-52.

Core Metrics

Accessing Metrics

From engine.rs:325-329:

Key Performance Indicators

Win Rate

Percentage of profitable trades (metrics.rs:62-68):
Interpretation:
  • 50%+: Strategy has edge (for equal-sized trades)
  • 40-50%: Acceptable if winners > losers
  • <40%: Likely unprofitable unless avg winner >> avg loser

Profit Factor

Ratio of gross profit to gross loss (metrics.rs:71-77):
Interpretation:
  • >2.0: Excellent strategy
  • 1.5-2.0: Good strategy
  • 1.0-1.5: Marginal, needs improvement
  • <1.0: Unprofitable

Average Trade P&L

Mean profit per trade (metrics.rs:80-86):
Interpretation:
  • Average trade should be significantly positive after fees
  • For HFT: Even 11-5 per round-trip can be profitable at scale
  • Avg winner should typically be larger than avg loser

Maker Ratio

Percentage of fills that added liquidity (metrics.rs:107-114):
Interpretation:
  • >80%: Excellent for fee optimization
  • 60-80%: Good maker-taker balance
  • <50%: High taker fees may erode profits
For CME futures, maker rebates vs taker fees can be $0.60+ difference per contract.

Maximum Drawdown

Drawdown Calculation

From metrics.rs:146-167:

Drawdown Tracking

The engine continuously updates drawdown (metrics.rs:156-166):
Interpretation:
  • <5%: Excellent risk management
  • 5-10%: Good for HFT strategies
  • 10-20%: Acceptable for lower-frequency strategies
  • >20%: High risk, review strategy and risk limits
High drawdowns can trigger the kill switch if max_drawdown_pct is exceeded in the risk configuration.

Advanced Statistics

The PerformanceStats struct (metrics.rs:186-208) provides deeper analytics.

Sharpe Ratio

Risk-adjusted return metric (metrics.rs:260-275):
Interpretation:
  • >3.0: Excellent (rare for real strategies)
  • 2.0-3.0: Very good
  • 1.0-2.0: Good
  • <1.0: Poor risk-adjusted returns
HFT strategies often achieve Sharpe ratios of 2-4 due to low volatility and consistent returns.

Sortino Ratio

Downside risk-adjusted return (metrics.rs:278-299):
Interpretation:
  • Similar to Sharpe, but only penalizes downside volatility
  • Better metric for asymmetric return distributions
  • Higher Sortino than Sharpe indicates positive skew

Calmar Ratio

Return relative to maximum drawdown (metrics.rs:301-309):
Interpretation:
  • >3.0: Excellent return/drawdown profile
  • 1.0-3.0: Good
  • <1.0: Returns don’t justify drawdown risk

Consecutive Wins/Losses

Track winning and losing streaks (metrics.rs:311-332):
Interpretation:
  • Long losing streaks indicate strategy may need adjustment
  • Very long winning streaks may indicate overfitting
  • Ratio should be reasonable (e.g., max_wins/max_losses ≈ 2-3)

Recovery Factor

Ability to recover from drawdowns (metrics.rs:334-342):
Interpretation:
  • >5.0: Strong recovery capability
  • 2.0-5.0: Moderate recovery
  • <2.0: Slow recovery from drawdowns

Equity Curve Analysis

The equity curve tracks cumulative P&L over time (metrics.rs:235-238):

Equity Curve Characteristics

Smooth Upward Trend:
Ideal - consistent positive returns with low volatility. Volatile but Positive:
Positive but risky - high variance in returns. Drawdown Pattern:
Periods of losses - analyze what caused drawdown.

Volume and Fill Analysis

From metrics.rs:36-50:
Volume Analysis:
  • High volume strategies can profit with small edge per trade
  • Unbalanced buy/sell may indicate directional bias
  • High maker ratio reduces total trading costs

Time-Based Metrics

From metrics.rs:170-182:

Rolling Statistics

The RollingStats calculator (metrics.rs:346-442) tracks windowed metrics:
Use Cases:
  • Detect strategy degradation over time
  • Monitor consistency of returns
  • Adaptive risk management based on recent performance

Interpreting Results

Example Good Strategy

Analysis:
  • Strong win rate (63%)
  • Excellent profit factor (2.31)
  • Low drawdown (3.24%)
  • High Sharpe ratio (2.87)
  • Good maker ratio (76%)
  • Avg winner > Avg loser

Example Problematic Strategy

Issues:
  • Unprofitable after fees (profit factor < 1.0)
  • Low win rate with larger losers
  • High drawdown (18%)
  • Poor Sharpe ratio (0.34)
  • Too many taker fills (expensive)
  • Over-trading (fees > gross profit)

Metrics Summary Table

Exporting Results