A high-performance backtesting engine for algorithmic trading strategies. Features multi-symbol/multi-timeframe support, parallel processing, zero-allocation patterns, and SIMD acceleration.
License
—
Deps
1
Install Size
—
Vulns
✓ 0
Published
Jan 21, 2026
$ dotnet add package Backtest.NetA high-performance backtesting engine for algorithmic trading strategies in .NET.
High-Performance Backtest.Net is a specialized backtesting library designed for quantitative trading applications. It processes multi-timeframe candlestick data across multiple symbols, simulating tick-by-tick strategy execution with proper warmup periods and OHLC handling.
| Feature | Description |
|---|---|
| EngineV10 | Latest engine with Span-based iteration, binary search, and parallel processing |
| SymbolDataSplitter | Partitions large datasets into memory-efficient chunks |
| Warmup Handling | Configurable warmup candle counts per timeframe |
| OHLC Simulation | Accurate current-candle OHLC handling during backtest |
| Progress Tracking | Real-time progress from 0-100% |
| SIMD Acceleration | Leverages SimdLinq for vectorized operations |
The library implements sophisticated performance techniques:
Span<T> and CollectionsMarshal.AsSpanParallel.ForEach for symbol-level parallelism[MethodImpl(MethodImplOptions.AggressiveInlining)]dotnet add package Backtest.Net
<PackageReference Include="Backtest.Net" Version="4.1.14" />
[!NOTE] Requires .NET 10.0 or later.
using Backtest.Net.Engines;
using Backtest.Net.SymbolsData;
using Backtest.Net.SymbolDataSplitters;
using Backtest.Net.Timeframes;
using Backtest.Net.Enums;
// 1. Prepare your symbol data (candlesticks per timeframe)
// Candlestick properties: OpenTime, Open, High, Low, Close, CloseTime, Volume
var symbolsData = new List<SymbolDataV2>
{
new SymbolDataV2
{
Symbol = "BTCUSDT",
Timeframes = new List<TimeframeV2>
{
new TimeframeV2
{
Timeframe = CandlestickInterval.OneMinute,
Candlesticks = yourOneMinuteCandles
},
new TimeframeV2
{
Timeframe = CandlestickInterval.OneHour,
Candlesticks = yourOneHourCandles
}
}
}
};
// 2. Split data for efficient processing
var splitter = new SymbolDataSplitterV2(
daysPerSplit: 30,
warmupCandlesCount: 100,
backtestingStartDateTime: new DateTime(2024, 1, 1)
);
var splitData = await splitter.SplitAsyncV2(symbolsData);
// 3. Create and configure the engine
var engine = new EngineV10(
warmupCandlesCount: 100,
sortCandlesInDescOrder: false,
useFullCandleForCurrent: false
);
// 4. Set up your strategy callback
engine.OnTick = async (symbolData) =>
{
foreach (var symbol in symbolData)
{
var latestCandle = symbol.Timeframes[0].Candlesticks[^1];
// Your strategy logic here
Console.WriteLine($"{symbol.Symbol}: Close = {latestCandle.Close}");
}
};
// 5. Run the backtest
await engine.RunAsync(splitData);
Console.WriteLine($"Progress: {engine.GetProgress()}%");
using var cts = new CancellationTokenSource();
engine.OnCancellationFinishedDelegate = () =>
{
Console.WriteLine("Backtest cancelled gracefully");
};
// Cancel after 30 seconds
cts.CancelAfter(TimeSpan.FromSeconds(30));
await engine.RunAsync(splitData, cts.Token);
| Engine | Description | Use Case |
|---|---|---|
EngineV8 | SymbolDataV2 support | Standard workloads |
EngineV9 | Optimized OHLC handling | Memory-sensitive scenarios |
EngineV10 | Full optimization suite | Production recommended |
[!TIP] Use
EngineV10for new projects. It provides the best performance through zero-allocation patterns and parallel processing.
Performance benchmarks run on Apple M3 Max with .NET 10.0, processing 4 million candlesticks (1 symbol × 4 timeframes × 1,000,000 candles each):
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| EngineV8Run | 99.78 ns | 1.564 ns | 1.463 ns | 0.0621 | 520 B |
| EngineV9Run | 96.69 ns | 1.933 ns | 2.148 ns | 0.0631 | 528 B |
| EngineV10Run | 80.16 ns | 1.553 ns | 1.453 ns | 0.0545 | 456 B |
Key findings:
Benchmarks run with BenchmarkDotNet v0.15.8 on macOS Tahoe 26.2, Apple M3 Max, .NET 10.0
git clone https://github.com/islero/High-Performance-Backtest.Net.git
cd High-Performance-Backtest.Net
dotnet build
dotnet test
cd benchmarks/Backtest.Net.Benchmarks
dotnet run -c Release
dotnet format
This project follows Semantic Versioning.
| Branch | Version Format | NuGet Feed |
|---|---|---|
master | X.Y.Z (stable) | nuget.org |
beta | X.Y.Z-beta.N (prerelease) | nuget.org |
src/Backtest.Net/Backtest.Net.csprojvX.Y.ZContributions are welcome! Please read CONTRIBUTING.md for guidelines.
This project is licensed under the GNU Lesser General Public License v3.0.
Built for the algorithmic trading community