Add remaining RQAlpha extension helpers

This commit is contained in:
boris
2026-04-23 21:44:42 -07:00
parent beb9c7a7ae
commit ed8ac385e4
7 changed files with 689 additions and 21 deletions

View File

@@ -4,6 +4,11 @@ use crate::events::{ProcessEvent, ProcessEventKind};
type ProcessEventListener = Box<dyn FnMut(&ProcessEvent)>;
pub trait BacktestProcessMod {
fn name(&self) -> &str;
fn install(&mut self, bus: &mut ProcessEventBus);
}
#[derive(Default)]
pub struct ProcessEventBus {
listeners: BTreeMap<ProcessEventKind, Vec<ProcessEventListener>>,
@@ -42,6 +47,13 @@ impl ProcessEventBus {
self.any_listeners.push(Box::new(listener));
}
pub fn install_mod<M>(&mut self, module: &mut M)
where
M: BacktestProcessMod,
{
module.install(self);
}
pub fn publish(&mut self, event: &ProcessEvent) {
if let Some(listeners) = self.listeners.get_mut(&event.kind) {
for listener in listeners {