wickra-timemachine-wasm
v0.2.0
Published
WebAssembly bindings for wickra-timemachine — reconstruct market microstructure in the browser.
Downloads
1,048
Readme
Wickra Time Machine — WASM
Part of the Wickra ecosystem: — for WASM. npm install wickra-timemachine-wasm — pure WebAssembly, runs anywhere a modern JS engine does.
WebAssembly bindings for the Wickra Time Machine, compiled from Rust with
wasm-bindgen. A TimeMachine 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 Time
Machine binding.
Install
npm install wickra-timemachine-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, { TimeMachine } from "wickra-timemachine-wasm";
await init();
const feed = [
{ ts: 10, symbol: "BTC-USDT", feed: { kind: "market", type: "trade",
symbol: { base: "BTC", quote: "USDT" }, price: "100", quantity: "1",
aggressor: "Buy", timestamp: 10 } },
{ ts: 20, symbol: "BTC-USDT", feed: { kind: "market", type: "trade",
symbol: { base: "BTC", quote: "USDT" }, price: "110", quantity: "2",
aggressor: "Sell", timestamp: 20 } },
].map((l) => JSON.stringify(l)).join("\n");
const tm = new TimeMachine("{}");
tm.command(JSON.stringify({ cmd: "load", data: feed }));
const snapshot = JSON.parse(tm.command(JSON.stringify({ cmd: "seek", ts: 20 })));
console.log(snapshot.symbols["BTC-USDT"].last); // 110command mirrors TimeMachine::command_json: the commands are load, seek,
state_at, play and version. An invalid spec throws; a command failure
throws too.
Determinism
The re-fold runs single-threaded here — no rayon thread pool in a browser sandbox — which is byte-identical to the native, parallel run. Seeking to a given timestamp produces the byte-identical snapshot here and in every other binding: the exact cross-language golden invariant.
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-timemachine
Docs (guides, spec reference, cookbook): https://timemachine.wickra.org
Runnable example:
examples/wasm/The main project: https://github.com/wickra-lib/wickra-timemachine
Documentation: https://wickra.org
Wickra Time Machine 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-timemachine/blob/main/SECURITY.md.
Disclaimer
Wickra Time Machine is a research tool, provided "as is" without warranty of any kind. It reconstructs recorded market microstructure for analysis; nothing here is financial advice, and trading carries risk of loss.
License
Licensed under either of Apache-2.0 or MIT at your option.
