Skip to main content

ArbitrageScanner

Struct ArbitrageScanner 

Source
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

Source

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.

Source

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).

Source

pub fn filter_by_min_profit( opps: Vec<ArbitrageOpportunity>, min_bps: f64, ) -> Vec<ArbitrageOpportunity>

Filter opportunities to only those with spread >= min_bps.

Source

pub fn rank_by_confidence(opps: &mut Vec<ArbitrageOpportunity>)

Sort opportunities descending by confidence score (in-place).

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.