pub struct PartialFillExchange<AT, LM, QM, MD, FM>{ /* private fields */ }Available on crate feature
backtest only.Expand description
The exchange model with partial fills.
- Support order types: OrdType::Limit
- Support time-in-force:
TimeInForce::GTC,TimeInForce::FOK,TimeInForce::IOC,TimeInForce::GTX
Conditions for Full Execution Buy order in the order book
- Your order price >= the best ask price
- Your order price > sell trade price
Sell order in the order book
- Your order price <= the best bid price
- Your order price < buy trade price
Conditions for Partial Execution Buy order in the order book
- Filled by (remaining) sell trade quantity: your order is at the front of the queue && your order price == sell trade price
Sell order in the order book
- Filled by (remaining) buy trade quantity: your order is at the front of the queue && your order price == buy trade price
Liquidity-Taking Order Liquidity-taking orders will be executed based on the quantity of the order book, even though the best price and quantity do not change due to your execution. Be aware that this may cause unrealistic fill simulations if you attempt to execute a large quantity.
General Comment Simulating partial fills accurately can be challenging, as they may indicate potential market impact. The rule of thumb is to ensure that your backtesting results align with your live results. (more comment will be added…)
Implementations§
Source§impl<AT, LM, QM, MD, FM> PartialFillExchange<AT, LM, QM, MD, FM>
impl<AT, LM, QM, MD, FM> PartialFillExchange<AT, LM, QM, MD, FM>
Trait Implementations§
Source§impl<AT, LM, QM, MD, FM> Processor for PartialFillExchange<AT, LM, QM, MD, FM>where
AT: AssetType,
LM: LatencyModel,
QM: QueueModel<MD>,
MD: MarketDepth + L2MarketDepth,
FM: FeeModel,
impl<AT, LM, QM, MD, FM> Processor for PartialFillExchange<AT, LM, QM, MD, FM>where
AT: AssetType,
LM: LatencyModel,
QM: QueueModel<MD>,
MD: MarketDepth + L2MarketDepth,
FM: FeeModel,
Source§fn initialize_data(&mut self) -> Result<i64, BacktestError>
fn initialize_data(&mut self) -> Result<i64, BacktestError>
Prepares to process the data. This is invoked when the backtesting is initiated.
If successful, returns the timestamp of the first event.
Source§fn process_data(&mut self) -> Result<(i64, i64), BacktestError>
fn process_data(&mut self) -> Result<(i64, i64), BacktestError>
Processes the data. This is invoked when the backtesting time reaches the timestamp of the
event to be processed in the data.
If successful, returns the timestamp of the next event.
Source§fn process_recv_order(
&mut self,
timestamp: i64,
_wait_resp_order_id: Option<OrderId>,
) -> Result<bool, BacktestError>
fn process_recv_order( &mut self, timestamp: i64, _wait_resp_order_id: Option<OrderId>, ) -> Result<bool, BacktestError>
Processes an order upon receipt. This is invoked when the backtesting time reaches the order
receipt timestamp.
Returns Ok(true) if the order with
wait_resp_order_id is received and processed.Source§fn earliest_recv_order_timestamp(&self) -> i64
fn earliest_recv_order_timestamp(&self) -> i64
Returns the foremost timestamp at which an order is to be received by this processor.
Source§fn earliest_send_order_timestamp(&self) -> i64
fn earliest_send_order_timestamp(&self) -> i64
Returns the foremost timestamp at which an order sent by this processor is to be received by
the corresponding processor.
Auto Trait Implementations§
impl<AT, LM, QM, MD, FM> Freeze for PartialFillExchange<AT, LM, QM, MD, FM>
impl<AT, LM, QM, MD, FM> !RefUnwindSafe for PartialFillExchange<AT, LM, QM, MD, FM>
impl<AT, LM, QM, MD, FM> !Send for PartialFillExchange<AT, LM, QM, MD, FM>
impl<AT, LM, QM, MD, FM> !Sync for PartialFillExchange<AT, LM, QM, MD, FM>
impl<AT, LM, QM, MD, FM> Unpin for PartialFillExchange<AT, LM, QM, MD, FM>
impl<AT, LM, QM, MD, FM> !UnwindSafe for PartialFillExchange<AT, LM, QM, MD, FM>
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