Skip to content

C / C++

The C ABI hub. A single wickra_backtest.h header + prebuilt library links from C, C++, or any C-capable language. Pass OHLCV arrays and a spec to wickra_backtest_run.

bash
# prebuilt wickra_backtest.h + library per platform:
# github.com/wickra-lib/wickra-backtest/releases
c
#include "wickra_backtest.h"

const char *spec = "{\"symbol\":\"BTCUSDT\",\"timeframe\":\"1h\","
                   "\"indicators\":{\"fast\":{\"type\":\"Ema\",\"params\":[12]},"
                   "\"slow\":{\"type\":\"Ema\",\"params\":[26]}},"
                   "\"entry\":{\"cross_above\":[\"fast\",\"slow\"]},"
                   "\"exit\":{\"cross_below\":[\"fast\",\"slow\"]},"
                   "\"sizing\":{\"type\":\"fixed_fraction\",\"fraction\":0.95}}";

char *report = NULL;
int rc = wickra_backtest_run(open, high, low, close, volume, time, n, spec, 10000.0, &report);
if (rc == 0) {
    printf("%s\n", report);          // JSON BacktestReport
    wickra_backtest_free_string(report);
}

volume/time may be NULL. The header is generated by cbindgen and is the same ABI the C#, Go, Java and R bindings link against; wickra_backtest_run_json takes a full request bundle for microstructure strategies.

More