Skip to content

Latest commit

 

History

History
112 lines (82 loc) · 5.12 KB

File metadata and controls

112 lines (82 loc) · 5.12 KB

Wickra Backtest — backtest and live are byte-identical

CI codecov PyPI License: MIT OR Apache-2.0

Wickra Backtest — Python


▶ Live demo: run a strategy in your browser and watch the equity curve build bar by bar — backtest-live.wickra.org · zero backend, the same engine this repository ships, compiled to WebAssembly.

Backtest and live — for Python. pip install wickra-backtest — prebuilt wheels for Linux, macOS and Windows, nothing to compile.

Streaming-native backtester for the Wickra indicator library. A strategy is a JSON spec, so the backtest values match a live run and every other language binding by construction.

Install

pip install wickra-backtest

Pre-built wheels ship for Linux, macOS and Windows — there is nothing to compile and no C library to track down.

Quick start

import wickra_backtest as wbt

spec = {
    "symbol": "BTCUSDT", "timeframe": "1h",
    "indicators": {"fast": {"type": "Ema", "params": [12]},
                   "slow": {"type": "Ema", "params": [26]}},
    "entry": {"cross_above": ["fast", "slow"]},
    "exit":  {"cross_below": ["fast", "slow"]},
    "sizing": {"type": "fixed_fraction", "fraction": 0.95},
}
report = wbt.run(opens, highs, lows, closes, spec=spec)
print(report["metrics"])

Lists, array.array and NumPy arrays all work as inputs (NumPy is not required).

The same strategy also runs one bar at a time, which is what makes a backtest and a live loop the same code path — swap the array for a socket and nothing else changes:

with wbt.StreamingBacktest(spec=spec, capital=10_000) as bt:
    for bar in feed:
        bt.step(bar.open, bar.high, bar.low, bar.close, bar.volume, bar.time)
        print(bt.num_trades, bt.latest_equity())
    report = bt.finish()

Strategies that read a side feed pass it per bar with bt.step(..., feeds={"reference": other_close}).

Benchmark

benchmarks/ reports this binding's throughput over the shared core. It measures the call overhead of PyO3, not a cross-library ratio (the same Rust core runs under every binding) — see the repository BENCHMARKS.md for the numbers, the machine and how each harness is run.

Documentation

The full guide, the spec reference and the API documentation live in the main repository and the documentation site:

The same StrategySpec runs identically across Rust, Python, Node.js, WASM, C, C++, C#, Go, Java and R — one engine kernel, byte-identical reports.

Wickra Backtest 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 support@wickra.org with a subject line starting [wickra security]. Full policy: https://github.com/wickra-lib/wickra-backtest/blob/main/SECURITY.md.

Disclaimer

Not a trading system. Backtest results are deterministic transforms of the input data — they are not financial advice and are not indicative of future performance. Any use in a live trading context is at your own risk. The software is provided as is, without warranty of any kind; see the license files for the full terms.

License

Licensed under either of Apache-2.0 or MIT at your option.