diff --git a/src/utils/qdf/blacklist.rs b/src/utils/qdf/blacklist.rs index 2ab1fad..d7e8f80 100644 --- a/src/utils/qdf/blacklist.rs +++ b/src/utils/qdf/blacklist.rs @@ -9,6 +9,43 @@ use std::error::Error; use crate::utils::qdf::get_unique_metrics; +// struct Blacklist which is a wrapper around hashmap and btreemap +#[derive(Debug, Clone)] +pub struct Blacklist { + pub blacklist: BTreeMap, +} + +// impl hashmap into +impl Blacklist { + pub fn into_hashmap(self) -> HashMap { + self.blacklist.into_iter().collect() + } +} + +/// Apply a blacklist to a Quantamental DataFrame with Lazy API. +/// +/// * `blacklist` is a map from any “ticker‑like” key to a tuple of +/// `(start_date, end_date)` in **inclusive** `"YYYY‑MM‑DD"` format. +/// * `metrics` – if `None`, every metric from `get_unique_metrics(df)` +/// is used. +/// * `group_by_cid = Some(false)` is not implemented yet (parity with +/// the eager version). +pub fn apply_blacklist_lazy( + df: &mut DataFrame, + blacklist: &BTreeMap, + metrics: Option>, + group_by_cid: Option, +) -> Result> { + check_quantamental_dataframe(df)?; + Ok(df.clone()) +} +/// Create a blacklist from a Quantamental DataFrame. +/// The blacklist is a mapping of tickers to date ranges where the specified metrics are null or NaN. +/// # Arguments: +/// * `df` - The Quantamental DataFrame. +/// * `group_by_cid` - If true, group the blacklist by `cid`. Defaults to true. +/// * `blacklist_name` - The name of the blacklist. Defaults to "BLACKLIST". +/// * `metrics` - The metrics to check for null or NaN values. If None, all metrics are used. pub fn create_blacklist_from_qdf( df: &DataFrame, group_by_cid: Option, @@ -119,6 +156,8 @@ pub fn create_blacklist_from_qdf( Ok(btree_map) } +/// Get a mask of NaN values for the specified metrics in the DataFrame. +#[allow(dead_code)] fn get_nan_mask( df: &DataFrame, metrics: Vec,