Wickra.Backtest 0.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Wickra.Backtest --version 0.1.4
                    
NuGet\Install-Package Wickra.Backtest -Version 0.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Wickra.Backtest" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wickra.Backtest" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Wickra.Backtest" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Wickra.Backtest --version 0.1.4
                    
#r "nuget: Wickra.Backtest, 0.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Wickra.Backtest@0.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Wickra.Backtest&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Wickra.Backtest&version=0.1.4
                    
Install as a Cake Tool

<p align="center"> <a href="https://wickra.org"><img src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/wickra-banner.webp?v=514" alt="Wickra Backtest — backtest and live are byte-identical" width="100%"></a> </p>

Built on Wickra CI codecov License: MIT OR Apache-2.0

Wickra Backtest — C#


C# binding for the wickra-backtest engine. It calls the stable C ABI through P/Invoke, so the results are byte-identical to the Rust, Python, Node.js, WASM, Java, Go, C/C++ and R bindings: one engine kernel behind every language.

Requirements

  • .NET 8 SDK
  • The native library wickra_backtest (built from the C-ABI crate)

Build the native library

cargo build -p wickra-backtest-c          # debug   -> target/debug
cargo build -p wickra-backtest-c --release # release -> target/release

The test project copies the native library next to the test assembly; for your own app, ensure wickra_backtest.dll / .so / .dylib is on the load path.

Usage

using Wickra.Backtest;

double[] open  = { 100.0, 102.0, 104.0, 98.0 };
double[] high  = { 101.0, 103.0, 104.0, 98.0 };
double[] low   = { 100.0, 102.0,  99.0, 97.0 };
double[] close = { 101.0, 103.0,  99.0, 97.0 };

string spec =
    "{\"symbol\":\"x\",\"timeframe\":\"1h\",\"indicators\":{}," +
    "\"entry\":{\"gt\":[{\"price\":\"close\"},100]}," +
    "\"exit\":{\"lt\":[{\"price\":\"close\"},100]}," +
    "\"sizing\":{\"type\":\"fixed_qty\",\"qty\":1}}";

string reportJson = Backtester.Run(open, high, low, close, spec: spec, capital: 10_000.0);
Console.WriteLine(reportJson);

Backtester.Run(open, high, low, close, volume?, time?, spec, capital) returns the BacktestReport JSON string. volume/time default to zeros / 0..n. An invalid spec throws InvalidOperationException; no panic crosses the boundary.

The same strategy also runs one bar at a time, which is what makes a backtest and a live loop the same code path -- swap the array for a socket and nothing else changes:

using var bt = new StreamingBacktest(spec, capital: 10_000.0);
foreach (var bar in feed)
{
    bt.Step(bar.Open, bar.High, bar.Low, bar.Close, bar.Volume, bar.Time);
    Console.WriteLine($"{bt.NumTrades} {bt.LatestEquityJson()}");
}
string reportJson = bt.FinishJson();

StreamingBacktest owns a native handle, so dispose it -- using, Dispose(), or FinishJson(), which ends the run and releases it. volume defaults to 0 and time to the number of bars fed so far. Strategies reading a side feed drive the run with StepJson, passing { "candle": ..., "feeds": ... } per bar. Using a finished run throws ObjectDisposedException.

Test

dotnet test Wickra.Backtest.Tests/Wickra.Backtest.Tests.csproj

Documentation

The same StrategySpec runs identically across Rust, Python, Node.js, WASM, C, C++, C#, Go, Java and R — one engine kernel, byte-identical reports.

Security

Found a security issue? Please don't open a public issue. Report it privately via the repository's Security tab ("Report a vulnerability") or email support@wickra.org. Full policy: https://github.com/wickra-lib/wickra-backtest/blob/main/SECURITY.md.

Disclaimer

Not a trading system. Backtest results are deterministic transforms of the input data — they are not financial advice and are not indicative of future performance. Any use in a live trading context is at your own risk. Provided as is, without warranty of any kind.

License

Licensed under either of MIT or Apache-2.0 at your option.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.9 108 9/27/2026
0.1.8 90 9/23/2026
0.1.7 106 9/18/2026
0.1.6 99 9/15/2026
0.1.5 100 9/13/2026
0.1.4 116 9/2/2026
0.1.3 112 9/2/2026
0.1.2 106 8/31/2026
0.1.1 104 8/31/2026
0.1.0 114 8/28/2026