High-performance backtesting engine for cryptocurrency strategies
Processes 210 million ticks per second using C# optimization techniques. Built to test trading strategies honestly - shows real results, not cherry-picked wins.
I tested 58 variations of 10 popular strategies on 7.4M Bitcoin price points (2012-2026):
📊 Key Finding: 43% of strategies LOST money
- Z-Score Mean Reversion: +$480k, 77% win rate ✅
- Bollinger Bands: +$462k, 70% win rate ✅
- RSI (Oversold/Overbought): +$330k, 72% win rate ✅
- Fast EMAs (10-20 period): -$1M, 20% win rate ❌
- Fast SMAs: -$908k, 21% win rate ❌
- MACD variations: -$373k, 27% win rate ❌
Why? Bitcoin is choppy. Fast trend-following strategies get destroyed by whipsaw. Mean reversion strategies that fade extremes actually work.
Dataset: 7.4M minute-by-minute Bitcoin ticks (14 years)
Load Time: 1.65 seconds
Processing: 210M ticks/second
58 Strategy Tests: ~8 seconds total
How?
readonly structfor cache localitySpan<T>for zero-allocation iteration- No LINQ in hot loops
- Value types over reference types
# Clone
git clone [https://github.com/iOptimizeThings/FlashBack.git](https://github.com/iOptimizeThings/FlashBack.git)
cd FlashBack
# Run
dotnet run -c Release
# Choose Option 1 to test all strategies
# Or Option 2 for quick single-strategy testRequires: .NET 8.0
To reproduce the benchmark results (210M ticks/sec), this project was tested using Bitcoin 1-Minute Historical Data from Kaggle.
- Dataset Source: Bitcoin Historical Data (Kaggle)
- Specific File:
btcusd_1-min_data.csv - Timeframe: Jan 2012 - Present
Setup:
- Download the
.csvfile from Kaggle. - Rename it to
1.csv(optional, for easier typing) or keep the original name. - Place it in the root directory or copy the path when prompted.
Trend Following:
- Simple Moving Average (SMA)
- Exponential Moving Average (EMA)
- Dual MA Crossover
Momentum:
- RSI (Relative Strength Index)
- MACD (Moving Average Convergence Divergence)
- Stochastic Oscillator
Volatility:
- Bollinger Bands
- ATR Breakout
Mean Reversion:
- Z-Score Statistical Arbitrage
Volume:
- VWAP (Volume Weighted Average Price)
Each strategy tested with multiple parameter combinations (fast/slow periods, thresholds, etc.)
The engine generates:
- Console summary with top/bottom performers
- Detailed text reports with every trade
- CSV export for Excel analysis
- Sharpe ratios, max drawdown, win rates
-
Most "textbook" strategies lose money on Bitcoin - The classic SMA(50) that everyone recommends? Lost $482k.
-
Mean reversion > Trend following for crypto - Bitcoin oscillates more than it trends. Strategies that buy dips and sell rips work better.
-
Parameter optimization matters - SMA(10) lost $908k but SMA(500) made $46k. Same strategy, different settings.
-
Win rate ≠ Profitability - Some strategies had 70%+ win rates but still lost money due to a few huge losing trades.
- Language: C# 10 / .NET 8.0
- CSV Parsing: nietras.SeparatedValues (fastest .NET CSV library)
- Architecture: Value types, Span, aggressive inlining
- Paradigm: Zero-allocation hot loops
Want to see the engine in action? Follow these steps to generate the summary table:
- Run the application:
dotnet run -c Release - Select Option 1.
- Enter the path to your dataset (e.g.,
1.csv). - Wait for the analysis to complete (approx. 15-20 seconds for 14 years of data).
If you find this project useful, feel free to use these templates to share your results!
PRs welcome! Especially for:
- Additional strategies (Ichimoku, Fibonacci, etc.)
- Multiple timeframe analysis
- Portfolio optimization
- Walk-forward testing
MIT
Note: This is educational software. Past performance ≠ future results. Don't trade with money you can't afford to lose.