Skip to main content

Crate wickra_benchmark_core

Crate wickra_benchmark_core 

Source
Expand description

§wickra-benchmark-core

The deterministic core of wickra-benchmark: a curated suite of (strategy, dataset, expected report, hash) cases you recompute and confirm byte-for-byte. Given a BenchmarkCase, run_case recomputes the report from the embedded strategy and candle data with the pinned wickra-backtest engine, hashes it with the same canonicalization wickra-proof uses, and reports two independent booleans: passed (the recomputed report is byte-exact equal to the frozen expected) and hash_match (its canonical hash equals expected_hash).

run_suite (path-based, for the CLI) and run_suite_inline (data supplied inline, for the FFI boundary) fan out over a Suite and re-sort the results by id, so a SuiteReport is byte-identical across all ten language bindings and between the parallel (rayon) and sequential (WASM) runners. Benchmark exposes the command_json boundary the bindings forward verbatim; canonicalize/hash are the single source of hash stability.

Structs§

BacktestReport
The result of a backtest run.
Benchmark
A stateless benchmark handle. It carries no state — the case, suite and data arrive with each command — but is handle-shaped so the ten language bindings share the same surface as the other Wickra products.
BenchmarkCase
A single golden-verified case. Its strategy is an embedded wickra-backtest StrategySpec (kept as raw JSON so wickra-benchmark-core stays decoupled from the engine’s struct internals across the FFI boundary); its expected report and expected_hash are frozen when the case is blessed and are byte-exact thereafter. Running the case recomputes the report from strategy + the dataset and checks it against both.
Candle
One OHLCV bar. time is the bar’s open time (engine-defined epoch unit; it is passed straight through to indicators that need a timestamp).
CaseResult
The outcome of running one case: whether the recomputed report matches the expectation (passed) and its frozen hash (hash_match), plus the recomputed report and its hash for inspection.
Config
Reserved runner options. Currently carries no fields; parsing {} yields the default.
StrategySpec
A complete strategy specification.
Suite
A curated suite of cases. The case order in the file is irrelevant — the runner sorts results by id — but every id must be unique.
SuiteReport
The result of running a whole suite: the per-case results (sorted by id) and the pass/fail tally. A case counts as passing only when it both passed and hash_match.

Enums§

Error
Everything that can go wrong while running a case or a suite.

Functions§

canonicalize
Produce the canonical string form of any serializable value (a report, a case, or a suite report). The value is first converted to a serde_json::Value and then canonicalized, so the output is independent of struct field order and depends only on the data.
hash
The lowercase 64-hex blake3 of a canonical string (no prefix). Pairs with canonicalize: hash(&canonicalize(x)?) is the stable digest of x.
hash_report
The canonical blake3 hash of a serializable value (typically a BacktestReport): hash(&canonicalize(value)?). This is exactly how a case’s expected_hash is defined, so a recomputed report that matches the expectation reproduces the frozen hash.
load_candles
Load a candle CSV (time,open,high,low,close,volume, an optional header row, volume optional per row). Rows are trusted repo data; a malformed row is a Error::Data.
run_case
Recompute case’s report from its strategy and the supplied candle data, then check it against the frozen expectation. Returns a CaseResult with two independent booleans: passed (the recomputed report is byte-exact equal to case.expected) and hash_match (its canonical hash equals case.expected_hash).
run_suite
Run every case in suite, loading each case’s dataset from data_root/<dataset_ref> as CSV. Used by the CLI, which has filesystem access.
run_suite_inline
Run every case in suite against datasets supplied inline, keyed by dataset_ref. Used across the FFI boundary, which has no filesystem. Must produce the same report as run_suite for the same data.
version
The wickra-benchmark-core crate version.

Type Aliases§

Result
The result of a wickra-benchmark-core operation.