pub struct BacktestConfig {
pub initial_balance: f64,
pub close_on_finish: bool,
pub fill_model: FillModel,
pub contract_sizes: HashMap<String, f64>,
pub sizing: Option<SizingPolicy>,
pub symbol_specs: HashMap<String, SymbolSpec>,
pub instrument_manifest: Option<ReplayInstrumentManifest>,
pub bar_spread_fallback: HashMap<String, f64>,
pub run_tags: BTreeMap<String, String>,
pub costs: HashMap<String, InstrumentCosts>,
}Expand description
Configuration for a backtest run.
Fields§
§initial_balance: f64Starting account balance.
close_on_finish: boolIf true, all remaining open positions are closed at market when the
data feed is exhausted.
fill_model: FillModelHow fill conditions and rule triggers interpret price quotes.
Defaults to FillModel::BidAsk — the most realistic model that
uses the appropriate side of the spread for each operation.
contract_sizes: HashMap<String, f64>Per-symbol contract size (point value) for P&L calculation.
Maps symbol name → contract size. For forex, this is typically
lot_base_units from SymbolSpec (e.g. 100_000 for majors).
For gold (XAUUSD) it’s 100 (1 lot = 100 oz).
When a symbol is absent from this map the multiplier defaults to 1.0,
which preserves backward compatibility with all existing tests.
sizing: Option<SizingPolicy>Optional position sizing policy. When set, entry signal sizes are recalculated after profile transformation using symbol metadata.
symbol_specs: HashMap<String, SymbolSpec>Symbol specs for sizing calculations. Populated by the server from the symbol registry. Empty when no sizing policy is configured.
instrument_manifest: Option<ReplayInstrumentManifest>Optional explicit instrument specifications and stored-series bindings pinned for this run.
bar_spread_fallback: HashMap<String, f64>Per-symbol symmetric bid/ask spread in price units, applied to bars that carry no recorded spread.
Stored bars normally carry the average spread observed while they formed. This map covers feeds that cannot supply one; without it such bars execute at a zero spread, and the run reports how often that happened.
Caller-supplied labels recorded with the run and attached to every completed position.
A batch of runs uses these to say what distinguishes one run from another, such as the parameter values or the data window, so that evaluation can break results down by them afterwards. They are inert: the engine never reads a tag to decide anything. Keys and values are bounded and validated before replay starts, and they are kept separate from the engine’s own diagnostic tags so neither can overwrite the other.
costs: HashMap<String, InstrumentCosts>Per-symbol commission and swap specification.
An empty map charges nothing and reproduces runs made before costs existed. Point-denominated swap additionally requires a matching symbol_specs entry, because the price point size comes from its digit count.