mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-11-20 19:56:11 +00:00
add Python wrapper for downloading JPMaQS indicators as DataFrame
This commit is contained in:
43
src/py/download.rs
Normal file
43
src/py/download.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use pyo3::prelude::*;
|
||||
use pyo3_polars::PyDataFrame;
|
||||
|
||||
/// Python wrapper for [`crate::utils::qdf`] module.
|
||||
#[allow(deprecated)]
|
||||
#[pymodule]
|
||||
pub fn download(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(download_jpmaqs_indicators_as_df, m)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Python wrapper for downloading JPMAQS indicators as a DataFrame.
|
||||
/// See [`crate::download::jpmaqsdownload::download_jpmaqs_indicators_as_df`] for full documentation.
|
||||
/// Arguments:
|
||||
/// - `client_id`: The client ID.
|
||||
/// - `client_secret`: The client secret.
|
||||
/// - `tickers`: The tickers.
|
||||
/// - `start_date`: The start date.
|
||||
/// - `end_date`: The end date.
|
||||
///
|
||||
/// Returns:
|
||||
/// - A standardized Quantamental DataFrame.
|
||||
#[pyfunction]
|
||||
pub fn download_jpmaqs_indicators_as_df(
|
||||
client_id: String,
|
||||
client_secret: String,
|
||||
tickers: Vec<String>,
|
||||
metrics: Option<Vec<String>>,
|
||||
start_date: Option<String>,
|
||||
end_date: Option<String>,
|
||||
) -> PyResult<PyDataFrame> {
|
||||
Ok(PyDataFrame(
|
||||
crate::download::jpmaqsdownload::download_jpmaqs_indicators_as_df(
|
||||
client_id,
|
||||
client_secret,
|
||||
tickers,
|
||||
metrics,
|
||||
start_date,
|
||||
end_date,
|
||||
)
|
||||
.unwrap(),
|
||||
))
|
||||
}
|
||||
Reference in New Issue
Block a user