Wickra.Backtest 0.1.9

dotnet add package Wickra.Backtest --version 0.1.9
                    
NuGet\Install-Package Wickra.Backtest -Version 0.1.9
                    
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.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wickra.Backtest" Version="0.1.9" />
                    
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.9
                    
#r "nuget: Wickra.Backtest, 0.1.9"
                    
#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.9
                    
#: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.9
                    
Install as a Cake Addin
#tool nuget:?package=Wickra.Backtest&version=0.1.9
                    
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.svg?v=514-8" alt="Wickra Backtest — backtest and live are byte-identical" width="100%"></a> </p>

CI codecov NuGet License: MIT OR Apache-2.0

Wickra Backtest — C#


▶ Live demo: run a strategy in your browser and watch the equity curve build bar by bar — backtest-live.wickra.org · zero backend, the same engine this repository ships, compiled to WebAssembly.

Backtest and live — for C#. dotnet add package Wickra.Backtest — prebuilt native library, no system dependencies.

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.

Install

dotnet add package Wickra.Backtest

The native library ships prebuilt per platform under runtimes/<rid>/native/, selected automatically. There is nothing to compile. Targets .NET 8 and later.

Requirements

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

Building from this repository (contributors)

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.

Test.

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

Quick start

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.

Benchmark

benchmarks/ reports this binding's throughput over the shared core. It measures the call overhead of [LibraryImport] P/Invoke over the C ABI, not a cross-library ratio (the same Rust core runs under every binding) — see the repository BENCHMARKS.md for the numbers, the machine and how each harness is run.

Documentation

The full guide, the spec reference and the API documentation live in the main repository and the documentation site:

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

Wickra Backtest ships native bindings for Python, Node.js, WASM and Rust, plus a C ABI hub that any C-capable language (C, C++, C#, Go, Java, R) links against — all forwarding to the same data-driven, unsafe-forbidden Rust core.

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 with a subject line starting [wickra security]. 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. The software is provided as is, without warranty of any kind; see the license files for the full terms.

License

Licensed under either of Apache-2.0 or MIT 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