nautilus_execution/matching_engine/
adapter.rs1use std::{
17 cell::{Ref, RefCell, RefMut},
18 rc::Rc,
19};
20
21use nautilus_common::{cache::Cache, clock::Clock};
22use nautilus_model::{
23 enums::{AccountType, BookType, OmsType},
24 instruments::InstrumentAny,
25};
26
27use crate::{
28 matching_engine::{config::OrderMatchingEngineConfig, engine::OrderMatchingEngine},
29 models::{fee::FeeModelAny, fill::FillModelAny},
30};
31
32#[derive(Debug)]
33pub struct OrderEngineAdapter {
34 engine: Rc<RefCell<OrderMatchingEngine>>,
35}
36
37impl OrderEngineAdapter {
38 #[expect(clippy::too_many_arguments)]
39 pub fn new(
40 instrument: InstrumentAny,
41 raw_id: u32,
42 fill_model: FillModelAny,
43 fee_model: FeeModelAny,
44 book_type: BookType,
45 oms_type: OmsType,
46 account_type: AccountType,
47 clock: Rc<RefCell<dyn Clock>>,
48 cache: Rc<RefCell<Cache>>,
49 config: OrderMatchingEngineConfig,
50 ) -> Self {
51 let engine = Rc::new(RefCell::new(OrderMatchingEngine::new(
52 instrument,
53 raw_id,
54 fill_model,
55 fee_model,
56 book_type,
57 oms_type,
58 account_type,
59 clock,
60 cache,
61 config,
62 )));
63
64 Self { engine }
65 }
66
67 #[must_use]
68 pub fn get_engine(&self) -> Ref<'_, OrderMatchingEngine> {
69 self.engine.borrow()
70 }
71
72 #[must_use]
73 pub fn get_engine_mut(&self) -> RefMut<'_, OrderMatchingEngine> {
74 self.engine.borrow_mut()
75 }
76}