diff options
Diffstat (limited to 'python/notebooks/Curve Trades.ipynb')
| -rw-r--r-- | python/notebooks/Curve Trades.ipynb | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/python/notebooks/Curve Trades.ipynb b/python/notebooks/Curve Trades.ipynb index f0027e40..5637beaf 100644 --- a/python/notebooks/Curve Trades.ipynb +++ b/python/notebooks/Curve Trades.ipynb @@ -9,7 +9,8 @@ "import curve_trades as ct\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", - "from ipywidgets import widgets" + "from ipywidgets import widgets\n", + "import pandas as pd" ] }, { @@ -135,7 +136,7 @@ "metadata": {}, "outputs": [], "source": [ - "model = ct.curve_model()\n", + "model = ct.curve_model('5yr', '10yr')\n", "model_results = ct.curve_model_results(model[0], model[1])" ] }, @@ -145,7 +146,10 @@ "metadata": {}, "outputs": [], "source": [ - "model[1].summary()" + "#Scenario Anslysis on current position\n", + "report_date = (pd.datetime.today() - pd.offsets.BDay(1)).normalize()\n", + "curve_pos = ct.curve_pos(report_date)\n", + "origpv = curve_pos.pv" ] }, { @@ -154,8 +158,9 @@ "metadata": {}, "outputs": [], "source": [ - "#Var on current position\n", - "results = ct.curve_var()" + "flat_curve = ct.curve_shape(report_date, percentile = .05)\n", + "for ind in curve_pos.indices:\n", + " ind.spread = flat_curve((pd.to_datetime(ind.end_date) - trade_date).days/365)" ] }, { @@ -164,19 +169,8 @@ "metadata": {}, "outputs": [], "source": [ - "model_results" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "results\n", - "#first number: at 5% flatness\n", - "#second number: at predicted curve shape\n", - "#third number: at 5% flatness given duration and spread" + "#PNL in flattening to a 5% case\n", + "curve_pos.pv - origpv" ] }, { @@ -226,7 +220,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.6.5" } }, "nbformat": 4, |
