Skip to main content

OrderEmulator

Struct OrderEmulator 

Source
pub struct OrderEmulator { /* private fields */ }

Implementations§

Source§

impl OrderEmulator

Source

pub fn new(clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>) -> Self

Source

pub fn register_msgbus_handlers(emulator: &Rc<RefCell<Self>>)

Source

pub fn set_on_event_handler(&mut self, handler: TypedHandler<OrderEventAny>)

Source

pub fn cache_submit_order_command(&mut self, command: SubmitOrder)

Caches a submit order command for emulation tracking.

Source

pub fn subscribed_quotes(&self) -> Vec<InstrumentId>

Source

pub fn subscribed_trades(&self) -> Vec<InstrumentId>

Source

pub fn subscribed_strategy_count(&self) -> usize

Source

pub fn monitored_position_count(&self) -> usize

Source

pub fn get_submit_order_commands(&self) -> AHashMap<ClientOrderId, SubmitOrder>

Source

pub fn get_matching_core( &self, instrument_id: &InstrumentId, ) -> Option<OrderMatchingCore>

Source

pub fn start(&mut self)

Source

pub fn stop(&self)

Source

pub fn reset(&mut self)

Source

pub fn dispose(&mut self)

Source

pub fn on_start(&mut self) -> Result<()>

Reactivates emulated orders from cache on start.

§Errors

Returns an error if processing fails.

Source

pub fn on_event(&mut self, event: &OrderEventAny)

Source

pub const fn on_stop(&self)

Source

pub fn on_reset(&mut self)

Source

pub fn on_dispose(&mut self)

Source

pub fn execute(&mut self, command: TradingCommand)

Source

pub fn handle_submit_order(&mut self, command: &SubmitOrder)

§Panics

Panics if the emulation trigger type is not set or if the order is not in the cache.

Source

pub fn handle_cancel_order(&mut self, command: CancelOrder)

Source

pub fn update_order(&mut self, order: &mut OrderAny, new_quantity: Quantity)

Source

pub fn on_order_book_deltas(&mut self, deltas: &OrderBookDeltas)

Source

pub fn on_quote_tick(&mut self, quote: QuoteTick)

Source

pub fn on_trade_tick(&mut self, trade: TradeTick)

Source

pub fn cancel_order(&mut self, order: &OrderAny)

Source

pub fn trigger_stop_order(&mut self, client_order_id: ClientOrderId)

§Panics

Panics if the order type is invalid for a stop order.

Source

pub fn fill_limit_order(&mut self, client_order_id: ClientOrderId)

Releases an emulated limit-type order as a limit order, or a plain limit order as a market order.

Retains the command when market data is unavailable or the limit order cannot be built. Returns without releasing a limit-type order when its command is missing.

§Panics

Panics if a plain limit order is ready for market release but its command is missing.

Source

pub fn fill_market_order(&mut self, client_order_id: ClientOrderId)

Releases an emulated order as a market order, converting GTD to GTC.

Retains the command when market data is unavailable.

§Panics

Panics if an order is ready for market release but its command is missing.

Trait Implementations§

Source§

impl Debug for OrderEmulator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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