| 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 |
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.
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.
kingchenc [email protected]
https://github.com/wickra-lib/wickra-synth
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.
wksynth_command(synth, cmd_json)wksynth_command(synth, cmd_json)
synth |
A handle from |
cmd_json |
A character vector of length one holding the command JSON,
for example |
A length-one character vector holding the response JSON, returned byte for byte as the core produced it.
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"}')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"}')
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.
wksynth_new(spec_json)wksynth_new(spec_json)
spec_json |
A character vector of length one holding a |
A wickra_synth handle: an external pointer whose finalizer frees the
native object, so there is nothing to close by hand.
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)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)
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.
wksynth_version()wksynth_version()
A length-one character vector: the version of the native library this package is linked against.
wksynth_version()wksynth_version()