pub struct Exchange<M: Matcher> { /* private fields */ }Expand description
Central exchange that manages matching and per-agent portfolio tracking. Wraps a Matcher and maintains a HashMap<AgentId, Portfolio>.
Implementations§
Source§impl<M: Matcher> Exchange<M>
impl<M: Matcher> Exchange<M>
pub fn new(matcher: M) -> Self
pub fn register_agent( &mut self, id: AgentId, initial_cash: f64, transaction_cost_rate: f64, )
pub fn get_portfolio(&self, id: AgentId) -> Option<&Portfolio>
Sourcepub fn submit_orders(&mut self, agent_id: AgentId, requests: Vec<OrderRequest>)
pub fn submit_orders(&mut self, agent_id: AgentId, requests: Vec<OrderRequest>)
Submit order requests tagged with an agent ID. CancelAll only cancels the submitting agent’s orders.
Sourcepub fn resolve_matches(&mut self, state: &MarketState) -> Vec<FillEvent>
pub fn resolve_matches(&mut self, state: &MarketState) -> Vec<FillEvent>
Match pending orders against the current market state. Updates agent portfolios and records fill history.
Sourcepub fn last_fills(&self) -> &[(AgentId, FillEvent)]
pub fn last_fills(&self) -> &[(AgentId, FillEvent)]
Returns fills from the most recent resolve_matches call
Sourcepub fn fill_history_for(&self, agent_id: AgentId) -> Vec<&FillEvent>
pub fn fill_history_for(&self, agent_id: AgentId) -> Vec<&FillEvent>
Returns the complete fill history for a specific agent
Sourcepub fn fill_history(&self) -> &[(AgentId, FillEvent)]
pub fn fill_history(&self) -> &[(AgentId, FillEvent)]
Returns the complete fill history
pub fn get_matcher(&self) -> &M
Sourcepub fn get_matcher_parameters(&self) -> HashMap<String, f64>
pub fn get_matcher_parameters(&self) -> HashMap<String, f64>
Delegates to the matcher’s augment_parameters, returning any runtime state that should be injected into the next tick’s MarketState.
Auto Trait Implementations§
impl<M> Freeze for Exchange<M>where
M: Freeze,
impl<M> RefUnwindSafe for Exchange<M>where
M: RefUnwindSafe,
impl<M> Send for Exchange<M>where
M: Send,
impl<M> Sync for Exchange<M>where
M: Sync,
impl<M> Unpin for Exchange<M>where
M: Unpin,
impl<M> UnsafeUnpin for Exchange<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for Exchange<M>where
M: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more