From 26a220cc4c29ca37ceccf0f9e7a7e0cb96f93562 Mon Sep 17 00:00:00 2001
From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com>
Date: Fri, 22 Nov 2024 23:39:56 +0000
Subject: [PATCH] moving stuff around
---
notebooks/python-notebook.ipynb | 553 +++++++++++++++++++++++++++-----
src/{py => _py}/download.rs | 0
src/{py => _py}/mod.rs | 8 +-
src/{py => _py}/panel.rs | 0
src/{py => _py}/qdf.rs | 0
src/lib.rs | 4 +-
src/panel/historic_vol.rs | 61 ++++
7 files changed, 541 insertions(+), 85 deletions(-)
rename src/{py => _py}/download.rs (100%)
rename src/{py => _py}/mod.rs (65%)
rename src/{py => _py}/panel.rs (100%)
rename src/{py => _py}/qdf.rs (100%)
diff --git a/notebooks/python-notebook.ipynb b/notebooks/python-notebook.ipynb
index 8335b3c..a5f11d2 100644
--- a/notebooks/python-notebook.ipynb
+++ b/notebooks/python-notebook.ipynb
@@ -66,8 +66,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# DATA_FOLDER_PATH = \"E:/Work/jpmaqs-data\"\n",
- "DATA_FOLDER_PATH = \"C:/Users/PalashTyagi/Code/go-dataquery/jpmaqs-data\"\n",
+ "DATA_FOLDER_PATH = \"E:/Work/jpmaqs-data\"\n",
+ "# DATA_FOLDER_PATH = \"C:/Users/PalashTyagi/Code/go-dataquery/jpmaqs-data\"\n",
"DQ_CLIENT_ID = os.getenv(\"DQ_CLIENT_ID\")\n",
"DQ_CLIENT_SECRET = os.getenv(\"DQ_CLIENT_SECRET\")"
]
@@ -92,7 +92,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken to load qdf: 0.007575511932373047\n"
+ "Time taken to load qdf: 0.0040130615234375\n"
]
},
{
@@ -163,20 +163,61 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "
shape: (5, 7)real_date | cid | xcat | value | grading | eop_lag | mop_lag |
---|
date | str | str | f64 | f64 | f64 | f64 |
1990-04-26 | "AUD" | "CPIC_SA_P1M1ML12" | 6.434599 | 2.0 | 26.0 | 223.0 |
1990-04-27 | "AUD" | "CPIC_SA_P1M1ML12" | 6.434599 | 2.0 | 27.0 | 224.0 |
1990-04-30 | "AUD" | "CPIC_SA_P1M1ML12" | 6.434599 | 2.0 | 30.0 | 227.0 |
1990-05-01 | "AUD" | "CPIC_SA_P1M1ML12" | 6.434599 | 2.0 | 31.0 | 228.0 |
1990-05-02 | "AUD" | "CPIC_SA_P1M1ML12" | 6.434599 | 2.0 | 32.0 | 229.0 |
"
+ ],
+ "text/plain": [
+ "shape: (5, 7)\n",
+ "┌────────────┬─────┬──────────────────┬──────────┬─────────┬─────────┬─────────┐\n",
+ "│ real_date ┆ cid ┆ xcat ┆ value ┆ grading ┆ eop_lag ┆ mop_lag │\n",
+ "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
+ "│ date ┆ str ┆ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
+ "╞════════════╪═════╪══════════════════╪══════════╪═════════╪═════════╪═════════╡\n",
+ "│ 1990-04-26 ┆ AUD ┆ CPIC_SA_P1M1ML12 ┆ 6.434599 ┆ 2.0 ┆ 26.0 ┆ 223.0 │\n",
+ "│ 1990-04-27 ┆ AUD ┆ CPIC_SA_P1M1ML12 ┆ 6.434599 ┆ 2.0 ┆ 27.0 ┆ 224.0 │\n",
+ "│ 1990-04-30 ┆ AUD ┆ CPIC_SA_P1M1ML12 ┆ 6.434599 ┆ 2.0 ┆ 30.0 ┆ 227.0 │\n",
+ "│ 1990-05-01 ┆ AUD ┆ CPIC_SA_P1M1ML12 ┆ 6.434599 ┆ 2.0 ┆ 31.0 ┆ 228.0 │\n",
+ "│ 1990-05-02 ┆ AUD ┆ CPIC_SA_P1M1ML12 ┆ 6.434599 ┆ 2.0 ┆ 32.0 ┆ 229.0 │\n",
+ "└────────────┴─────┴──────────────────┴──────────┴─────────┴─────────┴─────────┘"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# downloaded_df: pl.DataFrame = msyrs.download.download_jpmaqs_indicators_as_df(\n",
- "# client_id=DQ_CLIENT_ID,\n",
- "# client_secret=DQ_CLIENT_SECRET,\n",
- "# tickers=tickers,\n",
- "# )\n",
- "# downloaded_df.head(5)"
+ "downloaded_df: pl.DataFrame = msyrs.download.download_jpmaqs_indicators_as_df(\n",
+ " client_id=DQ_CLIENT_ID,\n",
+ " client_secret=DQ_CLIENT_SECRET,\n",
+ " tickers=tickers,\n",
+ ")\n",
+ "downloaded_df.head(5)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
+ "outputs": [],
+ "source": [
+ "downloaded_df = None"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
@@ -186,7 +227,7 @@
"Downloaded JPMAQS catalogue with 18711 tickers.\n",
"Removed 21/600 expressions that are not in the JPMaQS catalogue.\n",
"Downloading data from JPMaQS.\n",
- "Timestamp UTC: 2024-11-22 17:13:07\n",
+ "Timestamp UTC: 2024-11-22 20:35:07\n",
"Connection successful!\n"
]
},
@@ -194,8 +235,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "Requesting data: 100%|██████████| 29/29 [00:05<00:00, 4.91it/s]\n",
- "Downloading data: 100%|██████████| 29/29 [00:22<00:00, 1.26it/s]\n"
+ "Requesting data: 100%|██████████| 29/29 [00:05<00:00, 4.93it/s]\n",
+ "Downloading data: 100%|██████████| 29/29 [00:16<00:00, 1.80it/s]\n"
]
},
{
@@ -219,14 +260,14 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken to load qdf batch: 1.8986454010009766\n"
+ "Time taken to load qdf batch: 1.1382660865783691\n"
]
},
{
@@ -256,7 +297,7 @@
"└────────────┴─────┴──────────────────┴──────────┴─────────┴─────────┴─────────┘"
]
},
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -280,16 +321,16 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "275.89989376068115"
+ "275.7299613952637"
]
},
- "execution_count": 10,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -300,22 +341,179 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " real_date | \n",
+ " cid | \n",
+ " xcat | \n",
+ " value | \n",
+ " grading | \n",
+ " eop_lag | \n",
+ " mop_lag | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 1990-04-26 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 26 | \n",
+ " 223 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 1990-04-27 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 27 | \n",
+ " 224 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 1990-04-30 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 30 | \n",
+ " 227 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 1990-05-01 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 31 | \n",
+ " 228 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 1990-05-02 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 32 | \n",
+ " 229 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 5285577 | \n",
+ " 2024-11-08 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.097534 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285578 | \n",
+ " 2024-11-12 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.189884 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285579 | \n",
+ " 2024-11-13 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.108095 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285580 | \n",
+ " 2024-11-14 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.060968 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285581 | \n",
+ " 2024-11-15 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.102066 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5285582 rows × 7 columns
\n",
+ "
"
+ ],
"text/plain": [
- "871.0723962783813"
+ " real_date cid xcat value grading eop_lag mop_lag\n",
+ "0 1990-04-26 AUD CPIC_SA_P1M1ML12 6.434599 2.0 26 223\n",
+ "1 1990-04-27 AUD CPIC_SA_P1M1ML12 6.434599 2.0 27 224\n",
+ "2 1990-04-30 AUD CPIC_SA_P1M1ML12 6.434599 2.0 30 227\n",
+ "3 1990-05-01 AUD CPIC_SA_P1M1ML12 6.434599 2.0 31 228\n",
+ "4 1990-05-02 AUD CPIC_SA_P1M1ML12 6.434599 2.0 32 229\n",
+ "... ... ... ... ... ... ... ...\n",
+ "5285577 2024-11-08 ZAR RYLDIRS05Y_NSA 3.097534 1.0 0 0\n",
+ "5285578 2024-11-12 ZAR RYLDIRS05Y_NSA 3.189884 1.0 0 0\n",
+ "5285579 2024-11-13 ZAR RYLDIRS05Y_NSA 3.108095 1.0 0 0\n",
+ "5285580 2024-11-14 ZAR RYLDIRS05Y_NSA 3.060968 1.0 0 0\n",
+ "5285581 2024-11-15 ZAR RYLDIRS05Y_NSA 3.102066 1.0 0 0\n",
+ "\n",
+ "[5285582 rows x 7 columns]"
]
},
- "execution_count": 11,
+ "execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "big_df.to_pandas().memory_usage(deep=True).sum() / 1024**2"
+ "big_df.to_pandas()"
]
},
{
@@ -326,7 +524,7 @@
{
"data": {
"text/plain": [
- "211.8466453552246"
+ "789.8839149475098"
]
},
"execution_count": 12,
@@ -334,6 +532,203 @@
"output_type": "execute_result"
}
],
+ "source": [
+ "big_df.to_pandas().memory_usage(deep=True).sum() / 1024**2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " real_date | \n",
+ " cid | \n",
+ " xcat | \n",
+ " value | \n",
+ " grading | \n",
+ " eop_lag | \n",
+ " mop_lag | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 1990-04-26 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 26 | \n",
+ " 223 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 1990-04-27 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 27 | \n",
+ " 224 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 1990-04-30 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 30 | \n",
+ " 227 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 1990-05-01 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 31 | \n",
+ " 228 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 1990-05-02 | \n",
+ " AUD | \n",
+ " CPIC_SA_P1M1ML12 | \n",
+ " 6.434599 | \n",
+ " 2.0 | \n",
+ " 32 | \n",
+ " 229 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 5285577 | \n",
+ " 2024-11-08 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.097534 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285578 | \n",
+ " 2024-11-12 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.189884 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285579 | \n",
+ " 2024-11-13 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.108095 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285580 | \n",
+ " 2024-11-14 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.060968 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 5285581 | \n",
+ " 2024-11-15 | \n",
+ " ZAR | \n",
+ " RYLDIRS05Y_NSA | \n",
+ " 3.102066 | \n",
+ " 1.0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5285582 rows × 7 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " real_date cid xcat value grading eop_lag mop_lag\n",
+ "0 1990-04-26 AUD CPIC_SA_P1M1ML12 6.434599 2.0 26 223\n",
+ "1 1990-04-27 AUD CPIC_SA_P1M1ML12 6.434599 2.0 27 224\n",
+ "2 1990-04-30 AUD CPIC_SA_P1M1ML12 6.434599 2.0 30 227\n",
+ "3 1990-05-01 AUD CPIC_SA_P1M1ML12 6.434599 2.0 31 228\n",
+ "4 1990-05-02 AUD CPIC_SA_P1M1ML12 6.434599 2.0 32 229\n",
+ "... ... ... ... ... ... ... ...\n",
+ "5285577 2024-11-08 ZAR RYLDIRS05Y_NSA 3.097534 1.0 0 0\n",
+ "5285578 2024-11-12 ZAR RYLDIRS05Y_NSA 3.189884 1.0 0 0\n",
+ "5285579 2024-11-13 ZAR RYLDIRS05Y_NSA 3.108095 1.0 0 0\n",
+ "5285580 2024-11-14 ZAR RYLDIRS05Y_NSA 3.060968 1.0 0 0\n",
+ "5285581 2024-11-15 ZAR RYLDIRS05Y_NSA 3.102066 1.0 0 0\n",
+ "\n",
+ "[5285582 rows x 7 columns]"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "macrosynergy.management.types.QuantamentalDataFrame(big_df.to_pandas())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "211.71554374694824"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"macrosynergy.management.types.QuantamentalDataFrame(big_df.to_pandas()).memory_usage(\n",
" deep=True\n",
@@ -342,24 +737,24 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"sel_cids = [\"USD\", \"EUR\", \"GBP\", \"AUD\", \"CAD\"]\n",
- "start = \"1999-11-14\""
+ "start = \"1990-01-01\""
]
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken to reduce qdf: 0.34674978256225586\n"
+ "Time taken to reduce qdf: 0.2668800354003906\n"
]
},
{
@@ -372,10 +767,10 @@
" white-space: pre-wrap;\n",
"}\n",
"\n",
- "shape: (62_363, 7)real_date | cid | xcat | value | grading | eop_lag | mop_lag |
---|
date | str | str | f64 | f64 | i64 | i64 |
2000-05-04 | "AUD" | "EQXR_NSA" | -1.251605 | 1.0 | 0 | 0 |
2000-05-05 | "AUD" | "EQXR_NSA" | 1.787455 | 1.0 | 0 | 0 |
2000-05-08 | "AUD" | "EQXR_NSA" | -0.574713 | 1.0 | 0 | 0 |
2000-05-09 | "AUD" | "EQXR_NSA" | -0.931278 | 1.0 | 0 | 0 |
2000-05-10 | "AUD" | "EQXR_NSA" | -1.523501 | 1.0 | 0 | 0 |
… | … | … | … | … | … | … |
2024-11-15 | "USD" | "EQXR_VT10" | -1.198544 | 1.0 | 0 | 0 |
2024-11-18 | "USD" | "EQXR_VT10" | 0.349312 | 1.0 | 0 | 0 |
2024-11-19 | "USD" | "EQXR_VT10" | 0.2776 | 1.0 | 0 | 0 |
2024-11-20 | "USD" | "EQXR_VT10" | -0.014759 | 1.0 | 0 | 0 |
2024-11-21 | "USD" | "EQXR_VT10" | 0.483426 | 1.0 | 0 | 0 |
"
+ "shape: (73_069, 7)real_date | cid | xcat | value | grading | eop_lag | mop_lag |
---|
date | str | str | f64 | f64 | i64 | i64 |
2000-05-04 | "AUD" | "EQXR_NSA" | -1.251605 | 1.0 | 0 | 0 |
2000-05-05 | "AUD" | "EQXR_NSA" | 1.787455 | 1.0 | 0 | 0 |
2000-05-08 | "AUD" | "EQXR_NSA" | -0.574713 | 1.0 | 0 | 0 |
2000-05-09 | "AUD" | "EQXR_NSA" | -0.931278 | 1.0 | 0 | 0 |
2000-05-10 | "AUD" | "EQXR_NSA" | -1.523501 | 1.0 | 0 | 0 |
… | … | … | … | … | … | … |
2024-11-08 | "USD" | "EQXR_VT10" | 0.313875 | 1.0 | 0 | 0 |
2024-11-12 | "USD" | "EQXR_VT10" | -0.272457 | 1.0 | 0 | 0 |
2024-11-13 | "USD" | "EQXR_VT10" | 0.043729 | 1.0 | 0 | 0 |
2024-11-14 | "USD" | "EQXR_VT10" | -0.549983 | 1.0 | 0 | 0 |
2024-11-15 | "USD" | "EQXR_VT10" | -1.198544 | 1.0 | 0 | 0 |
"
],
"text/plain": [
- "shape: (62_363, 7)\n",
+ "shape: (73_069, 7)\n",
"┌────────────┬─────┬───────────┬───────────┬─────────┬─────────┬─────────┐\n",
"│ real_date ┆ cid ┆ xcat ┆ value ┆ grading ┆ eop_lag ┆ mop_lag │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
@@ -387,15 +782,15 @@
"│ 2000-05-09 ┆ AUD ┆ EQXR_NSA ┆ -0.931278 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2000-05-10 ┆ AUD ┆ EQXR_NSA ┆ -1.523501 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
+ "│ 2024-11-08 ┆ USD ┆ EQXR_VT10 ┆ 0.313875 ┆ 1.0 ┆ 0 ┆ 0 │\n",
+ "│ 2024-11-12 ┆ USD ┆ EQXR_VT10 ┆ -0.272457 ┆ 1.0 ┆ 0 ┆ 0 │\n",
+ "│ 2024-11-13 ┆ USD ┆ EQXR_VT10 ┆ 0.043729 ┆ 1.0 ┆ 0 ┆ 0 │\n",
+ "│ 2024-11-14 ┆ USD ┆ EQXR_VT10 ┆ -0.549983 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-15 ┆ USD ┆ EQXR_VT10 ┆ -1.198544 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-18 ┆ USD ┆ EQXR_VT10 ┆ 0.349312 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-19 ┆ USD ┆ EQXR_VT10 ┆ 0.2776 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-20 ┆ USD ┆ EQXR_VT10 ┆ -0.014759 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-21 ┆ USD ┆ EQXR_VT10 ┆ 0.483426 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"└────────────┴─────┴───────────┴───────────┴─────────┴─────────┴─────────┘"
]
},
- "execution_count": 14,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -415,14 +810,14 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken to reduce qdf: 0.13223624229431152\n"
+ "Time taken to reduce qdf: 0.057086944580078125\n"
]
}
],
@@ -434,14 +829,14 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken to reduce qdf: 0.3902719020843506\n"
+ "Time taken to reduce qdf: 0.298140287399292\n"
]
}
],
@@ -457,14 +852,14 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken to reduce qdf: 0.171736478805542\n"
+ "Time taken to reduce qdf: 0.08732080459594727\n"
]
}
],
@@ -476,14 +871,14 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken: 0.024325132369995117\n"
+ "Time taken: 0.01651310920715332\n"
]
},
{
@@ -518,7 +913,7 @@
"└────────────┴─────┴──────────┴───────────┴─────────┴─────────┴─────────┘"
]
},
- "execution_count": 18,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -532,14 +927,14 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken: 0.8326597213745117\n"
+ "Time taken: 0.4808037281036377\n"
]
}
],
@@ -551,7 +946,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 21,
"metadata": {},
"outputs": [
{
@@ -564,7 +959,7 @@
" white-space: pre-wrap;\n",
"}\n",
"\n",
- "shape: (10, 7)real_date | cid | xcat | value | grading | eop_lag | mop_lag |
---|
date | str | str | f64 | f64 | i64 | i64 |
2024-11-07 | "GBP" | "FXXR_VT10" | 0.806682 | 1.0 | 0 | 0 |
2024-11-08 | "GBP" | "FXXR_VT10" | -0.247346 | 1.0 | 0 | 0 |
2024-11-12 | "GBP" | "FXXR_VT10" | -1.083137 | 1.0 | 0 | 0 |
2024-11-13 | "GBP" | "FXXR_VT10" | -0.328958 | 1.0 | 0 | 0 |
2024-11-14 | "GBP" | "FXXR_VT10" | -0.110526 | 1.0 | 0 | 0 |
2024-11-15 | "GBP" | "FXXR_VT10" | -0.700977 | 1.0 | 0 | 0 |
2024-11-18 | "GBP" | "FXXR_VT10" | -0.140805 | 1.0 | 0 | 0 |
2024-11-19 | "GBP" | "FXXR_VT10" | 0.223372 | 1.0 | 0 | 0 |
2024-11-20 | "GBP" | "FXXR_VT10" | 0.361783 | 1.0 | 0 | 0 |
2024-11-21 | "GBP" | "FXXR_VT10" | -0.375365 | 1.0 | 0 | 0 |
"
+ "shape: (10, 7)real_date | cid | xcat | value | grading | eop_lag | mop_lag |
---|
date | str | str | f64 | f64 | i64 | i64 |
2024-11-01 | "GBP" | "FXXR_VT10" | 1.37805 | 1.0 | 0 | 0 |
2024-11-04 | "GBP" | "FXXR_VT10" | -0.111931 | 1.0 | 0 | 0 |
2024-11-05 | "GBP" | "FXXR_VT10" | 0.25294 | 1.0 | 0 | 0 |
2024-11-06 | "GBP" | "FXXR_VT10" | -0.175161 | 1.0 | 0 | 0 |
2024-11-07 | "GBP" | "FXXR_VT10" | 0.806682 | 1.0 | 0 | 0 |
2024-11-08 | "GBP" | "FXXR_VT10" | -0.247346 | 1.0 | 0 | 0 |
2024-11-12 | "GBP" | "FXXR_VT10" | -1.083137 | 1.0 | 0 | 0 |
2024-11-13 | "GBP" | "FXXR_VT10" | -0.328958 | 1.0 | 0 | 0 |
2024-11-14 | "GBP" | "FXXR_VT10" | -0.110526 | 1.0 | 0 | 0 |
2024-11-15 | "GBP" | "FXXR_VT10" | -0.700977 | 1.0 | 0 | 0 |
"
],
"text/plain": [
"shape: (10, 7)\n",
@@ -573,20 +968,20 @@
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ date ┆ str ┆ str ┆ f64 ┆ f64 ┆ i64 ┆ i64 │\n",
"╞════════════╪═════╪═══════════╪═══════════╪═════════╪═════════╪═════════╡\n",
+ "│ 2024-11-01 ┆ GBP ┆ FXXR_VT10 ┆ 1.37805 ┆ 1.0 ┆ 0 ┆ 0 │\n",
+ "│ 2024-11-04 ┆ GBP ┆ FXXR_VT10 ┆ -0.111931 ┆ 1.0 ┆ 0 ┆ 0 │\n",
+ "│ 2024-11-05 ┆ GBP ┆ FXXR_VT10 ┆ 0.25294 ┆ 1.0 ┆ 0 ┆ 0 │\n",
+ "│ 2024-11-06 ┆ GBP ┆ FXXR_VT10 ┆ -0.175161 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-07 ┆ GBP ┆ FXXR_VT10 ┆ 0.806682 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-08 ┆ GBP ┆ FXXR_VT10 ┆ -0.247346 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-12 ┆ GBP ┆ FXXR_VT10 ┆ -1.083137 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-13 ┆ GBP ┆ FXXR_VT10 ┆ -0.328958 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-14 ┆ GBP ┆ FXXR_VT10 ┆ -0.110526 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"│ 2024-11-15 ┆ GBP ┆ FXXR_VT10 ┆ -0.700977 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-18 ┆ GBP ┆ FXXR_VT10 ┆ -0.140805 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-19 ┆ GBP ┆ FXXR_VT10 ┆ 0.223372 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-20 ┆ GBP ┆ FXXR_VT10 ┆ 0.361783 ┆ 1.0 ┆ 0 ┆ 0 │\n",
- "│ 2024-11-21 ┆ GBP ┆ FXXR_VT10 ┆ -0.375365 ┆ 1.0 ┆ 0 ┆ 0 │\n",
"└────────────┴─────┴───────────┴───────────┴─────────┴─────────┴─────────┘"
]
},
- "execution_count": 20,
+ "execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@@ -597,14 +992,14 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken: 0.0014519691467285156\n",
+ "Time taken: 0.0010075569152832031\n",
"Time taken: 0.0\n"
]
}
@@ -647,14 +1042,14 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken: 0.054981231689453125\n"
+ "Time taken: 0.05028486251831055\n"
]
}
],
@@ -666,32 +1061,13 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"new_pd_df = macrosynergy.management.types.QuantamentalDataFrame(new_pd_df)"
]
},
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Time taken: 2.785749673843384\n"
- ]
- }
- ],
- "source": [
- "starttime = time.time()\n",
- "new_pd_df.to_wide()\n",
- "print(\"Time taken: \", time.time() - starttime)"
- ]
- },
{
"cell_type": "code",
"execution_count": 25,
@@ -701,7 +1077,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Time taken: 58.54259753227234 seconds\n"
+ "Time taken: 2.0133273601531982\n"
+ ]
+ }
+ ],
+ "source": [
+ "starttime = time.time()\n",
+ "new_pd_df.to_wide()\n",
+ "print(\"Time taken: \", time.time() - starttime)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Time taken: 130.01306796073914 seconds\n"
]
}
],
@@ -727,7 +1122,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.0"
+ "version": "3.12.7"
}
},
"nbformat": 4,
diff --git a/src/py/download.rs b/src/_py/download.rs
similarity index 100%
rename from src/py/download.rs
rename to src/_py/download.rs
diff --git a/src/py/mod.rs b/src/_py/mod.rs
similarity index 65%
rename from src/py/mod.rs
rename to src/_py/mod.rs
index c65391b..7da3188 100644
--- a/src/py/mod.rs
+++ b/src/_py/mod.rs
@@ -1,16 +1,16 @@
-/// Python API for [`crate::utils::qdf`].
+/// Python wrapper for [`crate::utils::qdf`].
pub mod qdf;
-/// Python API for [`crate::download`].
+/// Python wrapper for [`crate::download`].
pub mod download;
-/// Python API for [`crate::panel`].
+/// Python wrapper for [`crate::panel`].
pub mod panel;
use pyo3::{prelude::*, wrap_pymodule};
-// use pyo3_polars::PyDataFrame;
+/// PyO3 bindings for the `msyrs` Python wrapper.
#[allow(deprecated)]
#[pymodule]
pub fn msyrs(_py: Python, m: &PyModule) -> PyResult<()> {
diff --git a/src/py/panel.rs b/src/_py/panel.rs
similarity index 100%
rename from src/py/panel.rs
rename to src/_py/panel.rs
diff --git a/src/py/qdf.rs b/src/_py/qdf.rs
similarity index 100%
rename from src/py/qdf.rs
rename to src/_py/qdf.rs
diff --git a/src/lib.rs b/src/lib.rs
index 0e58b7e..f0fc571 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,7 +16,7 @@
//!
/// Documentation and type-stubs for the `msyrs` Python API.
-pub mod py;
+pub mod _py;
/// Implementation for the `download` module.
pub mod download;
@@ -29,4 +29,4 @@ pub mod panel;
/// PyO3 bindings for the `msyrs` Python API.
#[allow(unused_imports)]
-use py::msyrs;
+use _py::msyrs;
diff --git a/src/panel/historic_vol.rs b/src/panel/historic_vol.rs
index 50a72ad..74cdde5 100644
--- a/src/panel/historic_vol.rs
+++ b/src/panel/historic_vol.rs
@@ -48,6 +48,26 @@ fn flat_std(x: &Array1, remove_zeros: bool) -> f64 {
filtered_x.mapv(f64::abs).mean().unwrap_or(0.0)
}
+
+
+// #[allow(dead_code)]
+// fn single
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/// Calculate historic volatility.
/// Arguments:
/// - `df`: A Quantamental DataFrame.
@@ -81,5 +101,46 @@ pub fn historic_vol(
) -> Result> {
println!("Calculating historic volatility with the following parameters:");
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);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Ok(df.to_owned())
}