diff --git a/Cargo.lock b/Cargo.lock index d60b68c..7ab19b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1272,9 +1272,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libm" @@ -1410,6 +1410,8 @@ dependencies = [ "futures", "log", "polars", + "pyo3", + "pyo3-polars", "rand", "rayon", "reqwest", @@ -2023,7 +2025,6 @@ dependencies = [ "polars-json", "polars-schema", "polars-utils", - "rand", "rayon", "regex", "regex-syntax", @@ -2356,6 +2357,20 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "pyo3-polars" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d315add0412858cb21d45f0a48d68974d32f5f93f92fd9cedc95102ea011d1" +dependencies = [ + "libc", + "once_cell", + "polars", + "polars-core", + "pyo3", + "thiserror 1.0.69", +] + [[package]] name = "quick-xml" version = "0.36.2" @@ -2673,9 +2688,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" dependencies = [ "once_cell", "ring", @@ -2808,9 +2823,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap", "itoa", @@ -2839,9 +2854,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "simd-json" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1df0290e9bfe79ddd5ff8798ca887cd107b75353d2957efe9777296e17f26b5" +checksum = "aa2bcf6c6e164e81bc7a5d49fc6988b3d515d9e8c07457d7b74ffb9324b9cd40" dependencies = [ "ahash", "getrandom", diff --git a/Cargo.toml b/Cargo.toml index e48f8b0..430b8a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,15 +9,16 @@ rustdoc = ["--cfg", "doc"] [lib] name = "msyrs" -path = "src/lib.rs" +# path = "src/lib.rs" +crate-type = ["cdylib"] + [dependencies] anyhow = "1.0" reqwest = { version = "0.12.9", features = ["blocking", "json"] } -serde_json = "1.0" +serde_json = "^1.0" serde_urlencoded = "0.7" serde = { version = "1.0.215", features = ["derive"] } -# polars = { version = "0.44.2", features = ["lazy"] } chrono = "0.4.38" rand = "0.8" threadpool = "1.8.1" @@ -26,7 +27,13 @@ crossbeam = "0.8" rayon = "1.5" tokio = "1.41.1" futures = "0.3" -polars = { version = "^0.44.0", features = [ + +# pyo3 = { version = "0.23.1", features = ["extension-module"] } +# pyo3 = { version = "0.21.2", features = ["extension-module"] } +# pyo3 = { version = "*", features = ["abi3-py38"] } +pyo3 = { version = "*", features = ["extension-module"] } +pyo3-polars = { version = "0.18.0" } +polars = { version = "*", features = [ "lazy", "temporal", "describe", @@ -37,52 +44,51 @@ polars = { version = "^0.44.0", features = [ "timezones", "ndarray", "concat_str", - - # "serde-lazy", - # "parquet", - # "decompress", - # "zip", - # "gzip", - "dynamic_group_by", - "rows", - "cross_join", - "semi_anti_join", - "row_hash", - "diagonal_concat", - "dataframe_arithmetic", - "partition_by", - "is_in", - "zip_with", - "round_series", - "repeat_by", - "is_first_distinct", - "is_last_distinct", - "checked_arithmetic", - "dot_product", - "concat_str", - "reinterpret", - "take_opt_iter", - "mode", - "cum_agg", - "rolling_window", - "interpolate", - "rank", - "moment", - "ewma", - "abs", - "product", - "diff", - "pct_change", - "unique_counts", - "log", - "list_to_struct", - "list_count", - "list_eval", - "cumulative_eval", - "arg_where", - "search_sorted", - "offset_by", - "trigonometry", - "sign", - "propagate_nans", ] } + +# "serde-lazy", +# "parquet", +# "decompress", +# "zip", +# "gzip", +# "dynamic_group_by", +# "rows", +# "cross_join", +# "semi_anti_join", +# "row_hash", +# "diagonal_concat", +# "dataframe_arithmetic", +# "partition_by", +# "is_in", +# "zip_with", +# "round_series", +# "repeat_by", +# "is_first_distinct", +# "is_last_distinct", +# "checked_arithmetic", +# "dot_product", +# "reinterpret", +# "take_opt_iter", +# "mode", +# "cum_agg", +# "rolling_window", +# "interpolate", +# "rank", +# "moment", +# "ewma", +# "abs", +# "product", +# "diff", +# "pct_change", +# "unique_counts", +# "log", +# "list_to_struct", +# "list_count", +# "list_eval", +# "cumulative_eval", +# "arg_where", +# "search_sorted", +# "offset_by", +# "trigonometry", +# "sign", +# "propagate_nans", diff --git a/src/main.rs b/notebooks/main.rs similarity index 100% rename from src/main.rs rename to notebooks/main.rs diff --git a/src/lib.rs b/src/lib.rs index 6bcf0ea..78ddedf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,3 +2,29 @@ pub mod download; pub mod utils; + +use pyo3::{prelude::*, wrap_pymodule}; +use pyo3_polars::PyDataFrame; + +#[pyfunction] +pub fn load_qdf(file_path: &str) -> PyResult { + Ok(PyDataFrame( + utils::qdf::load_quantamental_dataframe(file_path).unwrap(), + )) +} + +// ignore deprecated warning +#[allow(deprecated)] +#[pymodule] +pub fn qdf(_py: Python, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(load_qdf, m)?)?; + Ok(()) +} + +#[allow(deprecated)] +#[pymodule] +pub fn msyrs(_py: Python, m: &PyModule) -> PyResult<()> { +// add qdf as a submodule + m.add_wrapped(wrap_pymodule!(qdf))?; + Ok(()) +} diff --git a/test.py b/test.py new file mode 100644 index 0000000..05c8bdb --- /dev/null +++ b/test.py @@ -0,0 +1,10 @@ +import msyrs + +# "E:\Work\jpmaqs-data\data\ADPEMPL_SA_P1M1ML1\USD_ADPEMPL_SA_P1M1ML1.csv" + +dfpath = "E:/Work/jpmaqs-data/data/ADPEMPL_SA_P1M1ML1/USD_ADPEMPL_SA_P1M1ML1.csv" + +print(msyrs.qdf.load_qdf(dfpath)) + + +