pub struct Backtest<MD> { /* private fields */ }
Available on crate feature
backtest
only.Expand description
This backtester provides multi-asset and multi-exchange model backtesting, allowing you to
configure different setups such as queue models or asset types for each asset. However, this may
result in slightly slower performance compared to Backtest
.
Implementations§
Source§impl<MD> Backtest<MD>where
MD: MarketDepth,
impl<MD> Backtest<MD>where
MD: MarketDepth,
pub fn builder() -> BacktestBuilder<MD>
pub fn new( local: Vec<Box<dyn LocalProcessor<MD>>>, exch: Vec<Box<dyn Processor>>, reader: Vec<Reader<Event>>, ) -> Self
pub fn goto_end(&mut self) -> Result<ElapseResult, BacktestError>
Trait Implementations§
Source§impl<MD> Bot<MD> for Backtest<MD>where
MD: MarketDepth,
impl<MD> Bot<MD> for Backtest<MD>where
MD: MarketDepth,
type Error = BacktestError
Source§fn current_timestamp(&self) -> i64
fn current_timestamp(&self) -> i64
In backtesting, this timestamp reflects the time at which the backtesting is conducted
within the provided data. In a live bot, it’s literally the current local timestamp.
Source§fn num_assets(&self) -> usize
fn num_assets(&self) -> usize
Returns the number of assets.
Source§fn state_values(&self, asset_no: usize) -> &StateValues
fn state_values(&self, asset_no: usize) -> &StateValues
Returns the state’s values such as balance, fee, and so on.
Source§fn clear_last_trades(&mut self, asset_no: Option<usize>)
fn clear_last_trades(&mut self, asset_no: Option<usize>)
Clears the last market trades from the buffer. Read more
Source§fn submit_buy_order(
&mut self,
asset_no: usize,
order_id: OrderId,
price: f64,
qty: f64,
time_in_force: TimeInForce,
order_type: OrdType,
wait: bool,
) -> Result<ElapseResult, Self::Error>
fn submit_buy_order( &mut self, asset_no: usize, order_id: OrderId, price: f64, qty: f64, time_in_force: TimeInForce, order_type: OrdType, wait: bool, ) -> Result<ElapseResult, Self::Error>
Places a buy order. Read more
Source§fn submit_sell_order(
&mut self,
asset_no: usize,
order_id: OrderId,
price: f64,
qty: f64,
time_in_force: TimeInForce,
order_type: OrdType,
wait: bool,
) -> Result<ElapseResult, Self::Error>
fn submit_sell_order( &mut self, asset_no: usize, order_id: OrderId, price: f64, qty: f64, time_in_force: TimeInForce, order_type: OrdType, wait: bool, ) -> Result<ElapseResult, Self::Error>
Places a sell order. Read more
Source§fn submit_order(
&mut self,
asset_no: usize,
order: OrderRequest,
wait: bool,
) -> Result<ElapseResult, Self::Error>
fn submit_order( &mut self, asset_no: usize, order: OrderRequest, wait: bool, ) -> Result<ElapseResult, Self::Error>
Places an order.
Source§fn modify(
&mut self,
asset_no: usize,
order_id: OrderId,
price: f64,
qty: f64,
wait: bool,
) -> Result<ElapseResult, Self::Error>
fn modify( &mut self, asset_no: usize, order_id: OrderId, price: f64, qty: f64, wait: bool, ) -> Result<ElapseResult, Self::Error>
Modifies an open order. Read more
Source§fn cancel(
&mut self,
asset_no: usize,
order_id: OrderId,
wait: bool,
) -> Result<ElapseResult, Self::Error>
fn cancel( &mut self, asset_no: usize, order_id: OrderId, wait: bool, ) -> Result<ElapseResult, Self::Error>
Cancels an open order. Read more
Source§fn clear_inactive_orders(&mut self, asset_no: Option<usize>)
fn clear_inactive_orders(&mut self, asset_no: Option<usize>)
Clears inactive orders from the local orders whose status is neither
Status::New
nor
Status::PartiallyFilled
.Source§fn wait_order_response(
&mut self,
asset_no: usize,
order_id: OrderId,
timeout: i64,
) -> Result<ElapseResult, BacktestError>
fn wait_order_response( &mut self, asset_no: usize, order_id: OrderId, timeout: i64, ) -> Result<ElapseResult, BacktestError>
Waits for the response of the order with the given order ID until timeout.
Source§fn wait_next_feed(
&mut self,
include_order_resp: bool,
timeout: i64,
) -> Result<ElapseResult, Self::Error>
fn wait_next_feed( &mut self, include_order_resp: bool, timeout: i64, ) -> Result<ElapseResult, Self::Error>
Wait until the next feed is received, or until timeout.
Source§fn elapse(&mut self, duration: i64) -> Result<ElapseResult, Self::Error>
fn elapse(&mut self, duration: i64) -> Result<ElapseResult, Self::Error>
Elapses the specified duration. Read more
Source§fn elapse_bt(&mut self, duration: i64) -> Result<ElapseResult, Self::Error>
fn elapse_bt(&mut self, duration: i64) -> Result<ElapseResult, Self::Error>
Elapses time only in backtesting. In live mode, it is ignored. Read more
Auto Trait Implementations§
impl<MD> Freeze for Backtest<MD>
impl<MD> !RefUnwindSafe for Backtest<MD>
impl<MD> !Send for Backtest<MD>
impl<MD> !Sync for Backtest<MD>
impl<MD> Unpin for Backtest<MD>
impl<MD> !UnwindSafe for Backtest<MD>
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