aboutsummaryrefslogtreecommitdiffstats
path: root/python/notebooks
diff options
context:
space:
mode:
Diffstat (limited to 'python/notebooks')
-rw-r--r--python/notebooks/Option Trades.ipynb142
1 files changed, 142 insertions, 0 deletions
diff --git a/python/notebooks/Option Trades.ipynb b/python/notebooks/Option Trades.ipynb
new file mode 100644
index 00000000..4440d5f2
--- /dev/null
+++ b/python/notebooks/Option Trades.ipynb
@@ -0,0 +1,142 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from analytics import Swaption, BlackSwaption, Index, VolatilitySurface, Portfolio\n",
+ "from analytics.scenarios import run_swaption_scenarios, run_index_scenarios, run_portfolio_scenarios\n",
+ "import datetime\n",
+ "\n",
+ "import swaption_calendar_spread as spread"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Delta Chart: Red = Long Risk, Blue = Short Risk"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Ad hoc\n",
+ "option_delta = Index.from_name('HY', 28, '5yr')\n",
+ "option_delta.price = 107.625\n",
+ "option1 = BlackSwaption(option_delta, datetime.date(2017, 9, 20), 107, option_type=\"payer\")\n",
+ "option2 = BlackSwaption(option_delta, datetime.date(2017, 9, 20), 105, option_type=\"payer\")\n",
+ "option1.sigma = .270\n",
+ "option2.sigma = .3625\n",
+ "option1.notional = 20_000_000\n",
+ "option2.notional = 40_000_000\n",
+ "option1.direction = 'Long'\n",
+ "option2.direction = 'Short'\n",
+ "option_delta.notional = -2000000\n",
+ "#option_delta.notional = option_delta.notional - option_delta2.notional\n",
+ "if option_delta.notional < 0:\n",
+ " option_delta.direction = 'Seller'\n",
+ " option_delta.notional = abs(option_delta.notional)\n",
+ "portf = Portfolio([option1, option2, option_delta])\n",
+ "spread.plot_trade_scenarios(portf)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Dec Jan 2017 Trade\n",
+ "option_delta = Index.from_tradeid(864)\n",
+ "option1 = BlackSwaption.from_tradeid(3, option_delta)\n",
+ "option2 = BlackSwaption.from_tradeid(4, option_delta)\n",
+ "portf = Portfolio([option1, option2, option_delta])\n",
+ "spread.plot_trade_scenarios(portf)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Feb 2017: Sell May Buy April Calendar Trade\n",
+ "option_delta = Index.from_tradeid(870)\n",
+ "option1 = BlackSwaption.from_tradeid(5, option_delta)\n",
+ "option2 = BlackSwaption.from_tradeid(6, option_delta)\n",
+ "portf = Portfolio([option1, option2, option_delta])\n",
+ "spread.plot_trade_scenarios(portf)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#April 2017: Sell May Buy June Calendar Trade\n",
+ "option_delta = Index.from_tradeid(874)\n",
+ "option1 = BlackSwaption.from_tradeid(7, option_delta)\n",
+ "option2 = BlackSwaption.from_tradeid(8, option_delta)\n",
+ "portf = Portfolio([option1, option2, option_delta])\n",
+ "spread.plot_trade_scenarios(portf)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#June July 2017 Calendar Trade\n",
+ "option_delta_pf = Index.from_tradeid(874)\n",
+ "option_delta2_pf = Index.from_tradeid(879)\n",
+ "\n",
+ "option1_pf = BlackSwaption.from_tradeid(7, option_delta_pf)\n",
+ "option2_pf = BlackSwaption.from_tradeid(9, option_delta_pf)\n",
+ "option_delta_pf.notional = 50_335_169\n",
+ "\n",
+ "portf = Portfolio([option1_pf, option2_pf, option_delta_pf])\n",
+ "portf.trade_date = datetime.date(2017, 5, 17)\n",
+ "portf.mark()\n",
+ "spread.plot_trade_scenarios(portf)"
+ ]
+ },
+ {
+ "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.6.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}