wickra-synth-wasm
v0.2.0
Published
WebAssembly bindings for wickra-synth — generate synthetic microstructure in the browser.
Readme
Wickra Synth — WASM
Deterministic synthetic market microstructure — for WASM. npm install wickra-synth-wasm — pure WebAssembly, runs anywhere a modern JS engine does.
WebAssembly bindings for the Wickra synthetic-microstructure generator, compiled
from Rust with wasm-bindgen. A
Synth is built from a spec JSON and driven by command JSONs over a JSON
boundary, so a browser front-end runs against the exact same core as every other
Wickra Synth binding.
Install
npm install wickra-synth-wasmBuilding from this repository (contributors)
wasm-pack build --target web # for a browser bundler
wasm-pack build --target nodejs # for node:test / Node.jsThe output lands in pkg/.
Quick start
import init, { Synth } from "wickra-synth-wasm";
await init();
const spec = JSON.stringify({
seed: 42,
bars: 20,
start_price: 100.0,
regimes: [{ kind: "trend", len: 20, drift: 0.002, vol: 0.01 }],
microstructure: { book_depth: 5, spread_bps: 4.0, trade_rate: 8.0 },
});
const synth = new Synth(spec);
const out = JSON.parse(synth.command(JSON.stringify({ cmd: "generate" })));
console.log(out.candles.length); // 20Surface
new Synth(specJson)— build a synth from a spec JSON (throws if the spec is invalid).synth.command(cmdJson) -> string— apply a command envelope ({"cmd":"...", ...}) and return the response JSON. Commands:set_spec,generate,generate_stream,version.synth.version() -> stringand the module-levelversion()— the crate version.
An invalid spec throws from the constructor. A malformed command or an unknown
command name is reported in-band as {"ok":false,"error":...} (the response
JSON), not thrown.
Determinism
The generator runs single-threaded in the browser sandbox (no worker thread pool), which is byte-identical to the native run — the exact cross-language golden invariant. The response bytes match every other binding for a given seed.
Benchmark
Every binding forwards to the same data-driven Rust core, so what this one adds is
the call overhead of wasm-bindgen, not a different result. The core's throughput is
measured by the repository's benchmark suite and the nightly bench.yml run; the
numbers, the machine and how to reproduce them are in the repository
BENCHMARKS.md.
Documentation
The full guide, the spec reference and the API documentation live in the main repository and the documentation site:
Repository: https://github.com/wickra-lib/wickra-synth
Docs (guides, spec reference, cookbook): https://synth.wickra.org
Runnable example:
examples/wasm/The main project: https://github.com/wickra-lib/wickra-synth
Documentation: https://wickra.org
Wickra Synth ships native bindings for Python, Node.js, WASM and Rust, plus a C ABI hub that any
C-capable language (C, C++, C#, Go, Java, R) links against — all forwarding to the
same data-driven, unsafe-forbidden Rust core.
Security
Found a security issue? Please don't open a public issue. Report it privately
via the repository's Security tab ("Report a vulnerability") or email
[email protected] with a subject line starting [wickra security]. Full
policy: https://github.com/wickra-lib/wickra-synth/blob/main/SECURITY.md.
Disclaimer
wickra-synth generates synthetic market data for testing, training and
demonstration. It is not real market data and is not financial advice; it comes
with no warranty.
License
Licensed under either of Apache-2.0 or MIT at your option.
