aboutsummaryrefslogtreecommitdiffstats
path: root/python/notebooks/bespokes/Phoenix.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'python/notebooks/bespokes/Phoenix.ipynb')
-rw-r--r--python/notebooks/bespokes/Phoenix.ipynb163
1 files changed, 163 insertions, 0 deletions
diff --git a/python/notebooks/bespokes/Phoenix.ipynb b/python/notebooks/bespokes/Phoenix.ipynb
new file mode 100644
index 00000000..3d546576
--- /dev/null
+++ b/python/notebooks/bespokes/Phoenix.ipynb
@@ -0,0 +1,163 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from analytics.tranche_basket import DualCorrTranche, TrancheBasket\n",
+ "import datetime"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ig29 = TrancheBasket(\"IG\", 29, \"5yr\")\n",
+ "ig29.tweak()\n",
+ "ig29.build_skew()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "phoenix = DualCorrTranche(\"BS\", 4, \"3yr\",attach=15, detach=30, corr_attach=None, corr_detach=None, tranche_running=100)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "phoenix.value_date=datetime.date.today()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "phoenix.mark(skew=ig29.skew)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "phoenix"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "(phoenix.spread, phoenix.duration, phoenix._index.spread())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Phoenix\n",
+ "import pandas as pd\n",
+ "date_range = pd.bdate_range(end=datetime.date.today(), periods=20, freq = '3B')\n",
+ "df = pd.DataFrame(index = date_range, columns = ['spread', 'duration', 'port_spread'])\n",
+ "index = TrancheBasket(\"IG\", 29, \"5yr\")\n",
+ "tranche = DualCorrTranche(\"BS\", 4, \"3yr\",attach=15, detach=30, corr_attach=None, corr_detach=None, tranche_running=100)\n",
+ "for date in date_range:\n",
+ " index.value_date = date\n",
+ " index.tweak()\n",
+ " index.build_skew()\n",
+ " tranche.value_date = date\n",
+ " tranche.mark(skew=index.skew)\n",
+ " df.loc[date] = [tranche.spread, tranche.duration, tranche._index.spread()[0]/10000]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df[['spread', 'port_spread']].plot()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from pyisda.curve import Senior, MM14\n",
+ "palma._index[(\"CMACGM\", Senior, MM14)].to_series()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "jtd = palma.jump_to_default(ig29.skew)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "jtd.sort_values()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "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.7.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}