diff --git a/src/utils/qdf/blacklist.rs b/src/utils/qdf/blacklist.rs index d7e8f80..09d0246 100644 --- a/src/utils/qdf/blacklist.rs +++ b/src/utils/qdf/blacklist.rs @@ -22,21 +22,41 @@ impl Blacklist { } } -/// Apply a blacklist to a Quantamental DataFrame with Lazy API. +/// Apply a blacklist to a Quantamental DataFrame. /// /// * `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( +/// * `group_by_cid = Some(false)` is not implemented yet. +pub fn apply_blacklist( df: &mut DataFrame, blacklist: &BTreeMap, metrics: Option>, group_by_cid: Option, ) -> Result> { check_quantamental_dataframe(df)?; + // dataframe is like: + // | cid | xcat | real_date | metric1 | metric2 | + // |-----|------|-----------|---------|---------| + // | A | B | 2023-01-01| 1.0 | 2.0 | + // | A | B | 2023-01-02| 1.0 | 2.0 | + // | A | C | 2023-01-01| 1.0 | 2.0 | + // | A | C | 2023-01-02| 1.0 | 2.0 | + // | D | E | 2023-01-01| 1.0 | 2.0 | + // | D | E | 2023-01-02| 1.0 | 2.0 | + + // (real date column is Naive date) + + // blacklist is like: + // {'A_B_1': ('2023-01-02', '2023-01-03'), + // 'A_B_2': ('2023-01-04', '2023-01-05'), + // 'A_C_1': ('2023-01-02', '2023-01-03'), } + + // get_cid('A_B_1') = 'A' + // get_cid('A_B_2') = 'A' + // get_cid('D_E_1') = 'D' + Ok(df.clone()) } /// Create a blacklist from a Quantamental DataFrame.