Skip to main content

Crate qs_backtest

Crate qs_backtest 

Source
Expand description

qs-backtest — Backtesting engine for the quant-system workspace.

This crate provides tools for replaying historical market data through the qs_core::TradeEngine to evaluate trading strategies and predefined signal sets.

§Two modes of operation

  1. Strategy-driven — implement the Strategy trait; the runner feeds market data tick-by-tick and your strategy decides when to act.
  2. Signal replay — provide a Vec<Signal> with timestamps; the runner injects them at the correct moments while replaying price data.

§Key types

TypePurpose
BacktestRunnerOrchestrates the backtest loop (both modes)
BacktestExecutorTracks simulated fills, positions, and P&L
BacktestResultFinal report — P&L, win rate, drawdown, trade log
DataFeedTrait for sequential market event sources
StrategyTrait for strategy-driven backtests

Re-exports§

pub use artifacts::CloseEvent;
pub use artifacts::CompletedPosition;
pub use artifacts::ExecutionMetadata;
pub use artifacts::FutureBacktestArtifacts;
pub use artifacts::NetPnlOutcome;
pub use artifacts::OpenPositionSnapshot;
pub use artifacts::PendingOrderLifecycleEvent;
pub use artifacts::PendingOrderLifecycleState;
pub use artifacts::PendingOrderSnapshot;
pub use artifacts::RecordedFill;
pub use artifacts::RiskBasisStatus;
pub use artifacts::RiskTranche;
pub use data_feed::DataFeed;
pub use data_feed::MarketEvent;
pub use data_feed::VecFeed;
pub use economic_support::EconomicSupportError;
pub use economic_support::LEGACY_ECONOMIC_GUARD_ID;
pub use economic_support::LegacyEconomicModel;
pub use economic_support::SupportedLegacyEconomics;
pub use economic_support::resolve_legacy_economics;
pub use evaluation::BootstrapConfig;
pub use evaluation::BreakdownDimension;
pub use evaluation::EvaluationContext;
pub use evaluation::EvaluationOptions;
pub use evaluation::EvaluationReport;
pub use evaluation::EvaluationSection;
pub use evaluation::GroupFilter;
pub use evaluation::PositionFilter;
pub use evaluation::PositionSide;
pub use executor::BacktestExecutor;
pub use future_executor::FutureExecutor;
pub use mtm::DEFAULT_MTM_MAX_POINTS;
pub use mtm::MAX_MTM_MAX_POINTS;
pub use mtm::MIN_MTM_MAX_POINTS;
pub use mtm::MtmCurveCollector;
pub use mtm::MtmOutputPolicy;
pub use mtm::MtmOutputPolicyError;
pub use mtm::MtmOutputSummary;
pub use profile::ProfileError;
pub use profile::ProfileRegistry;
pub use profile::ProfileRegistryError;
pub use report::BacktestResult;
pub use report::CloseReasonStats;
pub use report::DurationStats;
pub use report::MonthlyReturn;
pub use report::PositionSummary;
pub use report::RiskMetrics;
pub use report::StreakStats;
pub use report::SubsetStats;
pub use report::TradeResult;
pub use runner::BacktestRunner;
pub use runner::FutureQuoteConfig;
pub use runner::ReplayCancelled;
pub use runner::ReplayProgress;
pub use runner::StreamingReplayError;
pub use strategy::Strategy;

Modules§

artifacts
Additive, serializable artifacts for future backtest runners.
currency
Compatibility re-exports for currency-conversion domain types moved to qs-core.
data_feed
Data feed abstraction for backtesting.
economic_support
Fail-closed capability checks for the legacy backtest economic model.
evaluation
Additive, report-independent provider evaluation.
executor
Backtest executor — simulates fills and tracks P&L.
future_executor
Fill-authoritative accounting for the FutureQuoteV1 replay path.
ledger
Terminal action lifecycle accounting.
mtm
Deterministic mark-to-market output collection.
portfolio
Quote-aware portfolio snapshots and online account accounting.
profile
Backtest compatibility surface and configuration loader for core management profiles.
report
Backtest reporting — trade log, aggregate statistics, and enhanced analytics.
runner
Backtest runner — orchestrates the backtest loop.
sizing
Compatibility re-exports for position-sizing domain types moved to qs-core.
strategy
Strategy trait for strategy-driven backtests.

Structs§

ConversionLeg
One directed currency-conversion leg.
ConversionLegAudit
Auditable execution details for one route leg.
ConversionQuoteBook
Historical FX tick store with causal, staleness-bounded lookup.
ConversionResult
Result of one identity, direct, inverse, or two-leg conversion.
FxPair
One available FX symbol and its registered currencies.
ManagementProfile
A named management profile that resolves raw entry signals before sizing.
ResolvedEntry
A resolved entry that retains risk intent without assigning concrete lots.
RunCurrencyPlan
Immutable, validated currency handoff for one backtest run.
TargetResolution
Metadata describing how signal targets were selected and weighted.

Enums§

ConversionError
Errors produced by route resolution and quote-backed conversion.
ConversionPriceSide
Quote side used to execute one signed conversion leg.
ConversionRoute
Deterministic route selected from a caller-provided available-symbol set.
FxPairDirection
Direction in which an FX pair is used for a conversion leg.
PositionRef
How a management signal references its target position(s).
ProfileApplicationError
Strict validation failures returned by the canonical entry resolvers.
ProfileValidationError
Errors returned while validating a management profile definition.
QuoteValidationError
Validation failure for a tick quote submitted to the quote book.
RawSignal
A raw signal from an external source — entry or management.
RuleConfigDef
Profile-specific rule definition with #[serde(tag = "type")] for TOML.
RunCurrencyPlanError
Validation errors for an immutable run currency plan.
StoplossMode
How the profile handles the stoploss from the raw signal.
TargetSelection
Which 1-based target indices participate in strict target resolution.

Traits§

PositionResolver
Resolves a PositionRef to concrete position ID(s) using engine state.

Functions§

allocate_target_units
Convert an aligned floating lot size to steps and delegate to allocate_target_steps.
resolve_conversion_route
Resolve an identity, direct, inverse, or deterministic two-leg FX route.
resolve_fx_pair
Resolve one directed FX pair from the available-symbol set.
resolve_signal
Resolve a non-entry RawSignal into concrete Action(s).
resolve_unprofiled_entry
Strictly resolve an entry without a management profile.