pub struct ArbitrageScanner;Expand description
Scans market data for cross-market and triangular arbitrage opportunities.
§Example
use fin_primitives::arbitrage::ArbitrageScanner;
use std::collections::HashMap;
let mut markets: HashMap<String, HashMap<String, f64>> = HashMap::new();
let mut nyse = HashMap::new();
nyse.insert("AAPL".to_string(), 150.00_f64);
markets.insert("NYSE".to_string(), nyse);
let mut nasdaq = HashMap::new();
nasdaq.insert("AAPL".to_string(), 150.50_f64);
markets.insert("NASDAQ".to_string(), nasdaq);
let opps = ArbitrageScanner::scan_cross_market(&markets);
assert!(!opps.is_empty());Implementations§
Source§impl ArbitrageScanner
impl ArbitrageScanner
Sourcepub fn scan_cross_market(
markets: &HashMap<String, HashMap<String, f64>>,
) -> Vec<ArbitrageOpportunity>
pub fn scan_cross_market( markets: &HashMap<String, HashMap<String, f64>>, ) -> Vec<ArbitrageOpportunity>
Find same-asset price discrepancies across markets.
markets maps market name -> (symbol -> price).
Returns one ArbitrageOpportunity per (asset, buy_market, sell_market) triple
where a positive spread exists.
Sourcepub fn scan_triangular(rates: &HashMap<String, f64>) -> Vec<TriangularArb>
pub fn scan_triangular(rates: &HashMap<String, f64>) -> Vec<TriangularArb>
Scan for triangular arbitrage given a map of “A/B” -> rate.
Enumerates all currency triples present in the rate map and returns those with a product > 1.0 (profitable cycle).
Sourcepub fn filter_by_min_profit(
opps: Vec<ArbitrageOpportunity>,
min_bps: f64,
) -> Vec<ArbitrageOpportunity>
pub fn filter_by_min_profit( opps: Vec<ArbitrageOpportunity>, min_bps: f64, ) -> Vec<ArbitrageOpportunity>
Filter opportunities to only those with spread >= min_bps.
Sourcepub fn rank_by_confidence(opps: &mut Vec<ArbitrageOpportunity>)
pub fn rank_by_confidence(opps: &mut Vec<ArbitrageOpportunity>)
Sort opportunities descending by confidence score (in-place).
Auto Trait Implementations§
impl Freeze for ArbitrageScanner
impl RefUnwindSafe for ArbitrageScanner
impl Send for ArbitrageScanner
impl Sync for ArbitrageScanner
impl Unpin for ArbitrageScanner
impl UnsafeUnpin for ArbitrageScanner
impl UnwindSafe for ArbitrageScanner
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