pub struct SpreadCost;Expand description
Bid-ask spread cost estimator.
§Example
use fin_primitives::execution_cost::SpreadCost;
// Bid = 99.90, Ask = 100.10 -> half-spread = 10 bps
let hs = SpreadCost::half_spread_bps(99.90, 100.10);
assert!((hs - 10.0).abs() < 1e-6);Implementations§
Source§impl SpreadCost
impl SpreadCost
Sourcepub fn half_spread_bps(bid: f64, ask: f64) -> f64
pub fn half_spread_bps(bid: f64, ask: f64) -> f64
Half the bid-ask spread expressed in basis points.
half_spread_bps = (ask - bid) / (2 * mid) * 10_000
Auto Trait Implementations§
impl Freeze for SpreadCost
impl RefUnwindSafe for SpreadCost
impl Send for SpreadCost
impl Sync for SpreadCost
impl Unpin for SpreadCost
impl UnsafeUnpin for SpreadCost
impl UnwindSafe for SpreadCost
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