Skip to content

Quickstart

You have two ways to run a backtest: in your browser (zero install) or natively in Rust. Start with whichever fits.

Option A — the browser playground (0 minutes)

Open the interactive playground. It loads the WASM build of the engine plus a small synthetic dataset and runs a real backtest locally — nothing is sent to a server. Edit the strategy, press Run, and read the equity curve and metrics. This is the fastest way to get a feel for lemon.

Option B — native Rust (a few minutes)

You need a recent stable Rust toolchain.

Terminal window
git clone https://github.com/citrusquant/citrusquant
cd citrusquant
cargo run -p yuzu-core --example basic_backtest

That example is self-contained and readable top to bottom: it builds a tiny price panel, authors a strategy in lemon, runs the backtest, and prints headline metrics. It’s the best 40 lines to read first.

Use it as a library

Add the core crate:

Terminal window
cargo add yuzu-core lemon-lang

The top-level entry point is:

yuzu_core::run_backtest(spec_json, ctx, price_key, cfg) -> Result<Report, EngineError>
  • spec_json — the JSON Expr tree, produced by lemon::parse(source).
  • ctx — an EvalContext: your numeric panels keyed by series name, plus an optional symbol → industry map.
  • price_key — which series the backtest marks off (usually "close").
  • cfg — a BacktestConfig (fees, slippage, stops, benchmark, …).

See Your first strategy to build the spec, and Bring your own data to build the ctx.

What you get back

A Report — an equity curve (dates + equity), the trade list, and a large metrics block. Everything the UI draws is computed by the engine; the frontend only renders it.

Next steps