Package 'wickrasynth'

Title: Deterministic Synthetic Market Microstructure
Description: R bindings for wickra-synth over its C ABI hub: a seeded GenSpec generates byte-identical OHLCV candles, order-book snapshots, trades and funding - the same protocol as the CLI and every other binding.
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:56:52 UTC
Source: https://github.com/wickra-lib/wickra-synth

Help Index


Deterministic Synthetic Market Microstructure

Description

R bindings for wickra-synth over its C ABI hub. A seeded GenSpec produces byte-identical OHLCV candles, order-book snapshots, trades and funding: the same seed yields the same bytes here as in the Rust core and in every other language binding, which is what the project's golden corpus checks.

The whole surface is three functions over one JSON boundary. Build a handle with wksynth_new, drive it with wksynth_command, and read the version with wksynth_version.

Details

The native library is resolved at build time by configure: it downloads the prebuilt C ABI matching this package's version and bundles it beside the compiled object. Set WKSYNTH_INC and WKSYNTH_LIB to build against a locally built one instead.

Author(s)

kingchenc [email protected]

References

https://github.com/wickra-lib/wickra-synth


Apply a command and return the response

Description

The single entry point every wickra-synth binding forwards to. Four commands exist: version, set_spec, generate and generate_stream.

This function does not raise on a bad command or a bad spec. Failure comes back in the response as {"ok":false,"error":...}, so a caller checks the parsed result rather than wrapping the call.

Usage

wksynth_command(synth, cmd_json)

Arguments

synth

A handle from wksynth_new.

cmd_json

A character vector of length one holding the command JSON, for example '\{"cmd":"generate"\}' or '\{"cmd":"generate_stream"\}'.

Value

A length-one character vector holding the response JSON, returned byte for byte as the core produced it.

See Also

wksynth_new

Examples

spec <- paste0(
  '{"seed":42,"bars":8,"start_price":100.0,',
  '"regimes":[{"kind":"trend","len":8,"drift":0.002,"vol":0.01}],',
  '"microstructure":{"book_depth":3,"spread_bps":4.0,"trade_rate":3.0}}'
)
synth <- wksynth_new(spec)
out <- wksynth_command(synth, '{"cmd":"generate"}')

Build a synth from a spec

Description

Parses and validates the spec. An invalid spec is a hard error here rather than an in-band one later, which is the one place this binding raises: every command error comes back inside the returned JSON instead.

Usage

wksynth_new(spec_json)

Arguments

spec_json

A character vector of length one holding a GenSpec as JSON. It may also be "\{\}" or the empty string, which builds a handle with no spec; a command must then carry its own "spec" field.

Value

A wickra_synth handle: an external pointer whose finalizer frees the native object, so there is nothing to close by hand.

See Also

wksynth_command

Examples

spec <- paste0(
  '{"seed":42,"bars":8,"start_price":100.0,',
  '"regimes":[{"kind":"trend","len":8,"drift":0.002,"vol":0.01}],',
  '"microstructure":{"book_depth":3,"spread_bps":4.0,"trade_rate":3.0}}'
)
synth <- wksynth_new(spec)

The wickra-synth library version

Description

Reports the version of the C ABI library, not of the R package. The two are released together, so a mismatch means the bundled library did not come from this release.

Usage

wksynth_version()

Value

A length-one character vector: the version of the native library this package is linked against.

Examples

wksynth_version()