Commit Graph

3 Commits

Author SHA1 Message Date
Andrew Kaszubski 3d1267a818 feat(backtest): add ReportGenerator for PDF/HTML reports - Issue #44 (44 tests)
Implements comprehensive report generation for backtest results:
- ReportFormat, ReportSection, ChartType enums for configuration
- ReportConfig dataclass for customization (format, sections, colors)
- ChartData, ReportContent, ReportResult dataclasses
- ReportGenerator class with multi-format output:
  - HTML reports with embedded CSS styling
  - PDF reports (with HTML fallback)
  - JSON structured data export
  - Markdown text reports
- SVG chart generation for equity curves and drawdowns
- Monthly returns heatmap visualization
- Configurable color schemes and sections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 23:16:38 +11:00
Andrew Kaszubski 722b88d5b4 feat(backtest): add ResultsAnalyzer for metrics and trade analysis - Issue #43 (42 tests)
Implements comprehensive post-backtest analysis:
- TradeAnalysis, TradePattern, PerformanceBreakdown dataclasses
- RiskMetrics: Sharpe, Sortino, Calmar, VaR, CVaR, Ulcer index
- TradeStatistics: Win rate, profit factor, streaks, averages
- BenchmarkComparison: Alpha, beta, correlation, capture ratios
- DrawdownAnalysis: Underwater periods, recovery tracking
- AnalysisResult: Complete analysis output
- Monthly and yearly performance breakdown
- Best/worst trade identification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 23:03:02 +11:00
Andrew Kaszubski 6e52e4190d feat(backtest): add BacktestEngine with slippage and commission models - Issue #42 (57 tests)
Implements comprehensive backtesting framework:
- OrderSide, OrderType, FillStatus enums
- OHLCV bar data and Signal dataclasses
- BacktestConfig, BacktestPosition, BacktestTrade, BacktestResult
- BacktestSnapshot for portfolio tracking over time
- BacktestEngine main class

Slippage Models:
- NoSlippage: Zero slippage (ideal execution)
- FixedSlippage: Fixed amount per share
- PercentageSlippage: Percentage of price
- VolumeSlippage: Volume-impact model with participation ratio

Commission Models:
- NoCommission: Zero commission
- FixedCommission: Fixed per trade
- PerShareCommission: Per share with min/max
- PercentageCommission: Percentage of trade value
- TieredCommission: Tiered by trade value thresholds

Features:
- Historical price data replay with date filtering
- Multi-symbol portfolio support
- Automatic position sizing (equal weight)
- Buy/sell signal execution with slippage
- Cash and position tracking
- Shorting support (configurable)
- Max position percentage limits
- Minimum trade value enforcement
- Strategy callback for dynamic signals
- Portfolio snapshots at each timestamp
- Drawdown tracking with peak detection
- Sharpe and Sortino ratio calculation
- Win rate, profit factor, avg trade P&L
- Total commission and slippage tracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 22:55:18 +11:00