wip: hist vol

This commit is contained in:
Palash Tyagi 2024-11-29 00:49:11 +00:00
parent 6fb9b0f076
commit 421178a5bb

View File

@ -269,19 +269,40 @@ pub fn historic_vol(
println!("xcat: {:?},\ncids: {:?},\nlback_periods: {:?},lback_method: {:?},\nhalf_life: {:?},\nstart: {:?},\nend: {:?},\nest_freq: {:?},\nremove_zeros: {:?},\npostfix: {:?},\nnan_tolerance: {:?}", xcat, cids, lback_periods,lback_method, half_life, start, end, est_freq, remove_zeros, postfix, nan_tolerance);
let mut dfw = pivot_dataframe_by_ticker(df.clone(), Some("value".to_string()))?;
println!("Successfully pivoted the DataFrame.");
let lback_periods = lback_periods.unwrap_or(20);
let lback_method = lback_method.unwrap_or("ma".to_string());
let half_life = half_life;
println!("Successfully got lback_periods, lback_method, and half_life.");
let start = start.unwrap_or(dfw.column("real_date")?.date()?.min().unwrap().to_string());
let end = end.unwrap_or(dfw.column("real_date")?.date()?.max().unwrap().to_string());
println!("Successfully got start and end dates.");
let est_freq = est_freq.unwrap_or("D".to_string());
println!("Successfully got est_freq.");
let remove_zeros = remove_zeros.unwrap_or(false);
println!("Successfully got remove_zeros.");
let postfix = postfix.unwrap_or("_HISTVOL".to_string());
println!("Successfully got postfix.");
let nan_tolerance = nan_tolerance.unwrap_or(0.25);
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")?;
println!("Successfully parsed start and end dates.");
dfw = dfw
.lazy()
.filter(
@ -298,6 +319,8 @@ pub fn historic_vol(
)
.collect()?;
println!("Successfully filtered the DataFrame.");
let period = match est_freq.as_str() {
"W" => "weekly",
"M" => "monthly",