pub struct CostModel;Expand description
Estimates round-trip execution cost for a given order.
§Formula
commission_usd = commission_per_share * shares
spread_cost_usd = (spread_bps / 10_000) * notional_usd
impact_bps = impact_coefficient * sqrt(shares / avg_daily_volume) * 10_000
market_impact_usd = (impact_bps / 10_000) * notional_usd
total_cost_usd = commission_usd + spread_cost_usd + market_impact_usd
cost_bps = total_cost_usd / notional_usd * 10_000Implementations§
Source§impl CostModel
impl CostModel
Sourcepub fn estimate(
notional_usd: f64,
shares: f64,
price: f64,
params: &CostParams,
) -> ExecutionCost
pub fn estimate( notional_usd: f64, shares: f64, price: f64, params: &CostParams, ) -> ExecutionCost
Estimates round-trip execution cost for an order of shares at price.
notional_usd = shares * price (passed explicitly to avoid rounding differences).
Auto Trait Implementations§
impl Freeze for CostModel
impl RefUnwindSafe for CostModel
impl Send for CostModel
impl Sync for CostModel
impl Unpin for CostModel
impl UnsafeUnpin for CostModel
impl UnwindSafe for CostModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more