pub struct Backtest {Show 16 fields
pub initial_capital: f64,
pub equity: Vec<f64>,
pub trades: Vec<Trade>,
pub net_profit: f64,
pub open_profit: f64,
pub gross_profit: f64,
pub gross_loss: f64,
pub max_drawdown: f64,
pub max_runup: f64,
pub win_trades: usize,
pub loss_trades: usize,
pub even_trades: usize,
pub position_size: f64,
pub mark_price: f64,
pub halted: Option<u64>,
pub timeframe: Timeframe,
}Expand description
What a strategy produced over a run: the equity curve, the trade log, and
the summary values Pine exposes as strategy.*. Field names follow Pine’s.
Fields§
§initial_capital: f64§equity: Vec<f64>Account value at each bar’s close.
trades: Vec<Trade>Every trade, closed ones (in the order they closed) before still-open
ones. exit_price is None while open; profit(price) values it.
net_profit: f64§open_profit: f64§gross_profit: f64§gross_loss: f64Total loss of the losing trades, as a positive magnitude.
max_drawdown: f64§max_runup: f64§win_trades: usize§loss_trades: usize§even_trades: usize§position_size: f64Signed: positive long, negative short.
mark_price: f64The last bar’s close, at which open trades are valued.
halted: Option<u64>The bar the run halted on if a rest-of-run risk rule fired
(strategy.risk.max_drawdown / max_cons_loss_days)
timeframe: TimeframeThe chart timeframe, so per-bar figures can be annualised.
Implementations§
Source§impl Backtest
impl Backtest
Sourcepub fn final_equity(&self) -> f64
pub fn final_equity(&self) -> f64
The final account value, or the initial capital if no bar ran.
Sourcepub fn closed_trades(&self) -> impl Iterator<Item = &Trade>
pub fn closed_trades(&self) -> impl Iterator<Item = &Trade>
The trades already closed, in the order they closed.
Sourcepub fn open_trades(&self) -> impl Iterator<Item = &Trade>
pub fn open_trades(&self) -> impl Iterator<Item = &Trade>
The trades still open at the end of the run.
Sourcepub fn generate_metrics(&self) -> Metrics
pub fn generate_metrics(&self) -> Metrics
Standard summary metrics derived from the equity curve and trade log.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Backtest
impl RefUnwindSafe for Backtest
impl Send for Backtest
impl Sync for Backtest
impl Unpin for Backtest
impl UnsafeUnpin for Backtest
impl UnwindSafe for Backtest
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.