pub struct MultiExchange { /* private fields */ }Expand description
A collection of per-symbol Exchange instances.
Each symbol gets its own independent order book. This is the entry point for multi-asset simulations.
use nanobook::{MultiExchange, Symbol, Side, Price, TimeInForce};
let mut multi = MultiExchange::new();
let aapl = Symbol::new("AAPL");
let msft = Symbol::new("MSFT");
// Orders are routed to per-symbol books
multi.get_or_create(&aapl).submit_limit(Side::Sell, Price(150_00), 100, TimeInForce::GTC);
multi.get_or_create(&msft).submit_limit(Side::Sell, Price(300_00), 200, TimeInForce::GTC);
assert_eq!(multi.get(&aapl).unwrap().best_ask(), Some(Price(150_00)));
assert_eq!(multi.get(&msft).unwrap().best_ask(), Some(Price(300_00)));Implementations§
Source§impl MultiExchange
impl MultiExchange
Sourcepub fn get_or_create(&mut self, symbol: &Symbol) -> &mut Exchange
pub fn get_or_create(&mut self, symbol: &Symbol) -> &mut Exchange
Get or create the exchange for a symbol.
Sourcepub fn get(&self, symbol: &Symbol) -> Option<&Exchange>
pub fn get(&self, symbol: &Symbol) -> Option<&Exchange>
Get a reference to the exchange for a symbol, if it exists.
Sourcepub fn get_mut(&mut self, symbol: &Symbol) -> Option<&mut Exchange>
pub fn get_mut(&mut self, symbol: &Symbol) -> Option<&mut Exchange>
Get a mutable reference to the exchange for a symbol, if it exists.
Trait Implementations§
Source§impl Clone for MultiExchange
impl Clone for MultiExchange
Source§fn clone(&self) -> MultiExchange
fn clone(&self) -> MultiExchange
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MultiExchange
impl Debug for MultiExchange
Source§impl Default for MultiExchange
impl Default for MultiExchange
Source§fn default() -> MultiExchange
fn default() -> MultiExchange
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MultiExchange
impl RefUnwindSafe for MultiExchange
impl Send for MultiExchange
impl Sync for MultiExchange
impl Unpin for MultiExchange
impl UnwindSafe for MultiExchange
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