| Title: | Wickra Backtest Engine (R Binding) |
|---|---|
| Description: | R binding for the wickra-backtest engine. It calls the engine's stable C ABI from compiled C glue via .Call, returning the backtest report as a JSON string that is byte-identical to the Rust, Python, Node.js, WASM, C#, Java and Go bindings. |
| Authors: | kingchenc [aut, cre] |
| Maintainer: | kingchenc <[email protected]> |
| License: | MIT + file LICENSE | Apache License 2.0 |
| Version: | 0.2.0 |
| Built: | 2026-10-07 08:57:42 UTC |
| Source: | https://github.com/wickra-lib/wickra-backtest |
Calls the wickra-backtest engine through its C ABI and returns the report as a JSON string, byte-identical to the other language bindings.
backtest_run( open, high, low, close, volume = NULL, time = NULL, spec, capital = 10000 )backtest_run( open, high, low, close, volume = NULL, time = NULL, spec, capital = 10000 )
open, high, low, close
|
Numeric price vectors of equal length. |
volume |
Optional numeric volume vector (defaults to zeros). |
time |
Optional numeric timestamp vector (defaults to 0..n-1). |
spec |
The strategy spec as a JSON string. |
capital |
Starting capital (default 10000). |
The backtest report as a JSON string.
The request is a JSON document carrying the candles, the spec, the starting capital and any optional feeds. Returns the report as a JSON string, byte-identical to the other language bindings.
backtest_run_json(request)backtest_run_json(request)
request |
The request bundle as a JSON string. |
The backtest report as a JSON string.
The equity curve of a streaming backtest so far, as a JSON array.
backtest_stream_equity_json(bt)backtest_stream_equity_json(bt)
bt |
A |
A length-one character vector.
Ends the run: the handle is released, and further use raises an error.
backtest_stream_finish_json(bt)backtest_stream_finish_json(bt)
bt |
A |
The backtest report as a JSON string.
Idempotent, so it is safe to call alongside backtest_stream_finish_json().
backtest_stream_free(bt)backtest_stream_free(bt)
bt |
A |
NULL, invisibly.
The most recent equity point of a streaming backtest.
backtest_stream_latest_equity_json(bt)backtest_stream_latest_equity_json(bt)
bt |
A |
A length-one character vector; the JSON literal null before the
first bar.
Start a streaming backtest.
backtest_stream_new(spec, capital = 10000)backtest_stream_new(spec, capital = 10000)
spec |
The strategy spec as a JSON string. |
capital |
Starting capital (default 10000). |
A wickra_stream handle.
The number of closed trades in a streaming backtest so far.
backtest_stream_num_trades(bt)backtest_stream_num_trades(bt)
bt |
A |
A length-one numeric vector.
Advance a streaming backtest by one OHLCV bar.
backtest_stream_step(bt, open, high, low, close, volume = 0, time = NULL)backtest_stream_step(bt, open, high, low, close, volume = 0, time = NULL)
bt |
A |
open, high, low, close
|
Numeric bar prices. |
volume |
Bar volume (default 0). |
time |
Bar timestamp; defaults to the number of bars fed so far. |
The handle, invisibly.
The document is {"candle": {...}, "feeds": {...}}, where feeds optionally
carries this bar's reference, derivatives, order-book, trade or cross-section
input. This is the only form that can drive a strategy reading a side feed.
backtest_stream_step_json(bt, step)backtest_stream_step_json(bt, step)
bt |
A |
step |
The step document as a JSON string. |
The handle, invisibly.
The native wickra-backtest library version.
backtest_version()backtest_version()
A length-one character vector.