Module algorithm

Module algorithm 

Source
Expand description

Execution algorithm infrastructure for order slicing and execution optimization.

This module provides the ExecutionAlgorithm trait and supporting infrastructure for implementing algorithms like TWAP (Time-Weighted Average Price) and VWAP (Volume-Weighted Average Price) that slice large orders into smaller child orders.

§Architecture

Execution algorithms extend [DataActor] (not Strategy) because:

  • They don’t own positions (the parent Strategy does).
  • Spawned orders carry the parent Strategy’s ID, not the algorithm’s ID.
  • They act as order processors/transformers, not position managers.

§Order Flow

  1. A Strategy submits an order with exec_algorithm_id set.
  2. The order is routed to the algorithm’s {id}.execute endpoint.
  3. The algorithm receives the order via on_order().
  4. The algorithm spawns child orders using spawn_market(), spawn_limit(), etc.
  5. Spawned orders are submitted through the RiskEngine.
  6. The algorithm receives fill events and manages remaining quantity.

Re-exports§

pub use core::ExecutionAlgorithmCore;
pub use config::ExecutionAlgorithmConfig;
pub use twap::TwapAlgorithm;
pub use twap::TwapAlgorithmConfig;

Modules§

config
Configuration for execution algorithms.
core
Core component for execution algorithms.
twap
Time-Weighted Average Price (TWAP) execution algorithm.

Traits§

ExecutionAlgorithm
Core trait for implementing execution algorithms in NautilusTrader.