Skip to main content

engine/matcher/
mod.rs

1pub mod simple;
2pub mod stochastic;
3
4pub use simple::SimpleMatcher;
5pub use stochastic::StochasticMatcher;
6
7use crate::types::{FillEvent, MarketState, Order};
8use std::collections::HashMap;
9
10pub trait Matcher {
11    /// Adds a new order to the matcher
12    fn add_order(&mut self, order: Order);
13
14    /// Cancels a specific order by ID
15    fn cancel_order(&mut self, order_id: u64);
16
17    /// Cancels all open orders
18    fn cancel_all(&mut self);
19
20    /// Processes a new quote against open orders and returns any fill events
21    fn process_quote(&mut self, quote: &MarketState) -> Vec<FillEvent>;
22
23    /// Returns a reference to the current list of orders
24    fn get_orders(&self) -> &Vec<Order>;
25
26    /// Returns runtime state parameters to be injected into each tick's
27    /// MarketState before strategies are called.  The default returns an
28    /// empty map; override in matchers that carry observable state
29    /// (e.g. Hawkes intensity).
30    fn augment_parameters(&self) -> HashMap<String, f64> {
31        HashMap::new()
32    }
33}