mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 13:10:00 +00:00
updated python ntoebook
This commit is contained in:
parent
b72a9b3441
commit
6ea183419a
@ -12,55 +12,64 @@
|
||||
"# source .venv/bin/activate\n",
|
||||
"./.venv/Scripts/activate\n",
|
||||
"\n",
|
||||
"pip install maturin\n",
|
||||
"pip install maturin ipywidgets\n",
|
||||
"\n",
|
||||
"maturin develop --release\n",
|
||||
"```"
|
||||
"```\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Import Python packages\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"e:\\Work\\ruzt\\msyrs\\.venv\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
||||
" from .autonotebook import tqdm as notebook_tqdm\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import macrosynergy\n",
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n"
|
||||
"import numpy as np\n",
|
||||
"import polars as pl\n",
|
||||
"import os"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Import Python bindings - `msyrs`\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import msyrs\n",
|
||||
"import polars as pl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"DATA_FOLDER_PATH = \"E:/Work/jpmaqs-data\""
|
||||
"import msyrs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"DATA_FOLDER_PATH = \"E:/Work/jpmaqs-data\"\n",
|
||||
"\n",
|
||||
"DQ_CLIENT_ID = os.getenv(\"DQ_CLIENT_ID\")\n",
|
||||
"DQ_CLIENT_SECRET = os.getenv(\"DQ_CLIENT_SECRET\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -89,7 +98,7 @@
|
||||
"└────────────┴─────┴────────────────────┴───────────┴─────────┴─────────┴─────────┘"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -104,7 +113,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -115,8 +124,7 @@
|
||||
"ecos = \"CPIC_SA_P1M1ML12.CPIC_SJA_P3M3ML3AR.CPIC_SJA_P6M6ML6AR.CPIH_SA_P1M1ML12.CPIH_SJA_P3M3ML3AR.CPIH_SJA_P6M6ML6AR.INFTEFF_NSA.INTRGDP_NSA_P1M1ML12_3MMA.INTRGDPv5Y_NSA_P1M1ML12_3MMA.PCREDITGDP_SJA_D1M1ML12.RGDP_SA_P1Q1QL4_20QMA.RYLDIRS02Y_NSA.RYLDIRS05Y_NSA.PCREDITBN_SJA_P1M1ML12\".split(\n",
|
||||
" \".\"\n",
|
||||
")\n",
|
||||
"[\"CPIC\", \"CPIH\", \"INFTEFF\", \"INTRGDP\", \"INTRGDPv5Y\", \"PCREDITGDP\", \"RGDP\", \"RYLDIRS\", \"PCREDITBN\"]\n",
|
||||
"[\"\"]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"mkts = \"DU02YXR_NSA.DU05YXR_NSA.DU02YXR_VT10.DU05YXR_VT10.EQXR_NSA.EQXR_VT10.FXXR_NSA.FXXR_VT10.FXCRR_NSA.FXTARGETED_NSA.FXUNTRADABLE_NSA\".split(\n",
|
||||
" \".\"\n",
|
||||
@ -128,7 +136,53 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div><style>\n",
|
||||
".dataframe > thead > tr,\n",
|
||||
".dataframe > tbody > tr {\n",
|
||||
" text-align: right;\n",
|
||||
" white-space: pre-wrap;\n",
|
||||
"}\n",
|
||||
"</style>\n",
|
||||
"<small>shape: (5, 7)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>real_date</th><th>cid</th><th>xcat</th><th>value</th><th>grading</th><th>eop_lag</th><th>mop_lag</th></tr><tr><td>date</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1990-04-26</td><td>"AUD"</td><td>"CPIC_SA_P1M1ML12"</td><td>6.434599</td><td>2.0</td><td>26.0</td><td>223.0</td></tr><tr><td>1990-04-27</td><td>"AUD"</td><td>"CPIC_SA_P1M1ML12"</td><td>6.434599</td><td>2.0</td><td>27.0</td><td>224.0</td></tr><tr><td>1990-04-30</td><td>"AUD"</td><td>"CPIC_SA_P1M1ML12"</td><td>6.434599</td><td>2.0</td><td>30.0</td><td>227.0</td></tr><tr><td>1990-05-01</td><td>"AUD"</td><td>"CPIC_SA_P1M1ML12"</td><td>6.434599</td><td>2.0</td><td>31.0</td><td>228.0</td></tr><tr><td>1990-05-02</td><td>"AUD"</td><td>"CPIC_SA_P1M1ML12"</td><td>6.434599</td><td>2.0</td><td>32.0</td><td>229.0</td></tr></tbody></table></div>"
|
||||
],
|
||||
"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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -158,7 +212,7 @@
|
||||
"└────────────┴─────┴──────────────────┴──────────┴─────────┴─────────┴─────────┘"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -172,7 +226,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -182,7 +236,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -218,7 +272,7 @@
|
||||
"└────────────┴─────┴───────────┴───────────┴─────────┴─────────┴─────────┘"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -235,7 +289,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -247,7 +301,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -282,7 +336,7 @@
|
||||
"└────────────┴─────┴──────────┴───────────┴─────────┴─────────┴─────────┘"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -295,7 +349,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -330,7 +384,7 @@
|
||||
"└────────────┴─────┴───────────┴───────────┴─────────┴─────────┴─────────┘"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user