Skip to main content

BacktestResult

Struct BacktestResult 

Source
pub struct BacktestResult {
Show 41 fields pub initial_balance: f64, pub final_balance: f64, pub total_pnl: f64, pub total_trades: usize, pub winning_trades: usize, pub losing_trades: usize, pub win_rate: f64, pub max_drawdown: f64, pub max_drawdown_pct: f64, pub profit_factor: f64, pub equity_curve: Vec<(NaiveDateTime, f64)>, pub trade_log: Vec<TradeResult>, pub summary: SubsetStats, pub per_symbol: BTreeMap<String, SubsetStats>, pub per_group: BTreeMap<GroupId, SubsetStats>, pub long_stats: SubsetStats, pub short_stats: SubsetStats, pub per_close_reason: Vec<CloseReasonStats>, pub streaks: StreakStats, pub risk_metrics: RiskMetrics, pub duration_stats: Option<DurationStats>, pub monthly_returns: Vec<MonthlyReturn>, pub positions: Vec<PositionSummary>, pub total_positions: usize, pub winning_positions: usize, pub losing_positions: usize, pub position_win_rate: f64, pub future_format_version: Option<u32>, pub execution_metadata: Option<ExecutionMetadata>, pub recorded_fills: Vec<RecordedFill>, pub action_dispositions: Vec<ActionDisposition>, pub close_events: Vec<CloseEvent>, pub completed_positions: Vec<CompletedPosition>, pub open_position_snapshots: Vec<OpenPositionSnapshot>, pub pending_order_snapshots: Vec<PendingOrderSnapshot>, pub pending_order_lifecycle: Vec<PendingOrderLifecycleEvent>, pub mtm_equity_curve: Vec<EquityPoint>, pub mtm_output_summary: MtmOutputSummary, pub mtm_max_drawdown: Option<f64>, pub mtm_max_drawdown_pct: Option<f64>, pub provider_evaluation: Option<EvaluationReport>,
}
Expand description

Aggregate backtest statistics produced by BacktestRunner.

Fields§

§initial_balance: f64

Starting account balance.

§final_balance: f64

Final account balance (initial + total realized P&L).

§total_pnl: f64

Sum of all realized P&L.

§total_trades: usize

Number of completed trades (full + partial closes).

§winning_trades: usize

Number of trades with positive P&L.

§losing_trades: usize

Number of trades with negative P&L.

§win_rate: f64

winning_trades / total_trades (0.0 if no trades).

§max_drawdown: f64

Largest peak-to-trough drawdown in absolute terms.

§max_drawdown_pct: f64

Largest peak-to-trough drawdown as a percentage of the peak.

§profit_factor: f64

Sum of winning P&L / abs(sum of losing P&L). f64::INFINITY if no losers.

§equity_curve: Vec<(NaiveDateTime, f64)>

Equity value at each trade close: (timestamp, balance).

§trade_log: Vec<TradeResult>

Full trade log (one entry per close event).

§summary: SubsetStats

Full aggregate stats in SubsetStats form.

§per_symbol: BTreeMap<String, SubsetStats>

Stats broken down by symbol.

§per_group: BTreeMap<GroupId, SubsetStats>

Stats broken down by group (empty if no positions were grouped).

§long_stats: SubsetStats

Stats for long (Buy) trades.

§short_stats: SubsetStats

Stats for short (Sell) trades.

§per_close_reason: Vec<CloseReasonStats>

Breakdown by close reason, sorted by count descending.

§streaks: StreakStats

Consecutive win/loss streak analysis.

§risk_metrics: RiskMetrics

Risk-adjusted return metrics (Sharpe, Sortino, Calmar, drawdown duration).

§duration_stats: Option<DurationStats>

Trade holding time statistics. None if no trades.

§monthly_returns: Vec<MonthlyReturn>

Monthly P&L breakdown.

§positions: Vec<PositionSummary>

Per-position summaries. Legacy reports aggregate close-event rows; FutureQuote reports include only campaigns present in completed_positions.

§total_positions: usize

Number of unique legacy positions or completed FutureQuote campaigns.

§winning_positions: usize

Winning legacy positions or epsilon-classified FutureQuote campaigns.

§losing_positions: usize

Losing legacy positions or epsilon-classified FutureQuote campaigns.

§position_win_rate: f64

Position-level win rate: winning_positions / total_positions.

§future_format_version: Option<u32>§execution_metadata: Option<ExecutionMetadata>§recorded_fills: Vec<RecordedFill>§action_dispositions: Vec<ActionDisposition>§close_events: Vec<CloseEvent>§completed_positions: Vec<CompletedPosition>§open_position_snapshots: Vec<OpenPositionSnapshot>§pending_order_snapshots: Vec<PendingOrderSnapshot>§pending_order_lifecycle: Vec<PendingOrderLifecycleEvent>§mtm_equity_curve: Vec<EquityPoint>§mtm_output_summary: MtmOutputSummary§mtm_max_drawdown: Option<f64>§mtm_max_drawdown_pct: Option<f64>§provider_evaluation: Option<EvaluationReport>

Implementations§

Source§

impl BacktestResult

Source

pub fn from_trade_log(initial_balance: f64, trade_log: Vec<TradeResult>) -> Self

Build aggregate statistics from a trade log.

Source

pub fn from_future_artifacts(artifacts: FutureBacktestArtifacts) -> Self

Build legacy close-event rows plus completed-position FutureQuoteV1 statistics and additive artifacts using the backward-compatible all-sections report.

Source

pub fn from_future_artifacts_with_options( artifacts: FutureBacktestArtifacts, evaluation_options: EvaluationOptions, ) -> Self

Build a FutureQuoteV1 result and apply typed provider-evaluation selection.

Trait Implementations§

Source§

impl Clone for BacktestResult

Source§

fn clone(&self) -> BacktestResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BacktestResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BacktestResult

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for BacktestResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for BacktestResult

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V