mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 07:20:01 +00:00
Enhance documentation by adding argument descriptions to functions in historic_vol, pivots, reduce_df, and update_df modules
This commit is contained in:
parent
c10b6adfcd
commit
acbe621704
@ -248,7 +248,7 @@ fn get_period_indices(
|
||||
}
|
||||
|
||||
/// Calculate historic volatility.
|
||||
/// Arguments:
|
||||
/// # Arguments:
|
||||
/// - `df`: A Quantamental DataFrame.
|
||||
/// - `xcat`: The category to calculate the historic volatility for.
|
||||
/// - `cids`: A list of cross-sections. If none are provided, all cross-sections available
|
||||
|
@ -1,3 +1,3 @@
|
||||
pub mod historic_vol;
|
||||
|
||||
pub mod linear_composite;
|
||||
|
||||
|
@ -19,7 +19,12 @@ fn get_ticker_from_qdf(df: &DataFrame) -> Result<String, Box<dyn Error>> {
|
||||
Ok(ticker)
|
||||
}
|
||||
|
||||
/// Pivots a dataframe to a format where each ticker a column.
|
||||
/// Pivots a dataframe to a format where each ticker is a column.
|
||||
/// # Arguments:
|
||||
/// * `df` - The dataframe to pivot.
|
||||
/// * `metric` - The metric to pivot on. If None, defaults to "value".
|
||||
/// # Returns:
|
||||
/// * `DataFrame` - The pivoted dataframe.
|
||||
#[allow(dead_code)]
|
||||
pub fn pivot_dataframe_by_ticker(
|
||||
df: DataFrame,
|
||||
@ -67,6 +72,11 @@ pub fn pivot_dataframe_by_ticker(
|
||||
}
|
||||
|
||||
/// Pivot ticker dataframe to qdf.
|
||||
/// # Arguments:
|
||||
/// * `df` - The dataframe to pivot.
|
||||
/// * `metric` - The metric to pivot on. If None, defaults to "value".
|
||||
/// # Returns:
|
||||
/// * `DataFrame` - The pivoted dataframe.
|
||||
#[allow(dead_code)]
|
||||
pub fn pivot_wide_dataframe_to_qdf(
|
||||
df: DataFrame,
|
||||
@ -102,6 +112,11 @@ pub fn pivot_wide_dataframe_to_qdf(
|
||||
}
|
||||
|
||||
/// Splits a dataframe by ticker.
|
||||
/// # Arguments:
|
||||
/// * `df` - The dataframe to split.
|
||||
/// * `metrics` - The metrics to split on. If None, defaults to all metrics.
|
||||
/// # Returns:
|
||||
/// * `HashMap<String, DataFrame>` - A hashmap where the key is the ticker and the value is the dataframe.
|
||||
#[allow(dead_code)]
|
||||
fn split_df_by_tickers(
|
||||
df: &DataFrame,
|
||||
@ -146,6 +161,10 @@ fn split_df_by_tickers(
|
||||
|
||||
/// Splits a QDF container data for a single ticker into a Vec of DataFrames (one per metric).
|
||||
/// The resulting DataFrames will have the "real_date" column and the metric column.
|
||||
/// # Arguments:
|
||||
/// * `df` - The dataframe to split.
|
||||
/// # Returns:
|
||||
/// * `Vec<DataFrame>` - A vector of dataframes, each containing the "real_date" and a metric column.
|
||||
#[allow(dead_code)]
|
||||
fn single_ticker_qdf_to_timeseries(mut df: DataFrame) -> Result<Vec<DataFrame>, Box<dyn Error>> {
|
||||
let mut df_vec = Vec::new();
|
||||
|
@ -7,6 +7,7 @@ use std::error::Error;
|
||||
const QDF_INDEX_COLUMNS: [&str; 3] = ["real_date", "cid", "xcat"];
|
||||
|
||||
/// Filter a dataframe based on the given parameters.
|
||||
/// # Arguments:
|
||||
/// - `cids`: Filter by cross-sectional identifiers
|
||||
/// - `xcats`: Filter by extended categories
|
||||
/// - `metrics`: Filter by metrics
|
||||
|
@ -5,8 +5,10 @@ use std::error::Error;
|
||||
const QDF_INDEX_COLUMNS: [&str; 3] = ["real_date", "cid", "xcat"];
|
||||
|
||||
/// Update a Quantamental DataFrame with new data.
|
||||
/// # Arguments:
|
||||
/// - `df`: The original DataFrame
|
||||
/// - `df_add`: The new DataFrame to add
|
||||
/// - `xcat_replace`: !NOT IMPLEMENTED! If true, replace existing xcats with new ones.
|
||||
///
|
||||
pub fn update_dataframe(
|
||||
df: &DataFrame,
|
||||
|
Loading…
x
Reference in New Issue
Block a user