mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-11-23 13:46:13 +00:00
Add logging for historic volatility calculations and implement utility to get min/max real dates
This commit is contained in:
@@ -131,9 +131,15 @@ fn freq_period_calc(
|
||||
);
|
||||
}
|
||||
|
||||
println!("Calculating historic volatility with the following parameters:");
|
||||
println!("lback_periods: {:?}, lback_method: {:?}, half_life: {:?}, remove_zeros: {:?}, nan_tolerance: {:?}, period: {:?}", lback_periods, lback_method, half_life, remove_zeros, nan_tolerance, period);
|
||||
|
||||
let mut new_df = dfw.clone();
|
||||
|
||||
for col_name in dfw.get_column_names() {
|
||||
if col_name == "real_date" {
|
||||
continue;
|
||||
}
|
||||
let series = dfw.column(col_name)?;
|
||||
let values: Array1<f64> = series
|
||||
.f64()?
|
||||
@@ -174,7 +180,7 @@ fn freq_period_calc(
|
||||
}
|
||||
_ => return Err("Invalid lookback method.".into()),
|
||||
};
|
||||
|
||||
println!("Successfully calculated result_series for column: {:?}", col_name);
|
||||
new_df.with_column(result_series)?;
|
||||
}
|
||||
|
||||
@@ -298,9 +304,14 @@ pub fn historic_vol(
|
||||
|
||||
println!("Successfully got nan_tolerance.");
|
||||
|
||||
let start_date = NaiveDate::parse_from_str(&start, "%Y-%m-%d")?;
|
||||
let end_date = NaiveDate::parse_from_str(&end, "%Y-%m-%d")?;
|
||||
let (dfw_start_date, dfw_end_date) =
|
||||
crate::utils::misc::get_min_max_real_dates(&dfw, "real_date")?;
|
||||
println!("Successfully got min and max real dates.");
|
||||
|
||||
let (start_date, end_date) = (
|
||||
NaiveDate::parse_from_str(&start, "%Y-%m-%d").unwrap_or_else(|_| dfw_start_date),
|
||||
NaiveDate::parse_from_str(&end, "%Y-%m-%d").unwrap_or_else(|_| dfw_end_date),
|
||||
);
|
||||
println!("Successfully parsed start and end dates.");
|
||||
|
||||
dfw = dfw
|
||||
@@ -327,6 +338,8 @@ pub fn historic_vol(
|
||||
_ => return Err("Invalid frequency specified.".into()),
|
||||
};
|
||||
|
||||
println!("Successfully got period.");
|
||||
|
||||
let dfw = match est_freq.as_str() {
|
||||
"D" => freq_daily_calc(
|
||||
&dfw,
|
||||
|
||||
0
src/panel/linear_composite.rs
Normal file
0
src/panel/linear_composite.rs
Normal file
Reference in New Issue
Block a user