pub struct MultiAssetSingleExchangeBacktest<MD, Local, Exchange> { /* private fields */ }
Available on crate feature backtest only.
Expand description

This backtester provides multi-asset and single-exchange model backtesting, meaning all assets have the same setups for models such as asset type or queue model. However, this can be slightly faster than Backtest. If you need to configure different models for each asset, use Backtest.

Implementations§

source§

impl<MD, Local, Exchange> MultiAssetSingleExchangeBacktest<MD, Local, Exchange>
where MD: MarketDepth, Local: LocalProcessor<MD, Event>, Exchange: Processor,

source

pub fn builder() -> MultiAssetSingleExchangeBacktestBuilder<Local, Exchange>

source

pub fn new(local: Vec<Local>, exch: Vec<Exchange>) -> Self

source

pub fn goto<const WAIT_NEXT_FEED: bool>( &mut self, timestamp: i64, wait_order_response: WaitOrderResponse, ) -> Result<bool, BacktestError>

Trait Implementations§

source§

impl<MD, Local, Exchange> Bot<MD> for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>
where MD: MarketDepth, Local: LocalProcessor<MD, Event>, Exchange: Processor,

§

type Error = BacktestError

source§

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

Returns the number of assets.
source§

fn position(&self, asset_no: usize) -> f64

Returns the position you currently hold. Read more
source§

fn state_values(&self, asset_no: usize) -> &StateValues

Returns the state’s values such as balance, fee, and so on.
source§

fn depth(&self, asset_no: usize) -> &MD

Returns the MarketDepth. Read more
source§

fn last_trades(&self, asset_no: usize) -> &[Event]

Returns the last market trades. Read more
source§

fn clear_last_trades(&mut self, asset_no: Option<usize>)

Clears the last market trades from the buffer. Read more
source§

fn orders(&self, asset_no: usize) -> &HashMap<OrderId, Order>

Returns a hash map of order IDs and their corresponding Orders. 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<bool, 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<bool, Self::Error>

Places a sell order. Read more
source§

fn submit_order( &mut self, asset_no: usize, order: OrderRequest, wait: bool, ) -> Result<bool, Self::Error>

Places an order.
source§

fn cancel( &mut self, asset_no: usize, order_id: OrderId, wait: bool, ) -> Result<bool, Self::Error>

Cancels the specified order. Read more
source§

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<bool, 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<bool, Self::Error>

Wait until the next feed is received, or until timeout.
source§

fn elapse(&mut self, duration: i64) -> Result<bool, Self::Error>

Elapses the specified duration. Read more
source§

fn elapse_bt(&mut self, duration: i64) -> Result<bool, Self::Error>

Elapses time only in backtesting. In live mode, it is ignored. Read more
source§

fn close(&mut self) -> Result<(), Self::Error>

Closes this backtester or bot.
source§

fn feed_latency(&self, asset_no: usize) -> Option<(i64, i64)>

Returns the last feed’s exchange timestamp and local receipt timestamp.
source§

fn order_latency(&self, asset_no: usize) -> Option<(i64, i64, i64)>

Returns the last order’s request timestamp, exchange timestamp, and response receipt timestamp.

Auto Trait Implementations§

§

impl<MD, Local, Exchange> Freeze for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>

§

impl<MD, Local, Exchange> RefUnwindSafe for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>
where MD: RefUnwindSafe, Local: RefUnwindSafe, Exchange: RefUnwindSafe,

§

impl<MD, Local, Exchange> !Send for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>

§

impl<MD, Local, Exchange> !Sync for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>

§

impl<MD, Local, Exchange> Unpin for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>
where MD: Unpin, Local: Unpin, Exchange: Unpin,

§

impl<MD, Local, Exchange> UnwindSafe for MultiAssetSingleExchangeBacktest<MD, Local, Exchange>
where MD: UnwindSafe, Local: UnwindSafe, Exchange: UnwindSafe,

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more