wickra-backtest-wasm 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@ indicator core.
31
31
 
32
32
  > **▶ Live demo:** run a strategy in your browser and watch the equity curve build bar by bar — **[backtest-live.wickra.org](https://backtest-live.wickra.org)** · zero backend, the same engine this repository ships, compiled to WebAssembly.
33
33
 
34
- > **Part of the [Wickra ecosystem](https://github.com/wickra-lib):** the same data-driven core and ten-language binding surface also power [wickra-exchange](https://github.com/wickra-lib/wickra-exchange), [wickra-terminal](https://github.com/wickra-lib/wickra-terminal), [wickra-screener](https://github.com/wickra-lib/wickra-screener), [wickra-xray](https://github.com/wickra-lib/wickra-xray), [wickra-radar](https://github.com/wickra-lib/wickra-radar), [wickra-copilot](https://github.com/wickra-lib/wickra-copilot) and [wickra-shazam](https://github.com/wickra-lib/wickra-shazam).
34
+ > **Part of the [Wickra ecosystem](https://github.com/wickra-lib):** the same data-driven core and ten-language binding surface also power [wickra-exchange](https://github.com/wickra-lib/wickra-exchange), [wickra-terminal](https://github.com/wickra-lib/wickra-terminal), [wickra-screener](https://github.com/wickra-lib/wickra-screener) and 20 more — see [the full list](https://github.com/wickra-lib).
35
35
 
36
36
  The engine consumes the **exact same `wickra-core` O(1) indicator kernels** that
37
37
  power live Wickra, and a strategy is **data (a JSON spec), not code** — so a
@@ -78,6 +78,24 @@ with wbt.StreamingBacktest(spec=spec) as live:
78
78
  The two reports are byte-identical. That is the whole claim, and a shared
79
79
  [golden corpus](golden/) holds every one of the ten bindings to it.
80
80
 
81
+ ## Documentation
82
+
83
+ - **[Strategy spec reference](docs/STRATEGY_SPEC.md)** — the full DSL: operands,
84
+ conditions, sizing, costs, slippage, risk, execution and the report shape.
85
+ - **[Cookbook](docs/COOKBOOK.md)** — six ready-to-run strategies (RSI mean
86
+ reversion, MACD trend, Bollinger breakout, Donchian breakout, funding carry,
87
+ order-book imbalance), each validated against the engine.
88
+ - **[Microstructure guide](docs/MICROSTRUCTURE.md)** — backtesting on the order
89
+ book, trades, perpetual funding and market breadth (the differentiator).
90
+ - **[Architecture](ARCHITECTURE.md)** — crates, data flow and design decisions.
91
+ - **[Benchmarks](BENCHMARKS.md)** — throughput methodology and caveats.
92
+ - **[Examples](examples/)** — runnable specs and a sample dataset.
93
+ - The JSON Schema for the spec is at
94
+ [`schema/strategy_spec.schema.json`](schema/strategy_spec.schema.json) and is
95
+ printed by `wkbt schema`.
96
+
97
+ ## Why Wickra Backtest
98
+
81
99
  What it does differently:
82
100
 
83
101
  - **O(1) per tick** — years of tick data in seconds, not hours (no recompute-on-every-tick).
@@ -110,23 +128,9 @@ because none of them needs to.
110
128
  **Alpha / work in progress.** The engine, the data-driven `StrategySpec`, the
111
129
  full execution and cost model, the microstructure feeds and all ten language
112
130
  bindings are implemented and tested; a shared [golden corpus](golden/) pins the
113
- cross-language equality byte-for-byte. Not yet released to any registry.
114
-
115
- ## Documentation
116
-
117
- - **[Strategy spec reference](docs/STRATEGY_SPEC.md)** — the full DSL: operands,
118
- conditions, sizing, costs, slippage, risk, execution and the report shape.
119
- - **[Cookbook](docs/COOKBOOK.md)** — six ready-to-run strategies (RSI mean
120
- reversion, MACD trend, Bollinger breakout, Donchian breakout, funding carry,
121
- order-book imbalance), each validated against the engine.
122
- - **[Microstructure guide](docs/MICROSTRUCTURE.md)** — backtesting on the order
123
- book, trades, perpetual funding and market breadth (the differentiator).
124
- - **[Architecture](ARCHITECTURE.md)** — crates, data flow and design decisions.
125
- - **[Benchmarks](BENCHMARKS.md)** — throughput methodology and caveats.
126
- - **[Examples](examples/)** — runnable specs and a sample dataset.
127
- - The JSON Schema for the spec is at
128
- [`schema/strategy_spec.schema.json`](schema/strategy_spec.schema.json) and is
129
- printed by `wkbt schema`.
131
+ cross-language equality byte-for-byte. Released as **v0.1.0** to every registry:
132
+ crates.io, PyPI, npm, NuGet, Maven Central, the Go module proxy and
133
+ R-universe.
130
134
 
131
135
  ## Quickstart
132
136
 
@@ -197,10 +201,62 @@ The C, C++, C#, Go, Java and R bindings all call through the same C ABI hub; the
197
201
  both the plain OHLCV path and the order-book / trade / derivatives /
198
202
  cross-section feed paths.
199
203
 
200
- ## Performance
204
+ ## Benchmarks
201
205
 
202
206
  O(1) per bar — about **1.7M bars/second** on one core (a year of 1-minute bars in
203
- ~0.3 s). See [BENCHMARKS.md](BENCHMARKS.md) for the methodology and caveats.
207
+ ~0.3 s). The cost of a bar is bounded by the indicators the spec configures, never
208
+ by how much history precedes it. Full tables and how to reproduce them live in
209
+ **[BENCHMARKS.md](BENCHMARKS.md)**.
210
+
211
+ ### Pick your language with eyes open — per-binding throughput
212
+
213
+ Every binding drives the **same** Rust engine, so this is **not** a speed claim —
214
+ it is the raw cost of crossing each language's FFI boundary, measured with the
215
+ [shared example strategy](examples/ema-cross.json) over 100,000 bars (median of
216
+ three runs, one development machine). **Batch collapses towards the floor;
217
+ streaming is where the boundary shows** — so if you drive a live loop bar by bar,
218
+ the table tells you which binding keeps up.
219
+
220
+ | Binding | streaming | ns/bar | batch | ns/bar |
221
+ |---------|----------:|-------:|------:|-------:|
222
+ | C | 6,750,000 b/s | 148 | 6,548,000 b/s | 153 |
223
+ | C# | 6,188,000 b/s | 162 | 6,315,000 b/s | 158 |
224
+ | Go | 4,621,000 b/s | 216 | 6,448,000 b/s | 155 |
225
+ | Java | 4,493,000 b/s | 223 | 5,565,000 b/s | 180 |
226
+ | WASM | 4,127,000 b/s | 242 | 4,878,000 b/s | 205 |
227
+ | Node | 3,438,000 b/s | 291 | 2,530,000 b/s | 395 |
228
+ | Python | 1,411,000 b/s | 709 | 1,486,000 b/s | 673 |
229
+ | R | 284,000 b/s | 3,527 | 6,213,000 b/s | 161 |
230
+
231
+ **C is the floor**: it calls the exported functions directly, with no marshalling
232
+ of its own, so its ~148 ns/bar is the engine plus a function call — every other
233
+ row is that number plus what the language adds. Two results are the opposite of
234
+ what one might assume: **Node's batch path is slower than its streaming path**
235
+ (marshalling six JavaScript arrays across napi costs more than 100,000 scalar
236
+ calls), and **WASM beats the native Node binding on both paths**. All ten share
237
+ one verified implementation, so the *numbers* differ but the *values* do not.
238
+ Methodology and the per-binding discussion are in
239
+ [BENCHMARKS.md](BENCHMARKS.md#per-binding-throughput--the-cost-of-the-boundary).
240
+
241
+ ## Requirements
242
+
243
+ The minimum supported version per language. The same engine kernel runs behind
244
+ every binding; the C-ABI bindings that compile on install — Go (cgo) and R
245
+ (`.Call`) — also need a C compiler, and Java runs with
246
+ `--enable-native-access=ALL-UNNAMED`.
247
+
248
+ | Language | Package | Minimum supported |
249
+ |----------|-------------------------------------------|----------------------------|
250
+ | Rust | crates.io · `wickra-backtest` | 1.86 (MSRV) |
251
+ | Python | PyPI · `wickra-backtest` (abi3 wheel) | 3.9 (tested through 3.13) |
252
+ | Node.js | npm · `wickra-backtest` (N-API 8) | 22 (tested on 22 · 24 LTS) |
253
+ | WASM | npm · `wickra-backtest-wasm` | any modern JS engine |
254
+ | C | `wickra_backtest.h` + library (releases) | C99 compiler |
255
+ | C++ | the C ABI + optional `wickra_backtest.hpp` | C++14 compiler |
256
+ | C# | NuGet · `Wickra.Backtest` | .NET 8 (`net8.0`) |
257
+ | Go | module · `wickra-lib/wickra-backtest-go` | Go 1.23 (cgo) |
258
+ | Java | Maven Central · `org.wickra:wickra-backtest` | Java 22 (FFM / Panama) |
259
+ | R | r-universe · `wickrabacktest` | R ≥ 2.10 (Rtools on Win.) |
204
260
 
205
261
  ## Project layout
206
262
 
@@ -225,7 +281,7 @@ wickra-backtest/
225
281
  └── fuzz/ cargo-fuzz targets (nightly)
226
282
  ```
227
283
 
228
- ## Building from source
284
+ ## Building everything from source
229
285
 
230
286
  ```bash
231
287
  # Rust core + tests + lints
@@ -308,40 +364,35 @@ than argued.
308
364
  > compare to a relative tolerance instead. None currently does, and that is a
309
365
  > property of the corpus worth keeping deliberately rather than by accident.
310
366
 
311
- ## Requirements
312
-
313
- The minimum supported version per language. The same engine kernel runs behind
314
- every binding; the C-ABI bindings that compile on install — Go (cgo) and R
315
- (`.Call`) — also need a C compiler, and Java runs with
316
- `--enable-native-access=ALL-UNNAMED`.
317
-
318
- | Language | Package | Minimum supported |
319
- |----------|-------------------------------------------|----------------------------|
320
- | Rust | crates.io · `wickra-backtest` | 1.86 (MSRV) |
321
- | Python | PyPI · `wickra-backtest` (abi3 wheel) | 3.9 (tested through 3.13) |
322
- | Node.js | npm · `wickra-backtest` (N-API 8) | 22 (tested on 22 · 24 LTS) |
323
- | WASM | npm · `wickra-backtest-wasm` | any modern JS engine |
324
- | C | `wickra_backtest.h` + library (releases) | C99 compiler |
325
- | C++ | the C ABI + optional `wickra_backtest.hpp` | C++14 compiler |
326
- | C# | NuGet · `Wickra.Backtest` | .NET 8 (`net8.0`) |
327
- | Go | module · `wickra-lib/wickra-backtest-go` | Go 1.23 (cgo) |
328
- | Java | Maven Central · `org.wickra:wickra-backtest` | Java 22 (FFM / Panama) |
329
- | R | r-universe · `wickrabacktest` | R ≥ 2.10 (Rtools on Win.) |
330
-
331
367
  ## Ecosystem
332
368
 
333
369
  Part of the [Wickra](https://github.com/wickra-lib/wickra) family — each one a
334
370
  data-driven core with a CLI and the same ten-language binding surface:
335
371
 
336
- - [**wickra**](https://github.com/wickra-lib/wickra) — the core library: 514 O(1) streaming indicators across ten languages
372
+ - [**wickra**](https://github.com/wickra-lib/wickra) — main library (Rust core + Python / Node.js / WASM bindings + a C ABI for C / C++ / C# / Go / Java / R)
373
+ - [**wickra-playground**](https://github.com/wickra-lib/wickra-playground) — a polyglot strategy playground: one StrategySpec live side by side in Python, Rust, JS and Go, entirely in the browser
337
374
  - [**wickra-exchange**](https://github.com/wickra-lib/wickra-exchange) — unified market-data + execution across ten crypto exchanges
338
- - [**wickra-backtest**](https://github.com/wickra-lib/wickra-backtest) — event-driven backtester over the Wickra core
339
375
  - [**wickra-terminal**](https://github.com/wickra-lib/wickra-terminal) — the trading terminal: a TUI and a browser renderer over the stack
340
376
  - [**wickra-screener**](https://github.com/wickra-lib/wickra-screener) — parallel multi-symbol screening over 514 streaming indicators
341
377
  - [**wickra-xray**](https://github.com/wickra-lib/wickra-xray) — market-microstructure explorer: footprint, order-book heatmap, liquidation map, funding/OI divergence
342
378
  - [**wickra-radar**](https://github.com/wickra-lib/wickra-radar) — perp-universe alert radar: OI delta, funding flip, book imbalance, liquidation clusters, OI/price divergence
343
379
  - [**wickra-copilot**](https://github.com/wickra-lib/wickra-copilot) — local market copilot grounded in real order-book, liquidation and funding microstructure
344
380
  - [**wickra-shazam**](https://github.com/wickra-lib/wickra-shazam) — match an asset's current microstructure fingerprint against its entire history
381
+ - [**wickra-benchmark**](https://github.com/wickra-lib/wickra-benchmark) — reproducible, golden-verified benchmark suite — recompute any (strategy, dataset, report) in ten languages and confirm it byte-for-byte
382
+ - [**wickra-strategy-ci**](https://github.com/wickra-lib/wickra-strategy-ci) — Jest for trading strategies: golden-pin the report, catch regressions in CI, property-test against fuzzed data
383
+ - [**wickra-verify**](https://github.com/wickra-lib/wickra-verify) — confirm or refute a claimed backtest report against its strategy and data, in ten languages
384
+ - [**wickra-proof**](https://github.com/wickra-lib/wickra-proof) — Proof-of-Backtest: deterministic (spec, data) → report + blake3 hash, recomputable byte-for-byte in ten languages
385
+ - [**wickra-zk**](https://github.com/wickra-lib/wickra-zk) — prove a backtest zero-knowledge — on-chain-verifiable performance without revealing the data or the strategy
386
+ - [**wickra-impact**](https://github.com/wickra-lib/wickra-impact) — the backtester that knows you would have moved the market: agent-based fills on the real historical L2 order book
387
+ - [**wickra-darwin**](https://github.com/wickra-lib/wickra-darwin) — evolutionary strategy search at millions of backtests per second, mutating and crossing JSON specs across the 514-indicator space
388
+ - [**wickra-gym**](https://github.com/wickra-lib/wickra-gym) — a Gymnasium-compatible, microstructure-aware backtest environment with O(1) steps for deterministic RL rollouts
389
+ - [**wickra-feature-store**](https://github.com/wickra-lib/wickra-feature-store) — OHLCV and microstructure streams into ML-ready feature matrices over 514 O(1) streaming indicators
390
+ - [**wickra-genome**](https://github.com/wickra-lib/wickra-genome) — a vector database of the whole market: every asset a 514-dim live vector, for similarity search, clustering and anomaly detection
391
+ - [**wickra-timemachine**](https://github.com/wickra-lib/wickra-timemachine) — scrub the whole market like a video — every symbol, full order book, rewound to any moment via deterministic re-fold
392
+ - [**wickra-synth**](https://github.com/wickra-lib/wickra-synth) — deterministic synthetic market microstructure: OHLCV, order book, trades and funding from a single seed
393
+ - [**wickra-compile**](https://github.com/wickra-lib/wickra-compile) — compile a strategy spec into a standalone deployable: a WASM module, a self-contained binary, or a `no_std` artifact
394
+ - [**wickra-embed**](https://github.com/wickra-lib/wickra-embed) — allocation-free, `no_std` streaming indicators for bare-metal and HFT, byte-for-byte identical to the core
395
+ - [**wickra-pico**](https://github.com/wickra-lib/wickra-pico) — the O(1) indicator core running bare-metal on a $5 Raspberry Pi Pico — the LED blinks on the EMA cross
345
396
 
346
397
  This project's own site is [backtest.wickra.org](https://backtest.wickra.org) and
347
398
  its in-browser demo [backtest-live.wickra.org](https://backtest-live.wickra.org).
@@ -392,5 +443,22 @@ the full terms.
392
443
  ---
393
444
 
394
445
  <p align="center">
395
- Built on <a href="https://github.com/wickra-lib/wickra">Wickra</a>. If it saved you time, ⭐ the repo.
446
+ <a href="https://github.com/wickra-lib/wickra-backtest">
447
+ <img alt="GitHub stars" src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-backtest/stars.svg">
448
+ </a>
449
+ <a href="https://github.com/wickra-lib/wickra-backtest/network/members">
450
+ <img alt="GitHub forks" src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-backtest/forks.svg">
451
+ </a>
452
+ <a href="https://github.com/wickra-lib/wickra-backtest/issues">
453
+ <img alt="GitHub issues" src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-backtest/issues.svg">
454
+ </a>
455
+ </p>
456
+
457
+ <p align="center">
458
+ Built on <a href="https://github.com/wickra-lib/wickra">Wickra</a>. If it saved you time, the cheapest way to say thanks is to ⭐ the repo.
459
+ </p>
460
+
461
+ <p align="center">
462
+ <img alt="wickra-backtest star history" width="640"
463
+ src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-backtest/star-history.svg">
396
464
  </p>
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "kingchenc <support@wickra.org>"
6
6
  ],
7
7
  "description": "WebAssembly bindings for the wickra-backtest streaming backtester — backtest in the browser.",
8
- "version": "0.1.0",
8
+ "version": "0.1.3",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",
Binary file