docs: add documentation for save_indicators_as_csv function in jpmaqsdownload.rs

This commit is contained in:
Palash Tyagi 2024-11-14 01:20:47 +00:00
parent 356e442400
commit 09a2da68d6

View File

@ -207,6 +207,34 @@ impl JPMaQSDownload {
Ok(df_main)
}
/// Save the indicators for the provided tickers and metrics as CSV files.///
/// The CSV files will be saved in the provided folder path in a subfolder named "JPMaQSData".
/// Any data in the folder path will be deleted before saving the new data.
/// The function downloads the indicators in batches of 500 tickers at a time.
///
/// The saved results would be in the format: <folder_path>/JPMaQSData/<xcat>/<ticker>.csv .
///
/// Usage:
///
/// ```rust
/// use msyrs::download::jpmaqsdownload::JPMaQSDownload;
/// use msyrs::download::jpmaqsdownload::JPMaQSDownloadGetIndicatorArgs;
/// let mut jpamqs_download = JPMaQSDownload::default();
/// let tickers: Vec<String> = jpamqs_download.get_catalogue().unwrap();
/// let some_tickers = tickers.iter().take(100).map(|s| s.to_string()).collect();
/// let res = jpamqs_download.save_indicators_as_csv(
/// JPMaQSDownloadGetIndicatorArgs {
/// tickers: some_tickers,
/// start_date: "2024-11-11".to_string(),
/// ..Default::default()
/// },
/// "./data/",
/// );
/// match res {
/// Ok(_) => println!("Saved indicators to disk"),
/// Err(e) => println!("Error saving indicators: {:?}", e),
/// }
/// ```
pub fn save_indicators_as_csv(
&mut self,
download_args: JPMaQSDownloadGetIndicatorArgs,