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>, Error>;
fn on_child_order_placed(&mut self, order: &Order);
fn on_fill(&mut self, fill: &Fill) -> Result<Vec<ChildOrderRequest>, Error>;
fn on_tick(&mut self, tick: &Tick) -> Result<Vec<ChildOrderRequest>, Error>;
fn on_timer(&mut self) -> Result<Vec<ChildOrderRequest>, Error>;
fn cancel(&mut self) -> Result<(), Error>;
fn state(&self) -> Value;
fn from_state(state: Value) -> Result<Self, Error>
where Self: Sized;
// Provided method
fn bind_child_order(&mut self, _order: Order) -> Result<(), Error> { ... }
}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§
Sourcefn status(&self) -> AlgoStatus
fn status(&self) -> AlgoStatus
Returns the current status of the algorithm.
Sourcefn start(&mut self) -> Result<Vec<ChildOrderRequest>, Error>
fn start(&mut self) -> Result<Vec<ChildOrderRequest>, Error>
Start the algorithm and return any initial child orders.
Sourcefn on_child_order_placed(&mut self, order: &Order)
fn on_child_order_placed(&mut self, order: &Order)
Called when a child order has been successfully placed.
Sourcefn on_fill(&mut self, fill: &Fill) -> Result<Vec<ChildOrderRequest>, Error>
fn on_fill(&mut self, fill: &Fill) -> Result<Vec<ChildOrderRequest>, Error>
Called when a fill is received for one of this algorithm’s child orders.
Sourcefn on_tick(&mut self, tick: &Tick) -> Result<Vec<ChildOrderRequest>, Error>
fn on_tick(&mut self, tick: &Tick) -> Result<Vec<ChildOrderRequest>, Error>
Called when market tick data is received (mainly for VWAP algorithms).
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".