pub struct ExecutionEventEmitter { /* private fields */ }Expand description
Event emitter for live trading - combines event generation with async dispatch.
This struct wraps an OrderEventFactory for event construction and an unbounded
channel sender for async dispatch. It provides emit_* convenience methods that
generate and send events in a single call.
The sender is set during the adapter’s start() phase via set_sender.
Implementations§
Source§impl ExecutionEventEmitter
impl ExecutionEventEmitter
Sourcepub fn new(
clock: &'static AtomicTime,
trader_id: TraderId,
account_id: AccountId,
account_type: AccountType,
base_currency: Option<Currency>,
) -> Self
pub fn new( clock: &'static AtomicTime, trader_id: TraderId, account_id: AccountId, account_type: AccountType, base_currency: Option<Currency>, ) -> Self
Creates a new ExecutionEventEmitter with no sender.
Call set_sender in the adapter’s start() method.
Sourcepub fn set_sender(&mut self, sender: UnboundedSender<ExecutionEvent>)
pub fn set_sender(&mut self, sender: UnboundedSender<ExecutionEvent>)
Sets the sender. Call in adapter’s start().
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Returns true if the sender is initialized.
Sourcepub fn account_id(&self) -> AccountId
pub fn account_id(&self) -> AccountId
Returns the account ID.
Sourcepub fn emit_account_state(
&self,
balances: Vec<AccountBalance>,
margins: Vec<MarginBalance>,
reported: bool,
ts_event: UnixNanos,
)
pub fn emit_account_state( &self, balances: Vec<AccountBalance>, margins: Vec<MarginBalance>, reported: bool, ts_event: UnixNanos, )
Generates and emits an account state event.
Sourcepub fn emit_order_denied(&self, order: &OrderAny, reason: &str)
pub fn emit_order_denied(&self, order: &OrderAny, reason: &str)
Generates and emits an order denied event.
Sourcepub fn emit_order_submitted(&self, order: &OrderAny)
pub fn emit_order_submitted(&self, order: &OrderAny)
Generates and emits an order submitted event.
Sourcepub fn emit_order_rejected(
&self,
order: &OrderAny,
reason: &str,
ts_event: UnixNanos,
due_post_only: bool,
)
pub fn emit_order_rejected( &self, order: &OrderAny, reason: &str, ts_event: UnixNanos, due_post_only: bool, )
Generates and emits an order rejected event.
Sourcepub fn emit_order_accepted(
&self,
order: &OrderAny,
venue_order_id: VenueOrderId,
ts_event: UnixNanos,
)
pub fn emit_order_accepted( &self, order: &OrderAny, venue_order_id: VenueOrderId, ts_event: UnixNanos, )
Generates and emits an order accepted event.
Sourcepub fn emit_order_modify_rejected(
&self,
order: &OrderAny,
venue_order_id: Option<VenueOrderId>,
reason: &str,
ts_event: UnixNanos,
)
pub fn emit_order_modify_rejected( &self, order: &OrderAny, venue_order_id: Option<VenueOrderId>, reason: &str, ts_event: UnixNanos, )
Generates and emits an order modify rejected event.
Sourcepub fn emit_order_cancel_rejected(
&self,
order: &OrderAny,
venue_order_id: Option<VenueOrderId>,
reason: &str,
ts_event: UnixNanos,
)
pub fn emit_order_cancel_rejected( &self, order: &OrderAny, venue_order_id: Option<VenueOrderId>, reason: &str, ts_event: UnixNanos, )
Generates and emits an order cancel rejected event.
Sourcepub fn emit_order_updated(
&self,
order: &OrderAny,
venue_order_id: VenueOrderId,
quantity: Quantity,
price: Option<Price>,
trigger_price: Option<Price>,
protection_price: Option<Price>,
ts_event: UnixNanos,
)
pub fn emit_order_updated( &self, order: &OrderAny, venue_order_id: VenueOrderId, quantity: Quantity, price: Option<Price>, trigger_price: Option<Price>, protection_price: Option<Price>, ts_event: UnixNanos, )
Generates and emits an order updated event.
Sourcepub fn emit_order_canceled(
&self,
order: &OrderAny,
venue_order_id: Option<VenueOrderId>,
ts_event: UnixNanos,
)
pub fn emit_order_canceled( &self, order: &OrderAny, venue_order_id: Option<VenueOrderId>, ts_event: UnixNanos, )
Generates and emits an order canceled event.
Sourcepub fn emit_order_triggered(
&self,
order: &OrderAny,
venue_order_id: Option<VenueOrderId>,
ts_event: UnixNanos,
)
pub fn emit_order_triggered( &self, order: &OrderAny, venue_order_id: Option<VenueOrderId>, ts_event: UnixNanos, )
Generates and emits an order triggered event.
Sourcepub fn emit_order_expired(
&self,
order: &OrderAny,
venue_order_id: Option<VenueOrderId>,
ts_event: UnixNanos,
)
pub fn emit_order_expired( &self, order: &OrderAny, venue_order_id: Option<VenueOrderId>, ts_event: UnixNanos, )
Generates and emits an order expired event.
Sourcepub fn emit_order_filled(
&self,
order: &OrderAny,
venue_order_id: VenueOrderId,
venue_position_id: Option<PositionId>,
trade_id: TradeId,
last_qty: Quantity,
last_px: Price,
quote_currency: Currency,
commission: Option<Money>,
liquidity_side: LiquiditySide,
ts_event: UnixNanos,
)
pub fn emit_order_filled( &self, order: &OrderAny, venue_order_id: VenueOrderId, venue_position_id: Option<PositionId>, trade_id: TradeId, last_qty: Quantity, last_px: Price, quote_currency: Currency, commission: Option<Money>, liquidity_side: LiquiditySide, ts_event: UnixNanos, )
Generates and emits an order filled event.
Sourcepub fn emit_order_rejected_event(
&self,
strategy_id: StrategyId,
instrument_id: InstrumentId,
client_order_id: ClientOrderId,
reason: &str,
ts_event: UnixNanos,
due_post_only: bool,
)
pub fn emit_order_rejected_event( &self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, reason: &str, ts_event: UnixNanos, due_post_only: bool, )
Constructs and emits an order rejected event from raw fields.
Sourcepub fn emit_order_modify_rejected_event(
&self,
strategy_id: StrategyId,
instrument_id: InstrumentId,
client_order_id: ClientOrderId,
venue_order_id: Option<VenueOrderId>,
reason: &str,
ts_event: UnixNanos,
)
pub fn emit_order_modify_rejected_event( &self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: Option<VenueOrderId>, reason: &str, ts_event: UnixNanos, )
Constructs and emits an order modify rejected event from raw fields.
Sourcepub fn emit_order_cancel_rejected_event(
&self,
strategy_id: StrategyId,
instrument_id: InstrumentId,
client_order_id: ClientOrderId,
venue_order_id: Option<VenueOrderId>,
reason: &str,
ts_event: UnixNanos,
)
pub fn emit_order_cancel_rejected_event( &self, strategy_id: StrategyId, instrument_id: InstrumentId, client_order_id: ClientOrderId, venue_order_id: Option<VenueOrderId>, reason: &str, ts_event: UnixNanos, )
Constructs and emits an order cancel rejected event from raw fields.
Sourcepub fn send_order_event(&self, event: OrderEventAny)
pub fn send_order_event(&self, event: OrderEventAny)
Emits an order event.
Sourcepub fn send_account_state(&self, state: AccountState)
pub fn send_account_state(&self, state: AccountState)
Emits an account state event.
Sourcepub fn send_execution_report(&self, report: ExecutionReport)
pub fn send_execution_report(&self, report: ExecutionReport)
Emits an execution report.
Sourcepub fn send_order_status_report(&self, report: OrderStatusReport)
pub fn send_order_status_report(&self, report: OrderStatusReport)
Emits an order status report.
Sourcepub fn send_fill_report(&self, report: FillReport)
pub fn send_fill_report(&self, report: FillReport)
Emits a fill report.
Sourcepub fn send_position_report(&self, report: PositionStatusReport)
pub fn send_position_report(&self, report: PositionStatusReport)
Emits a position status report.
Trait Implementations§
Source§impl Clone for ExecutionEventEmitter
impl Clone for ExecutionEventEmitter
Source§fn clone(&self) -> ExecutionEventEmitter
fn clone(&self) -> ExecutionEventEmitter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ExecutionEventEmitter
impl RefUnwindSafe for ExecutionEventEmitter
impl Send for ExecutionEventEmitter
impl Sync for ExecutionEventEmitter
impl Unpin for ExecutionEventEmitter
impl UnsafeUnpin for ExecutionEventEmitter
impl UnwindSafe for ExecutionEventEmitter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more