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 set_account_id(&mut self, account_id: AccountId)
pub fn set_account_id(&mut self, account_id: AccountId)
Sets the account ID for generated events.
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_order_submitted_batch(&self, batch: OrderSubmittedBatch)
pub fn send_order_submitted_batch(&self, batch: OrderSubmittedBatch)
Emits a batch of order submitted events as a single channel message.
Sourcepub fn send_order_accepted_batch(&self, batch: OrderAcceptedBatch)
pub fn send_order_accepted_batch(&self, batch: OrderAcceptedBatch)
Emits a batch of order accepted events as a single channel message.
Sourcepub fn send_order_canceled_batch(&self, batch: OrderCanceledBatch)
pub fn send_order_canceled_batch(&self, batch: OrderCanceledBatch)
Emits a batch of order canceled events as a single channel message.
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_order_with_fills(
&self,
report: OrderStatusReport,
fills: Vec<FillReport>,
)
pub fn send_order_with_fills( &self, report: OrderStatusReport, fills: Vec<FillReport>, )
Emits an order status report bundled with the fills that produced it.
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more