Skip to main content

FillSimulator

Struct FillSimulator 

Source
pub struct FillSimulator { /* private fields */ }

Implementations§

Source§

impl FillSimulator

Source

pub fn new(config: FillSimulatorConfig) -> Self

Source

pub fn position(&self) -> Position

Source

pub fn fills(&self) -> &[Fill]

Source

pub fn open_orders(&self) -> impl Iterator<Item = &Order>

Source

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.

Source

pub fn cancel(&mut self, order_id: u64) -> bool

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.