From ed9b0c2e0f27870bdfa546dcadd4229ac623bf7c Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sun, 6 Apr 2025 00:41:58 +0100 Subject: [PATCH] Add documentation comments for ticker-related functions --- src/utils/misc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/misc.rs b/src/utils/misc.rs index 528c8b8..9bca1d1 100644 --- a/src/utils/misc.rs +++ b/src/utils/misc.rs @@ -3,6 +3,7 @@ use polars::prelude::*; use std::collections::HashMap; use std::error::Error; +/// Split a ticker string into `cid` and `xcat`. pub fn split_ticker(ticker: String) -> Result<(String, String), Box> { // split by the first underscore character. return the first and second parts. let parts: Vec<&str> = ticker.splitn(2, '_').collect(); @@ -12,6 +13,7 @@ pub fn split_ticker(ticker: String) -> Result<(String, String), Box> Ok((parts[0].to_string(), parts[1].to_string())) } +/// Get the minimum and maximum dates from a date column in a DataFrame. pub fn get_min_max_real_dates( df: &DataFrame, date_col: &str, @@ -41,20 +43,24 @@ pub fn get_min_max_real_dates( } } +/// Get the `cid` from a ticker string. #[allow(dead_code)] pub fn get_cid(ticker: String) -> Result> { split_ticker(ticker).map(|(cid, _)| cid) } +/// Get the `xcat` from a ticker string. #[allow(dead_code)] pub fn get_xcat(ticker: String) -> Result> { split_ticker(ticker).map(|(_, xcat)| xcat) } +/// Get the `cid` and `xcat` from a ticker string. pub fn create_ticker(cid: &str, xcat: &str) -> String { format!("{}_{}", cid, xcat) } +/// Create all possible tickers from a list of `cids` and `xcats`. pub fn create_intersecting_tickers(cids: &[&str], xcats: &[&str]) -> Vec { let mut tickers = Vec::new(); for cid in cids {