Release Date: December 24, 2024
Comprehensive trade tracking and advanced risk metrics for honest performance analysis.
Sortino Ratio - Downside deviation only
- Penalizes only negative volatility
- Better for asymmetric return strategies
- SMA 50/200 shows 1.34 Sortino vs 0.89 Sharpe (positive skew confirmed)
Calmar Ratio - Return per unit of drawdown
- Direct measure: annualized return / |max drawdown|
- Buy-and-hold: 2.13 Calmar (good)
- SMA 20/50: 2.68 Calmar (excellent)
Every backtest now captures individual trades:
- Entry/exit timestamps and prices
- Position size and P&L ($ and %)
- Duration (bars and days)
- Win/loss classification
Aggregate analysis automatically calculated:
- Win Rate: Percentage of profitable trades
- Profit Factor: Total wins / Total losses
- Expectancy: Expected value per trade
- Average Win/Loss: Mean trade sizes
- Largest Win/Loss: Outlier identification
- Win/Loss Streaks: Longest consecutive runs
Export data for external analysis:
result.save_trades_to_csv(Path::new("trades.csv"))?;
result.save_equity_to_csv(Path::new("equity.csv"))?;=== RESULTS ===
Initial capital: $ 100000.00
Final equity: $ 1049354.30
Total return: 949.35%
Sharpe ratio: 0.89
Sortino ratio: 1.34 ← NEW
Calmar ratio: 2.36 ← NEW
Max drawdown: -76.63%
Total trades: 5
=== TRADE ANALYSIS === ← NEW SECTION
Win rate: 80.0%
Profit factor: 432.67
Avg win: $ 72910.70
Avg loss: $ 2.89
Largest win: $ 291632.26
Largest loss: $ 28.88
Expectancy: $ 58328.56
Win streak: 3
Loss streak: 1
Return: 857.31%
Sharpe: 0.83
Sortino: 1.21 (better - only downside risk)
Calmar: 2.13 (return/drawdown ratio)
Win rate: 100% (single trade)
Profit factor: 999.00 (no losses)
Expectancy: $857,408
Return: 949.35%
Sharpe: 0.89
Sortino: 1.34 (strong positive skew)
Calmar: 2.36 (efficient vs drawdown)
Win rate: 80% (4 wins, 1 loss)
Profit factor: 432.67
Expectancy: $58,329 per trade
Max win: $291,632
Max loss: $29 (tiny)
Win streak: 3
Return: 1079.39%
Sharpe: 0.89
Sortino: 1.30
Calmar: 2.68 (best risk-adjusted)
Win rate: 50% (more whipsaws)
Profit factor: 432.67
Avg loss: $2.89 (tiny whipsaw losses)
Win streak: 3
Loss streak: 3
Sortino > Sharpe?
- Strategy has positive skew (good)
- Upside volatility exceeds downside
- True for all SMA strategies tested
Calmar > 2.0?
- Return efficiency vs max loss is good
- SMA 20/50 at 2.68 is excellent
- Better capital efficiency than buy-and-hold
Win Rate 50-80%?
- Realistic for trend-following
- 80% (SMA 50/200) means low whipsaw
- 50% (SMA 20/50) means faster signals, more noise
Profit Factor > 100?
- Tiny losses, big wins (asymmetric)
- Confirms trend-following nature
- Stop losses would reduce this
None. All v0.2.0 functionality preserved.
New fields in BacktestResult:
sortino_ratio: f64calmar_ratio: f64trades: Option<Vec<Trade>>trade_stats: Option<TradeStats>>
All are additions - no existing functionality changed.
# Clone
git clone https://github.com/ChronoCoders/strataquant.git
cd strataquant
# Build
cargo build --release
# Run
./target/release/strataquant backtest --strategy smaNew Files:
src/backtest/trade.rs- Trade tracking structs (188 lines)src/metrics/sortino.rs- Sortino ratio (33 lines)src/metrics/calmar.rs- Calmar ratio (19 lines)
Modified Files:
src/backtest/result.rs- Added new metrics and CSV exportsrc/backtest/engine.rs- Trade tracking logicsrc/main.rs- Display new metrics in CLI
Performance:
- Trade tracking overhead: <5ms per backtest
- Memory increase: ~100 KB for 1000-bar backtest
- All metrics: O(n) time complexity
Dependencies:
- No new dependencies added
v0.4.0 - Risk Management (planned):
- Position sizing (Kelly, fixed fractional)
- Stop losses (trailing, fixed)
- Portfolio heat limits
- Max drawdown thresholds
Download the source:
wget https://github.com/ChronoCoders/strataquant/archive/refs/tags/v0.3.0.tar.gzOr clone:
git clone --branch v0.3.0 https://github.com/ChronoCoders/strataquant.gitSource tarball:
sha256: [Will be generated by GitHub]
Built by Distributed Systems Labs, LLC
- GitHub: @ChronoCoders
- Website: https://dslabs.network
Full changelog: CHANGELOG.md
Previous releases:
This software is for educational and research purposes only. Past performance does not guarantee future results. Trading cryptocurrencies carries significant risk. Only trade with capital you can afford to lose.