{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "99b92926",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# import libraries and set display options\n",
"import pandas as pd\n",
"import pprint\n",
"\n",
"# set frame width and center output\n",
"from IPython.core.display import display, HTML\n",
"display(HTML(\"\"\"\n",
"\n",
"\"\"\"))\n",
"\n",
"# pretty print options\n",
"pd.options.display.float_format = '{:20,.4f}'.format\n",
"pd.set_option('display.max_rows', None)\n",
"pd.set_option('display.max_columns', None)\n",
"pd.set_option('display.width', 3000)\n",
"pd.set_option('display.colheader_justify', 'center')\n",
"pd.set_option('display.precision', 3)\n",
"\n",
"# open file\n",
"x_rates = pd.read_csv(\"euro-daily-hist_1999_2020.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "eed88132",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/bz/5cj1tzbj5xn319rpqrw6gpmh0000gn/T/ipykernel_10747/1632861684.py:4: FutureWarning: The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.\n",
" x_rates.columns = x_rates.columns.str.replace(\"[\",\"\").str.replace(\"]\",\"\")\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" date | \n",
" australian_dollar | \n",
" bulgarian_lev | \n",
" brazilian_real | \n",
" canadian_dollar | \n",
" swiss_franc | \n",
" chinese_yuan | \n",
" cypriot_pound | \n",
" czech_koruna | \n",
" danish_krone | \n",
" estonian_kroon | \n",
" uk_pound | \n",
" greek_drachma | \n",
" hong_kong_dollar | \n",
" croatian_kuna | \n",
" hungarian_forint | \n",
" indonesian_rupiah | \n",
" israeli_shekel | \n",
" indian_rupee | \n",
" iceland_krona | \n",
" japanese_yen | \n",
" korean_won | \n",
" lithuanian_litas | \n",
" latvian_lats | \n",
" maltese_lira | \n",
" mexican_peso | \n",
" malaysian_ringgit | \n",
" norwegian_krone | \n",
" new_zealand_dollar | \n",
" philippine_peso | \n",
" polish_zloty | \n",
" romanian_leu | \n",
" russian_rouble | \n",
" swedish_krona | \n",
" singapore_dollar | \n",
" slovenian_tolar | \n",
" slovak_koruna | \n",
" thai_baht | \n",
" turkish_lira | \n",
" us_dollar | \n",
" south_african_rand | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1999-01-04 | \n",
" 1.9100 | \n",
" NaN | \n",
" NaN | \n",
" 1.8004 | \n",
" 1.6168 | \n",
" NaN | \n",
" 0.5823 | \n",
" 35.1070 | \n",
" 7.4501 | \n",
" 15.6466 | \n",
" 0.7111 | \n",
" 327.1500 | \n",
" 9.1332 | \n",
" NaN | \n",
" 251.4800 | \n",
" 9,433.6100 | \n",
" NaN | \n",
" NaN | \n",
" 81.4800 | \n",
" 133.7300 | \n",
" 1,398.5900 | \n",
" 4.7170 | \n",
" 0.6668 | \n",
" 0.4432 | \n",
" 11.6446 | \n",
" 4.4798 | \n",
" 8.8550 | \n",
" 2.2229 | \n",
" 45.5100 | \n",
" 4.0712 | \n",
" 1.3111 | \n",
" 25.2875 | \n",
" 9.4696 | \n",
" 1.9554 | \n",
" 189.0450 | \n",
" 42.9910 | \n",
" 42.6799 | \n",
" 0.3723 | \n",
" 1.1789 | \n",
" 6.9358 | \n",
"
\n",
" \n",
" 1 | \n",
" 1999-01-05 | \n",
" 1.8944 | \n",
" NaN | \n",
" NaN | \n",
" 1.7965 | \n",
" 1.6123 | \n",
" NaN | \n",
" 0.5823 | \n",
" 34.9170 | \n",
" 7.4495 | \n",
" 15.6466 | \n",
" 0.7122 | \n",
" 324.7000 | \n",
" 9.1341 | \n",
" NaN | \n",
" 250.8000 | \n",
" 9,314.5100 | \n",
" NaN | \n",
" NaN | \n",
" 81.5300 | \n",
" 130.9600 | \n",
" 1,373.0100 | \n",
" 4.7174 | \n",
" 0.6657 | \n",
" 0.4432 | \n",
" 11.5960 | \n",
" 4.4805 | \n",
" 8.7745 | \n",
" 2.2011 | \n",
" 44.7450 | \n",
" 4.0245 | \n",
" 1.3168 | \n",
" 26.5876 | \n",
" 9.4025 | \n",
" 1.9655 | \n",
" 188.7750 | \n",
" 42.8480 | \n",
" 42.5048 | \n",
" 0.3728 | \n",
" 1.1790 | \n",
" 6.7975 | \n",
"
\n",
" \n",
" 2 | \n",
" 1999-01-06 | \n",
" 1.8820 | \n",
" NaN | \n",
" NaN | \n",
" 1.7711 | \n",
" 1.6116 | \n",
" NaN | \n",
" 0.5820 | \n",
" 34.8500 | \n",
" 7.4452 | \n",
" 15.6466 | \n",
" 0.7076 | \n",
" 324.7200 | \n",
" 9.1010 | \n",
" NaN | \n",
" 250.6700 | \n",
" 9,337.6800 | \n",
" NaN | \n",
" NaN | \n",
" 81.5400 | \n",
" 131.4200 | \n",
" 1,359.5400 | \n",
" 4.6994 | \n",
" 0.6649 | \n",
" 0.4420 | \n",
" 11.4705 | \n",
" 4.4637 | \n",
" 8.7335 | \n",
" 2.1890 | \n",
" 44.8720 | \n",
" 4.0065 | \n",
" 1.3168 | \n",
" 27.4315 | \n",
" 9.3050 | \n",
" 1.9699 | \n",
" 188.7000 | \n",
" 42.7780 | \n",
" 42.6949 | \n",
" 0.3722 | \n",
" 1.1743 | \n",
" 6.7307 | \n",
"
\n",
" \n",
" 3 | \n",
" 1999-01-07 | \n",
" 1.8474 | \n",
" NaN | \n",
" NaN | \n",
" 1.7602 | \n",
" 1.6165 | \n",
" NaN | \n",
" 0.5819 | \n",
" 34.8860 | \n",
" 7.4431 | \n",
" 15.6466 | \n",
" 0.7058 | \n",
" 324.4000 | \n",
" 9.0131 | \n",
" NaN | \n",
" 250.0900 | \n",
" 9,218.7700 | \n",
" NaN | \n",
" NaN | \n",
" 81.0600 | \n",
" 129.4300 | \n",
" 1,337.1600 | \n",
" 4.6548 | \n",
" 0.6627 | \n",
" 0.4413 | \n",
" 11.5511 | \n",
" 4.4203 | \n",
" 8.6295 | \n",
" 2.1531 | \n",
" 44.4360 | \n",
" 4.0165 | \n",
" 1.3092 | \n",
" 26.9876 | \n",
" 9.1800 | \n",
" 1.9436 | \n",
" 188.8000 | \n",
" 42.7650 | \n",
" 42.1678 | \n",
" 0.3701 | \n",
" 1.1632 | \n",
" 6.8283 | \n",
"
\n",
" \n",
" 4 | \n",
" 1999-01-08 | \n",
" 1.8406 | \n",
" NaN | \n",
" NaN | \n",
" 1.7643 | \n",
" 1.6138 | \n",
" NaN | \n",
" 0.5819 | \n",
" 34.9380 | \n",
" 7.4433 | \n",
" 15.6466 | \n",
" 0.7094 | \n",
" 324.0000 | \n",
" 9.0302 | \n",
" NaN | \n",
" 250.1500 | \n",
" 9,321.6300 | \n",
" NaN | \n",
" NaN | \n",
" 80.9900 | \n",
" 130.0900 | \n",
" 1,366.7300 | \n",
" 4.6643 | \n",
" 0.6654 | \n",
" 0.4419 | \n",
" 11.4414 | \n",
" 4.4295 | \n",
" 8.5900 | \n",
" 2.1557 | \n",
" 44.2950 | \n",
" 4.0363 | \n",
" 1.3143 | \n",
" 27.2075 | \n",
" 9.1650 | \n",
" 1.9537 | \n",
" 188.8400 | \n",
" 42.5600 | \n",
" 42.5590 | \n",
" 0.3718 | \n",
" 1.1659 | \n",
" 6.7855 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" date australian_dollar bulgarian_lev brazilian_real canadian_dollar swiss_franc chinese_yuan cypriot_pound czech_koruna danish_krone estonian_kroon uk_pound greek_drachma hong_kong_dollar croatian_kuna hungarian_forint indonesian_rupiah israeli_shekel indian_rupee iceland_krona japanese_yen korean_won lithuanian_litas latvian_lats maltese_lira mexican_peso malaysian_ringgit norwegian_krone new_zealand_dollar philippine_peso polish_zloty romanian_leu russian_rouble swedish_krona singapore_dollar slovenian_tolar slovak_koruna thai_baht turkish_lira us_dollar south_african_rand \n",
"0 1999-01-04 1.9100 NaN NaN 1.8004 1.6168 NaN 0.5823 35.1070 7.4501 15.6466 0.7111 327.1500 9.1332 NaN 251.4800 9,433.6100 NaN NaN 81.4800 133.7300 1,398.5900 4.7170 0.6668 0.4432 11.6446 4.4798 8.8550 2.2229 45.5100 4.0712 1.3111 25.2875 9.4696 1.9554 189.0450 42.9910 42.6799 0.3723 1.1789 6.9358\n",
"1 1999-01-05 1.8944 NaN NaN 1.7965 1.6123 NaN 0.5823 34.9170 7.4495 15.6466 0.7122 324.7000 9.1341 NaN 250.8000 9,314.5100 NaN NaN 81.5300 130.9600 1,373.0100 4.7174 0.6657 0.4432 11.5960 4.4805 8.7745 2.2011 44.7450 4.0245 1.3168 26.5876 9.4025 1.9655 188.7750 42.8480 42.5048 0.3728 1.1790 6.7975\n",
"2 1999-01-06 1.8820 NaN NaN 1.7711 1.6116 NaN 0.5820 34.8500 7.4452 15.6466 0.7076 324.7200 9.1010 NaN 250.6700 9,337.6800 NaN NaN 81.5400 131.4200 1,359.5400 4.6994 0.6649 0.4420 11.4705 4.4637 8.7335 2.1890 44.8720 4.0065 1.3168 27.4315 9.3050 1.9699 188.7000 42.7780 42.6949 0.3722 1.1743 6.7307\n",
"3 1999-01-07 1.8474 NaN NaN 1.7602 1.6165 NaN 0.5819 34.8860 7.4431 15.6466 0.7058 324.4000 9.0131 NaN 250.0900 9,218.7700 NaN NaN 81.0600 129.4300 1,337.1600 4.6548 0.6627 0.4413 11.5511 4.4203 8.6295 2.1531 44.4360 4.0165 1.3092 26.9876 9.1800 1.9436 188.8000 42.7650 42.1678 0.3701 1.1632 6.8283\n",
"4 1999-01-08 1.8406 NaN NaN 1.7643 1.6138 NaN 0.5819 34.9380 7.4433 15.6466 0.7094 324.0000 9.0302 NaN 250.1500 9,321.6300 NaN NaN 80.9900 130.0900 1,366.7300 4.6643 0.6654 0.4419 11.4414 4.4295 8.5900 2.1557 44.2950 4.0363 1.3143 27.2075 9.1650 1.9537 188.8400 42.5600 42.5590 0.3718 1.1659 6.7855"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# strip brackets and trailing space from country names\n",
"# replace remaining space with underscore\n",
"# lower case all column names\n",
"x_rates.columns = x_rates.columns.str.replace(\"[\",\"\").str.replace(\"]\",\"\")\n",
"x_rates.columns = x_rates.columns.str.rstrip()\n",
"x_rates.columns = x_rates.columns.str.replace(\" \",\"_\")\n",
"x_rates.columns = x_rates.columns.str.lower()\n",
"\n",
"# rename columns\n",
"x_rates.rename(columns={\"period\\\\unit:\":\"date\",\n",
" \"chinese_yuan_renminbi\":\"chinese_yuan\",\n",
" \"uk_pound_sterling\":\"uk_pound\"}, inplace=True)\n",
"\n",
"# convert datetime\n",
"x_rates[\"date\"] = pd.to_datetime(x_rates[\"date\"])\n",
"\n",
"# resort and reindex\n",
"x_rates.sort_values(\"date\", inplace=True)\n",
"x_rates.reset_index(drop=True, inplace=True)\n",
"\n",
"# convert hyphens in currency columns to NaN\n",
"import numpy as np\n",
"x_rates = x_rates.replace(\"-\", np.nan)\n",
"\n",
"# convert exchange rate values to float\n",
"x_rates.iloc[:,1:] = x_rates.iloc[:,1:].astype(float)\n",
"\n",
"display(x_rates.head())"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "27c42da0",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import matplotlib.dates as mdates\n",
"from matplotlib.pyplot import cm\n",
"colors = iter([plt.cm.Set3(i) for i in range(20)])\n",
"\n",
"# create a list of data frame names\n",
"# not sure this is neccessary but trying df = df_list.index(currency) in the framer function doesn't seem to work\n",
"# create a list of data frames for each currency with log rate of the exchange rate, 30 day rolling mean, and year\n",
"# col_names = []\n",
"df_dict = {}\n",
"for currency in x_rates.columns[1:]:\n",
" df_name = currency\n",
"# col_names.append(df_name)\n",
" df = x_rates[[\"date\", currency]].copy()\n",
" df = df[df[currency].notna()]\n",
" df[\"log_rate\"] = np.log(df.iloc[:,1]/df.iloc[:,1].shift()) # getting the log of the exchange rate # double check this is the correct way to get log\n",
" df[\"rolling_mean_30\"] = df[currency].rolling(30).mean()\n",
" df[\"year\"] = df[\"date\"].dt.year\n",
" df_dict[currency] = df\n",
"\n",
"# currencies for comparison\n",
"high_freq = [df_dict[\"us_dollar\"], df_dict[\"japanese_yen\"], df_dict[\"uk_pound\"], df_dict[\"australian_dollar\"]]\n",
"low_freq = [df_dict[\"israeli_shekel\"], df_dict[\"philippine_peso\"], df_dict[\"malaysian_ringgit\"], df_dict[\"romanian_leu\"]]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "edeb8b57",
"metadata": {
"scrolled": false
},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'ipympl'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/var/folders/bz/5cj1tzbj5xn319rpqrw6gpmh0000gn/T/ipykernel_10747/3736899207.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# line graph showing Euro to four high frequency trading pairs overlapped\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m# widget can be turned on and off to discover specific dates\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_line_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'matplotlib'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'widget'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mfig\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0max\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubplots\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfigsize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m7.5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0max1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtwinx\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_line_magic\u001b[0;34m(self, magic_name, line, _stack_depth)\u001b[0m\n\u001b[1;32m 2349\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'local_ns'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_local_scope\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstack_depth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2350\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2351\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2352\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2353\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/decorator.py\u001b[0m in \u001b[0;36mfun\u001b[0;34m(*args, **kw)\u001b[0m\n\u001b[1;32m 230\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mkwsyntax\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 231\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkw\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkw\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msig\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 232\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mcaller\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mextras\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 233\u001b[0m \u001b[0mfun\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 234\u001b[0m \u001b[0mfun\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m\u001b[0;34m(f, *a, **k)\u001b[0m\n\u001b[1;32m 185\u001b[0m \u001b[0;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 187\u001b[0;31m \u001b[0mcall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 188\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/IPython/core/magics/pylab.py\u001b[0m in \u001b[0;36mmatplotlib\u001b[0;34m(self, line)\u001b[0m\n\u001b[1;32m 97\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Available matplotlib backends: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mbackends_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 99\u001b[0;31m \u001b[0mgui\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbackend\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshell\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0menable_matplotlib\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgui\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgui\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgui\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 100\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_show_matplotlib_backend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgui\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbackend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 101\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36menable_matplotlib\u001b[0;34m(self, gui)\u001b[0m\n\u001b[1;32m 3531\u001b[0m \u001b[0mgui\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbackend\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfind_gui_and_backend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpylab_gui_select\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3532\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3533\u001b[0;31m \u001b[0mpt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mactivate_matplotlib\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3534\u001b[0m \u001b[0mconfigure_inline_support\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbackend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3535\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/IPython/core/pylabtools.py\u001b[0m in \u001b[0;36mactivate_matplotlib\u001b[0;34m(backend)\u001b[0m\n\u001b[1;32m 357\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmatplotlib\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 358\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 359\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mswitch_backend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 360\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 361\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_needmain\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/matplotlib/pyplot.py\u001b[0m in \u001b[0;36mswitch_backend\u001b[0;34m(newbackend)\u001b[0m\n\u001b[1;32m 265\u001b[0m \u001b[0mbackend_name\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcbook\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_backend_module_name\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnewbackend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 267\u001b[0;31m \u001b[0;32mclass\u001b[0m \u001b[0mbackend_mod\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbackend_bases\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_Backend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 268\u001b[0m \u001b[0mlocals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvars\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimportlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimport_module\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 269\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/site-packages/matplotlib/pyplot.py\u001b[0m in \u001b[0;36mbackend_mod\u001b[0;34m()\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mbackend_mod\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbackend_bases\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_Backend\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 268\u001b[0;31m \u001b[0mlocals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvars\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimportlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimport_module\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 269\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 270\u001b[0m \u001b[0mrequired_framework\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_get_required_interactive_framework\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbackend_mod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/__init__.py\u001b[0m in \u001b[0;36mimport_module\u001b[0;34m(name, package)\u001b[0m\n\u001b[1;32m 125\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 126\u001b[0m \u001b[0mlevel\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 127\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_bootstrap\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_gcd_import\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mlevel\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpackage\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 128\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 129\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_gcd_import\u001b[0;34m(name, package, level)\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_find_and_load\u001b[0;34m(name, import_)\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_find_and_load_unlocked\u001b[0;34m(name, import_)\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_call_with_frames_removed\u001b[0;34m(f, *args, **kwds)\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_gcd_import\u001b[0;34m(name, package, level)\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_find_and_load\u001b[0;34m(name, import_)\u001b[0m\n",
"\u001b[0;32m/opt/anaconda3/envs/geo_env/lib/python3.9/importlib/_bootstrap.py\u001b[0m in \u001b[0;36m_find_and_load_unlocked\u001b[0;34m(name, import_)\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'ipympl'"
]
}
],
"source": [
"# line graph showing Euro to four high frequency trading pairs overlapped\n",
"# widget can be turned on and off to discover specific dates\n",
"%matplotlib widget\n",
"fig, ax = plt.subplots(figsize=(7.5,5))\n",
"ax1 = ax.twinx()\n",
"ax2 = ax.twinx()\n",
"ax3 = ax.twinx()\n",
"line = ax.plot(df_dict[\"us_dollar\"][\"date\"], df_dict[\"us_dollar\"][\"rolling_mean_30\"], 'tab:orange')\n",
"line_1 = ax1.plot(df_dict[\"us_dollar\"][\"date\"], df_dict[\"japanese_yen\"][\"rolling_mean_30\"], 'tab:blue')\n",
"line_2 = ax2.plot(df_dict[\"us_dollar\"][\"date\"], df_dict[\"uk_pound\"][\"rolling_mean_30\"], 'tab:green')\n",
"line_3 = ax3.plot(df_dict[\"us_dollar\"][\"date\"], df_dict[\"australian_dollar\"][\"rolling_mean_30\"], 'tab:red')\n",
"lines = [line, line_1, line_2, line_3]\n",
"for ax in ax, ax1, ax2, ax3:\n",
" ax.set(yticks=[])\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}