Skip to main content

Crate wickra_backtest_core

Crate wickra_backtest_core 

Source
Expand description

§wickra-backtest-core

Streaming-native, event-driven backtest engine built on the wickra-core indicator kernels.

The engine is feed-agnostic: it consumes a stream of bars and a data-driven StrategySpec, evaluates entry/exit rules over the exact same O(1) indicator updates that power live Wickra, and produces a BacktestReport. Because the indicator math is identical to live, and the strategy is data (JSON) rather than code, a backtest and a live run over the same spec produce identical signals — across all Wickra language bindings.

This crate is the shared engine core, and wickra-backtest is the facade over it. Live execution is not a second crate: it is the same engine driven one bar at a time through StreamingBacktest instead of over a stored series, so “backtest == live” holds because there is one implementation, not because two of them agree.

Re-exports§

pub use data::Candle;
pub use data::CrossSection;
pub use data::CrossSectionMember;
pub use data::DerivativesTick;
pub use data::Level;
pub use data::OrderBook;
pub use data::TradePrint;
pub use data::TradeSide;
pub use engine::run;
pub use engine::run_stream;
pub use engine::run_with_capital;
pub use engine::run_with_cross_section;
pub use engine::run_with_deriv;
pub use engine::run_with_orderbook;
pub use engine::run_with_ref;
pub use engine::run_with_trades;
pub use engine::Feeds;
pub use engine::StreamingBacktest;
pub use engine::DEFAULT_CAPITAL;
pub use error::BacktestError;
pub use error::Result;
pub use metrics::Metrics;
pub use portfolio::Trade;
pub use registry::EvalIndicator;
pub use report::BacktestReport;
pub use report::EquityPoint;
pub use report::REPORT_SCHEMA_VERSION;
pub use request::run_json;
pub use request::RunRequest;
pub use request::StepFeeds;
pub use request::StepRequest;
pub use spec::Condition;
pub use spec::Costs;
pub use spec::Execution;
pub use spec::Feed;
pub use spec::FillTiming;
pub use spec::IndicatorSpec;
pub use spec::IntPredicate;
pub use spec::Operand;
pub use spec::OperandExpr;
pub use spec::OrderType;
pub use spec::PriceField;
pub use spec::Risk;
pub use spec::Sizing;
pub use spec::Slippage;
pub use spec::StrategySpec;
pub use spec::SPEC_VERSION;

Modules§

data
Market-data input types fed to the engine.
engine
The event-driven backtest loop.
error
Error types for the backtest engine.
metrics
Performance metrics computed from the equity curve and the trade log.
portfolio
Cash/position accounting for one signed position (long qty > 0 or short qty < 0).
registry
Indicator registry: constructs wickra-core indicators by name and wraps them behind a uniform, object-safe EvalIndicator the engine can drive from a Candle.
report
The backtest result: metrics, the trade log and the equity curve.
request
A single JSON request bundling candles, the strategy spec and optional feeds — the uniform entry point the language bindings call, so every binding can run any feed combination by passing one JSON document.
rules
Evaluation of the strategy DSL (Operand / Condition) against the per-bar history. Operands resolve to a number (or None when an indicator is still warming up); conditions resolve to a boolean (false when any operand is missing). Cross conditions compare the current bar with the previous one.
spec
The data-driven strategy specification (StrategySpec).

Functions§

strategy_spec_schema
The JSON Schema for StrategySpec, pretty-printed. Editors and tooling can validate strategy specs against it; the committed schema/strategy_spec.schema.json is generated from this.
version
The crate version, surfaced for diagnostics and binding parity checks.