#[non_exhaustive]pub struct BenchmarkMetrics {
pub symbol: String,
pub benchmark_return_pct: f64,
pub buy_and_hold_return_pct: f64,
pub alpha: f64,
pub beta: f64,
pub information_ratio: f64,
}Expand description
Comparison of strategy performance against a benchmark.
Populated when a benchmark symbol is supplied to backtest_with_benchmark.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.symbol: StringBenchmark symbol (e.g. "SPY")
benchmark_return_pct: f64Buy-and-hold return of the benchmark over the same period (percentage)
buy_and_hold_return_pct: f64Buy-and-hold return of the backtested symbol over the same period (percentage)
alpha: f64Jensen’s Alpha: annualised strategy excess return over the benchmark (CAPM).
Computed as strategy_ann - rf - β × (benchmark_ann - rf) on the
timestamp-aligned subset of strategy and benchmark returns.
§Accuracy Caveat
Annualisation uses aligned_bars / bars_per_year to estimate elapsed
years. If the strategy and benchmark candles have different sampling
frequencies (e.g., daily strategy vs. weekly benchmark), the aligned
subset contains far fewer bars than the full backtest period and the
per-year estimate will be wrong — both strategy_ann and benchmark_ann
are inflated by the same factor, but the risk-free rate is always the
true annual rate, making alpha unreliable.
For accurate alpha, supply benchmark candles with the same interval as the strategy candles.
beta: f64Beta: sensitivity of strategy returns to benchmark movements
information_ratio: f64Information ratio: excess return per unit of tracking error (annualised)
Trait Implementations§
Source§impl Clone for BenchmarkMetrics
impl Clone for BenchmarkMetrics
Source§fn clone(&self) -> BenchmarkMetrics
fn clone(&self) -> BenchmarkMetrics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BenchmarkMetrics
impl Debug for BenchmarkMetrics
Source§impl<'de> Deserialize<'de> for BenchmarkMetrics
impl<'de> Deserialize<'de> for BenchmarkMetrics
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BenchmarkMetrics
impl RefUnwindSafe for BenchmarkMetrics
impl Send for BenchmarkMetrics
impl Sync for BenchmarkMetrics
impl Unpin for BenchmarkMetrics
impl UnsafeUnpin for BenchmarkMetrics
impl UnwindSafe for BenchmarkMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more