pub mod fx_rollover;
use ahash::AHashMap;
pub use fx_rollover::FXRolloverInterestModule;
use nautilus_common::cache::Cache;
use nautilus_core::UnixNanos;
use nautilus_execution::matching_engine::engine::OrderMatchingEngine;
use nautilus_model::{
data::Data,
identifiers::{InstrumentId, Venue},
instruments::InstrumentAny,
types::{Currency, Money},
};
#[derive(Debug)]
pub struct ExchangeContext<'a> {
pub venue: Venue,
pub base_currency: Option<Currency>,
pub instruments: &'a AHashMap<InstrumentId, InstrumentAny>,
pub matching_engines: &'a AHashMap<InstrumentId, OrderMatchingEngine>,
pub cache: &'a Cache,
}
#[derive(Debug, Clone)]
pub enum SimulationModuleAny {
FXRolloverInterest(FXRolloverInterestModule),
}
impl SimulationModule for SimulationModuleAny {
fn pre_process(&self, data: &Data) {
match self {
Self::FXRolloverInterest(module) => module.pre_process(data),
}
}
fn process(&self, ts_now: UnixNanos, ctx: &ExchangeContext) -> Vec<Money> {
match self {
Self::FXRolloverInterest(module) => module.process(ts_now, ctx),
}
}
fn log_diagnostics(&self) {
match self {
Self::FXRolloverInterest(module) => module.log_diagnostics(),
}
}
fn reset(&self) {
match self {
Self::FXRolloverInterest(module) => module.reset(),
}
}
}
impl From<SimulationModuleAny> for Box<dyn SimulationModule> {
fn from(value: SimulationModuleAny) -> Self {
match value {
SimulationModuleAny::FXRolloverInterest(module) => Box::new(module),
}
}
}
pub trait SimulationModule {
fn pre_process(&self, data: &Data);
fn process(&self, ts_now: UnixNanos, ctx: &ExchangeContext) -> Vec<Money>;
fn log_diagnostics(&self);
fn reset(&self);
}