Add instrument history helpers
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user