diff options
Diffstat (limited to 'python/notebooks/Curve Trades.ipynb')
| -rw-r--r-- | python/notebooks/Curve Trades.ipynb | 163 |
1 files changed, 148 insertions, 15 deletions
diff --git a/python/notebooks/Curve Trades.ipynb b/python/notebooks/Curve Trades.ipynb index 744eaa89..d8d1b7ce 100644 --- a/python/notebooks/Curve Trades.ipynb +++ b/python/notebooks/Curve Trades.ipynb @@ -2,11 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ - "import analytics.curve_trades as ct\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import numpy as np\n", @@ -15,17 +14,31 @@ "\n", "from ipywidgets import widgets\n", "from analytics.scenarios import run_curve_scenarios\n", + "from analytics.curve_trades import curve_spread_diff, spreads_diff_table, theta_matrix_by_series\n", "from scipy.optimize import brentq\n", - "from utils.db import dbengine\n", - "\n", - "%matplotlib inline" + "from utils.db import dbengine" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "48e324f064aa450f9ca82dd064a3082f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Dropdown(description='Index:', options=('IG', 'EU'), value='IG')" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "w = widgets.Dropdown(\n", " options=['IG', 'EU'],\n", @@ -38,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -48,23 +61,143 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "260c86a418564dbe92079d66f6da64d5", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "<matplotlib.axes._subplots.AxesSubplot at 0x7f6018e50e50>" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#On the run spread differences\n", - "spreads_diff = ct.curve_spread_diff(index, 6)\n", + "spreads_diff = curve_spread_diff(index, 6)\n", "spreads_diff.plot()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1f6848430d7c4cdca60133d2b6edf190", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "<div>\n", + "<style scoped>\n", + " .dataframe tbody tr th:only-of-type {\n", + " vertical-align: middle;\n", + " }\n", + "\n", + " .dataframe tbody tr th {\n", + " vertical-align: top;\n", + " }\n", + "\n", + " .dataframe thead th {\n", + " text-align: right;\n", + " }\n", + "</style>\n", + "<table border=\"1\" class=\"dataframe\">\n", + " <thead>\n", + " <tr style=\"text-align: right;\">\n", + " <th></th>\n", + " <th>3-5</th>\n", + " <th>5-7</th>\n", + " <th>7-10</th>\n", + " <th>5-10</th>\n", + " </tr>\n", + " </thead>\n", + " <tbody>\n", + " <tr>\n", + " <th>min</th>\n", + " <td>21.219659</td>\n", + " <td>20.056528</td>\n", + " <td>16.047530</td>\n", + " <td>40.126583</td>\n", + " </tr>\n", + " <tr>\n", + " <th>max</th>\n", + " <td>34.068608</td>\n", + " <td>27.193659</td>\n", + " <td>24.195653</td>\n", + " <td>48.782836</td>\n", + " </tr>\n", + " <tr>\n", + " <th>mean</th>\n", + " <td>29.106575</td>\n", + " <td>24.588519</td>\n", + " <td>20.883679</td>\n", + " <td>45.472198</td>\n", + " </tr>\n", + " <tr>\n", + " <th>current</th>\n", + " <td>21.603603</td>\n", + " <td>21.392519</td>\n", + " <td>23.498862</td>\n", + " <td>44.891380</td>\n", + " </tr>\n", + " <tr>\n", + " <th>zscore</th>\n", + " <td>-2.698133</td>\n", + " <td>-2.206748</td>\n", + " <td>1.378322</td>\n", + " <td>-0.287849</td>\n", + " </tr>\n", + " </tbody>\n", + "</table>\n", + "</div>" + ], + "text/plain": [ + " 3-5 5-7 7-10 5-10\n", + "min 21.219659 20.056528 16.047530 40.126583\n", + "max 34.068608 27.193659 24.195653 48.782836\n", + "mean 29.106575 24.588519 20.883679 45.472198\n", + "current 21.603603 21.392519 23.498862 44.891380\n", + "zscore -2.698133 -2.206748 1.378322 -0.287849" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#Table of Spread Differences, and Z-score of current spread differences\n", - "ct.spreads_diff_table(spreads_diff)" + "spreads_diff_table(spreads_diff)" ] }, { @@ -512,7 +645,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.0" + "version": "3.8.1" } }, "nbformat": 4, |
