Add instrument history helpers

This commit is contained in:
boris
2026-04-23 19:43:36 -07:00
parent ca49b6dbb3
commit f4030f2607
6 changed files with 60 additions and 16 deletions

View File

@@ -802,6 +802,21 @@ impl DataSet {
instruments
}
pub fn instruments_history(&self, symbols: &[&str]) -> Vec<&Instrument> {
symbols
.iter()
.filter_map(|symbol| self.instruments.get(*symbol))
.collect()
}
pub fn active_instruments(&self, date: NaiveDate, symbols: &[&str]) -> Vec<&Instrument> {
symbols
.iter()
.filter_map(|symbol| self.instruments.get(*symbol))
.filter(|instrument| instrument.is_active_on(date))
.collect()
}
pub fn instrument(&self, symbol: &str) -> Option<&Instrument> {
self.instruments.get(symbol)
}