pub struct FillSimulator { /* private fields */ }Implementations§
Source§impl FillSimulator
impl FillSimulator
pub fn new(config: FillSimulatorConfig) -> Self
pub fn position(&self) -> Position
pub fn fills(&self) -> &[Fill]
pub fn open_orders(&self) -> impl Iterator<Item = &Order>
Sourcepub fn submit(
&mut self,
side: OrderSide,
kind: OrderKind,
quantity: f64,
) -> Option<u64>
pub fn submit( &mut self, side: OrderSide, kind: OrderKind, quantity: f64, ) -> Option<u64>
Submits a new order, returning its ID. Rejected (returns None) if this would exceed
max_pyramid_entries same-direction accumulations.
pub fn cancel(&mut self, order_id: u64) -> bool
Sourcepub fn on_bar(&mut self, bar: &Bar, timestamp: i64) -> Vec<Fill>
pub fn on_bar(&mut self, bar: &Bar, timestamp: i64) -> Vec<Fill>
Processes one bar against all resting orders: updates trailing stops, checks fill conditions, applies costs, and updates position state. Returns the fills produced this bar.
Bracket orders (submitted via submit_bracket) are evaluated in two passes: standalone
orders and bracket entries first, then bracket exits. A bracket’s stop-loss/take-profit
only become active once (and only for as much quantity as) the entry has actually filled,
and the two exits share one OCO capacity budget (entry_filled - exit_closed) so that
whichever fills first — per IntrabarFillPolicy when a single bar touches both —
immediately caps the other within the same bar. This prevents a bracket’s exits from
filling before its entry, or from jointly closing more than the position they protect.