pub struct Backtest {Show 14 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,
}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.
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.
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
Mutably borrows from an owned value. Read more