Skip to main content

fx_pricing/
spread.rs

1//! Spread calculation models
2
3use fx_utils::Price;
4
5/// Spread model for calculating bid/ask spreads
6pub trait SpreadModel {
7    fn calculate_spread(&self, mid_price: Price, volatility: f64) -> Price;
8}
9
10/// Simple fixed spread model
11pub struct FixedSpreadModel {
12    spread_bps: u64, // Spread in basis points
13}
14
15impl FixedSpreadModel {
16    pub fn new(spread_bps: u64) -> Self {
17        Self { spread_bps }
18    }
19}
20
21impl SpreadModel for FixedSpreadModel {
22    fn calculate_spread(&self, mid_price: Price, _volatility: f64) -> Price {
23        // Calculate spread as basis points of mid price
24        let spread = (mid_price.0 * self.spread_bps) / 10000;
25        Price(spread)
26    }
27}