ExecutionAlgorithm

Trait ExecutionAlgorithm 

Source
pub trait ExecutionAlgorithm: Send + Sync {
    // Required methods
    fn kind(&self) -> &'static str;
    fn id(&self) -> &Uuid;
    fn status(&self) -> AlgoStatus;
    fn start(&mut self) -> Result<Vec<ChildOrderRequest>>;
    fn on_child_order_placed(&mut self, order: &Order);
    fn on_fill(&mut self, fill: &Fill) -> Result<Vec<ChildOrderRequest>>;
    fn on_tick(&mut self, tick: &Tick) -> Result<Vec<ChildOrderRequest>>;
    fn on_timer(&mut self) -> Result<Vec<ChildOrderRequest>>;
    fn cancel(&mut self) -> Result<()>;
    fn state(&self) -> Value;
    fn from_state(state: Value) -> Result<Self>
       where Self: Sized;

    // Provided method
    fn bind_child_order(&mut self, _order: Order) -> Result<()> { ... }
}
Expand description

Trait defining the behavior of an execution algorithm.

Each execution algorithm is a stateful entity that responds to various events and generates child orders as needed. The algorithm maintains its own internal state and can be persisted and restored.

Required Methods§

Source

fn kind(&self) -> &'static str

Human-readable identifier for persistence/logging.

Source

fn id(&self) -> &Uuid

Returns the unique ID of this algorithm instance.

Source

fn status(&self) -> AlgoStatus

Returns the current status of the algorithm.

Source

fn start(&mut self) -> Result<Vec<ChildOrderRequest>>

Start the algorithm and return any initial child orders.

Source

fn on_child_order_placed(&mut self, order: &Order)

Called when a child order has been successfully placed.

Source

fn on_fill(&mut self, fill: &Fill) -> Result<Vec<ChildOrderRequest>>

Called when a fill is received for one of this algorithm’s child orders.

Source

fn on_tick(&mut self, tick: &Tick) -> Result<Vec<ChildOrderRequest>>

Called when market tick data is received (mainly for VWAP algorithms).

Source

fn on_timer(&mut self) -> Result<Vec<ChildOrderRequest>>

Called when a timer event occurs (mainly for TWAP algorithms).

Source

fn cancel(&mut self) -> Result<()>

Request cancellation of the algorithm.

Source

fn state(&self) -> Value

Return the current state for persistence.

Source

fn from_state(state: Value) -> Result<Self>
where Self: Sized,

Restore algorithm from persisted state.

Provided Methods§

Source

fn bind_child_order(&mut self, _order: Order) -> Result<()>

Bind a previously placed child order to the algorithm (used during recovery).

Implementors§