Package 'wickrabacktest'

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

Help Index


Run a strategy spec over OHLCV data.

Description

Calls the wickra-backtest engine through its C ABI and returns the report as a JSON string, byte-identical to the other language bindings.

Usage

backtest_run(
  open,
  high,
  low,
  close,
  volume = NULL,
  time = NULL,
  spec,
  capital = 10000
)

Arguments

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).

Value

The backtest report as a JSON string.


Run a backtest from a single request bundle.

Description

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.

Usage

backtest_run_json(request)

Arguments

request

The request bundle as a JSON string.

Value

The backtest report as a JSON string.


The equity curve of a streaming backtest so far, as a JSON array.

Description

The equity curve of a streaming backtest so far, as a JSON array.

Usage

backtest_stream_equity_json(bt)

Arguments

bt

A wickra_stream handle.

Value

A length-one character vector.


Close any open position and return the streaming backtest report.

Description

Ends the run: the handle is released, and further use raises an error.

Usage

backtest_stream_finish_json(bt)

Arguments

bt

A wickra_stream handle.

Value

The backtest report as a JSON string.


Release a streaming backtest without producing a report.

Description

Idempotent, so it is safe to call alongside backtest_stream_finish_json().

Usage

backtest_stream_free(bt)

Arguments

bt

A wickra_stream handle.

Value

NULL, invisibly.


The most recent equity point of a streaming backtest.

Description

The most recent equity point of a streaming backtest.

Usage

backtest_stream_latest_equity_json(bt)

Arguments

bt

A wickra_stream handle.

Value

A length-one character vector; the JSON literal null before the first bar.


Start a streaming backtest.

Description

Start a streaming backtest.

Usage

backtest_stream_new(spec, capital = 10000)

Arguments

spec

The strategy spec as a JSON string.

capital

Starting capital (default 10000).

Value

A wickra_stream handle.


The number of closed trades in a streaming backtest so far.

Description

The number of closed trades in a streaming backtest so far.

Usage

backtest_stream_num_trades(bt)

Arguments

bt

A wickra_stream handle.

Value

A length-one numeric vector.


Advance a streaming backtest by one OHLCV bar.

Description

Advance a streaming backtest by one OHLCV bar.

Usage

backtest_stream_step(bt, open, high, low, close, volume = 0, time = NULL)

Arguments

bt

A wickra_stream handle.

open, high, low, close

Numeric bar prices.

volume

Bar volume (default 0).

time

Bar timestamp; defaults to the number of bars fed so far.

Value

The handle, invisibly.


Advance a streaming backtest by one bar given as a request document.

Description

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.

Usage

backtest_stream_step_json(bt, step)

Arguments

bt

A wickra_stream handle.

step

The step document as a JSON string.

Value

The handle, invisibly.


The native wickra-backtest library version.

Description

The native wickra-backtest library version.

Usage

backtest_version()

Value

A length-one character vector.