"use strict";(self.webpackChunkspeice_io=self.webpackChunkspeice_io||[]).push([["3241"],{1859:function(e,n,s){s.r(n),s.d(n,{assets:function(){return o},contentTitle:function(){return l},default:function(){return h},frontMatter:function(){return r},metadata:function(){return a},toc:function(){return m}});var a=s(8279),i=s(5893),t=s(65);let r={slug:"2015/11/autocallable",title:"Autocallable Bonds",date:new Date("2015-11-27T12:00:00.000Z"),authors:["bspeice"],tags:[]},l=void 0,o={authorsImageUrls:[void 0]},m=[{value:"Underlying simulation",id:"underlying-simulation",level:2},{value:"Defining the simulation",id:"defining-the-simulation",level:3},{value:"Example simulation",id:"example-simulation",level:3},{value:"Computing the term structure",id:"computing-the-term-structure",level:3},{value:"Illustrating the term structure",id:"illustrating-the-term-structure",level:3},{value:"The full underlying simulation",id:"the-full-underlying-simulation",level:3},{value:"Final simulation",id:"final-simulation",level:3},{value:"Athena Simulation",id:"athena-simulation",level:2},{value:"Phoenix without Memory Simulation",id:"phoenix-without-memory-simulation",level:2},{value:"Phoenix with Memory Simulation",id:"phoenix-with-memory-simulation",level:2}];function c(e){let n={a:"a",annotation:"annotation",code:"code",h1:"h1",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",math:"math",mi:"mi",mn:"mn",mo:"mo",mrow:"mrow",msub:"msub",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,t.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.p,{children:"For a final project, my group was tasked with understanding three exotic derivatives: The Athena, Phoenix without memory, and Phoenix with memory autocallable products."}),"\n",(0,i.jsx)(n.p,{children:"My only non-core class this semester has been in Structure Products. We've been surveying a wide variety of products, and the final project was to pick one to report on.\nBecause these are all very similar, we decided to demonstrate all 3 products at once."}),"\n",(0,i.jsxs)(n.p,{children:["What follows below is a notebook demonstrating the usage of ",(0,i.jsx)(n.a,{href:"http://julialang.com",children:"Julia"})," for Monte-Carlo simulation of some exotic products."]}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:"using Gadfly\n"})}),"\n",(0,i.jsx)(n.h1,{id:"athenaphoenix-simulation",children:"Athena/Phoenix Simulation"}),"\n",(0,i.jsx)(n.h2,{id:"underlying-simulation",children:"Underlying simulation"}),"\n",(0,i.jsxs)(n.p,{children:["In order to price the autocallable bonds, we need to simulate the underlying assets. Let's go ahead and set up the simulation first, as this lays the foundation for what we're trying to do. We're going to use ",(0,i.jsx)(n.a,{href:"http://finance.yahoo.com/q?s=jnj",children:"JNJ"})," as the basis for our simulation. This implies the following parameters:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsxs)(n.msub,{children:[(0,i.jsx)(n.mi,{children:"S"}),(0,i.jsx)(n.mn,{children:"0"})]})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"S_0"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.8333em",verticalAlign:"-0.15em"}}),(0,i.jsxs)(n.span,{className:"mord",children:[(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.05764em"},children:"S"}),(0,i.jsx)(n.span,{className:"msupsub",children:(0,i.jsxs)(n.span,{className:"vlist-t vlist-t2",children:[(0,i.jsxs)(n.span,{className:"vlist-r",children:[(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.3011em"},children:(0,i.jsxs)(n.span,{style:{top:"-2.55em",marginLeft:"-0.0576em",marginRight:"0.05em"},children:[(0,i.jsx)(n.span,{className:"pstrut",style:{height:"2.7em"}}),(0,i.jsx)(n.span,{className:"sizing reset-size6 size3 mtight",children:(0,i.jsx)(n.span,{className:"mord mtight",children:"0"})})]})}),(0,i.jsx)(n.span,{className:"vlist-s",children:"\u200B"})]}),(0,i.jsx)(n.span,{className:"vlist-r",children:(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.15em"},children:(0,i.jsx)(n.span,{})})})]})})]})]})})]})," = $102.2 (as of time of writing)"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsx)(n.mi,{children:"q"})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"q"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.625em",verticalAlign:"-0.1944em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.03588em"},children:"q"})]})})]})," = 2.84%"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsx)(n.mi,{children:"r"})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"r"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.4306em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.02778em"},children:"r"})]})})]})," = [.49, .9, 1.21, 1.45, 1.69] (term structure as of time of writing, linear interpolation)"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsx)(n.mi,{children:"\u03BC"})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"\\mu"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.625em",verticalAlign:"-0.1944em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"\u03BC"})]})})]})," = ",(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsxs)(n.mrow,{children:[(0,i.jsx)(n.mi,{children:"r"}),(0,i.jsx)(n.mo,{children:"\u2212"}),(0,i.jsx)(n.mi,{children:"q"})]}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"r - q"})]})})}),(0,i.jsxs)(n.span,{className:"katex-html","aria-hidden":"true",children:[(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.6667em",verticalAlign:"-0.0833em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.02778em"},children:"r"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,i.jsx)(n.span,{className:"mbin",children:"\u2212"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.625em",verticalAlign:"-0.1944em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.03588em"},children:"q"})]})]})]})," (note that this implies a negative drift because of current low rates)"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsx)(n.mi,{children:"\u03C3"})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"\\sigma"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.4306em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.03588em"},children:"\u03C3"})]})})]})," = ",(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsxs)(n.msub,{children:[(0,i.jsx)(n.mi,{children:"\u03C3"}),(0,i.jsxs)(n.mrow,{children:[(0,i.jsx)(n.mi,{children:"i"}),(0,i.jsx)(n.mi,{children:"m"}),(0,i.jsx)(n.mi,{children:"p"})]})]})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"\\sigma_{imp}"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.7167em",verticalAlign:"-0.2861em"}}),(0,i.jsxs)(n.span,{className:"mord",children:[(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.03588em"},children:"\u03C3"}),(0,i.jsx)(n.span,{className:"msupsub",children:(0,i.jsxs)(n.span,{className:"vlist-t vlist-t2",children:[(0,i.jsxs)(n.span,{className:"vlist-r",children:[(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.3117em"},children:(0,i.jsxs)(n.span,{style:{top:"-2.55em",marginLeft:"-0.0359em",marginRight:"0.05em"},children:[(0,i.jsx)(n.span,{className:"pstrut",style:{height:"2.7em"}}),(0,i.jsx)(n.span,{className:"sizing reset-size6 size3 mtight",children:(0,i.jsxs)(n.span,{className:"mord mtight",children:[(0,i.jsx)(n.span,{className:"mord mathnormal mtight",children:"im"}),(0,i.jsx)(n.span,{className:"mord mathnormal mtight",children:"p"})]})})]})}),(0,i.jsx)(n.span,{className:"vlist-s",children:"\u200B"})]}),(0,i.jsx)(n.span,{className:"vlist-r",children:(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.2861em"},children:(0,i.jsx)(n.span,{})})})]})})]})]})})]})," = 15.62% (from VIX implied volatility)"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"We additionally define some parameters for simulation:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"T"}),": The number of years to simulate"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"m"}),": The number of paths to simulate"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"n"}),": The number of steps to simulate in a year"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:"S0 = 102.2\nnominal = 100\nq = 2.84 / 100\n\u03C3 = 15.37 / 100\nterm = [0, .49, .9, 1.21, 1.45, 1.69] / 100 + 1\n\n###\n# Potential: Based on PEP\n# S0 = 100.6\n# \u03C3 = 14.86\n# q = 2.7\n###\n\n# Simulation parameters\nT = 5 # Using years as the unit of time\nn = 250 # simulations per year\nm = 100000 # paths\nnum_simulations = 5; # simulation rounds per price\n"})}),"\n",(0,i.jsx)(n.h3,{id:"defining-the-simulation",children:"Defining the simulation"}),"\n",(0,i.jsx)(n.p,{children:"To make things simpler, we simulate a single year at a time. This allows us to easily add in a dividend policy without too much difficulty, and update the simulation every year to match the term structure. The underlying uses GBM for simulation between years."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:'simulate_gbm = function(S0, \u03BC, \u03C3, T, n)\n # Set the initial state\n m = length(S0)\n t = T / n\n motion = zeros(m, n)\n motion[:,1] = S0\n \n # Build out all states\n for i=1:(n-1)\n motion[:,i+1] = motion[:,i] .* exp((\u03BC - \u03C3^2/2)*t) .* exp(sqrt(t) * \u03C3 .* randn(m))\n end\n \n return motion\nend\n\nfunction display_motion(motion, T)\n # Given a matrix of paths, display the motion\n n = length(motion[1,:])\n m = length(motion[:,1])\n x = repmat(1:n, m)\n \n # Calculate the ticks we\'re going to use. We\'d like to\n # have an xtick every month, so calculate where those\n # ticks will actually be at.\n if (T > 3)\n num_ticks = T\n xlabel = "Years"\n else\n num_ticks = T * 12\n xlabel = "Months"\n end\n tick_width = n / num_ticks\n x_ticks = []\n for i=1:round(num_ticks)\n x_ticks = vcat(x_ticks, i*tick_width)\n end\n \n # Use one color for each path. I\'m not sure if there\'s\n # a better way to do this without going through DataFrames\n colors = []\n for i = 1:m\n colors = vcat(colors, ones(n)*i)\n end\n \n plot(x=x, y=motion\', color=colors, Geom.line,\n Guide.xticks(ticks=x_ticks, label=false),\n Guide.xlabel(xlabel),\n Guide.ylabel("Value"))\nend;\n'})}),"\n",(0,i.jsx)(n.h3,{id:"example-simulation",children:"Example simulation"}),"\n",(0,i.jsx)(n.p,{children:"Let's go ahead and run a sample simulation to see what the functions got us!"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:"initial = ones(5) * S0\n# Using \u03BC=0, T=.25 for now, we'll use the proper values later\nmotion = simulate_gbm(initial, 0, \u03C3, .25, 200) \n\ndisplay_motion(motion, .25)\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:s(1960).Z+"",width:"535",height:"378"})}),"\n",(0,i.jsx)(n.h3,{id:"computing-the-term-structure",children:"Computing the term structure"}),"\n",(0,i.jsx)(n.p,{children:"Now that we've got the basic motion set up, let's start making things a bit more sophisticated for the model. We're going to assume that the drift of the stock is the difference between the implied forward rate and the quarterly dividend rate."}),"\n",(0,i.jsx)(n.p,{children:"We're given the yearly term structure, and need to calculate the quarterly forward rate to match this structure. The term structure is assumed to follow:"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsxs)(n.mrow,{children:[(0,i.jsx)(n.mi,{children:"d"}),(0,i.jsx)(n.mo,{stretchy:"false",children:"("}),(0,i.jsx)(n.mn,{children:"0"}),(0,i.jsx)(n.mo,{separator:"true",children:","}),(0,i.jsx)(n.mi,{children:"t"}),(0,i.jsx)(n.mo,{stretchy:"false",children:")"}),(0,i.jsx)(n.mo,{children:"="}),(0,i.jsx)(n.mi,{children:"d"}),(0,i.jsx)(n.mo,{stretchy:"false",children:"("}),(0,i.jsx)(n.mn,{children:"0"}),(0,i.jsx)(n.mo,{separator:"true",children:","}),(0,i.jsx)(n.mi,{children:"t"}),(0,i.jsx)(n.mo,{children:"\u2212"}),(0,i.jsx)(n.mn,{children:"1"}),(0,i.jsx)(n.mo,{stretchy:"false",children:")"}),(0,i.jsx)(n.mo,{children:"\u22C5"}),(0,i.jsxs)(n.msub,{children:[(0,i.jsx)(n.mi,{children:"f"}),(0,i.jsxs)(n.mrow,{children:[(0,i.jsx)(n.mi,{children:"i"}),(0,i.jsx)(n.mo,{children:"\u2212"}),(0,i.jsx)(n.mn,{children:"1"}),(0,i.jsx)(n.mo,{separator:"true",children:","}),(0,i.jsx)(n.mi,{children:"i"})]})]})]}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"d(0, t) = d(0,t-1)\\cdot f_{i-1, i}"})]})})}),(0,i.jsxs)(n.span,{className:"katex-html","aria-hidden":"true",children:[(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"d"}),(0,i.jsx)(n.span,{className:"mopen",children:"("}),(0,i.jsx)(n.span,{className:"mord",children:"0"}),(0,i.jsx)(n.span,{className:"mpunct",children:","}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"t"}),(0,i.jsx)(n.span,{className:"mclose",children:")"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,i.jsx)(n.span,{className:"mrel",children:"="}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"d"}),(0,i.jsx)(n.span,{className:"mopen",children:"("}),(0,i.jsx)(n.span,{className:"mord",children:"0"}),(0,i.jsx)(n.span,{className:"mpunct",children:","}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"t"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,i.jsx)(n.span,{className:"mbin",children:"\u2212"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,i.jsx)(n.span,{className:"mord",children:"1"}),(0,i.jsx)(n.span,{className:"mclose",children:")"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,i.jsx)(n.span,{className:"mbin",children:"\u22C5"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.9805em",verticalAlign:"-0.2861em"}}),(0,i.jsxs)(n.span,{className:"mord",children:[(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.10764em"},children:"f"}),(0,i.jsx)(n.span,{className:"msupsub",children:(0,i.jsxs)(n.span,{className:"vlist-t vlist-t2",children:[(0,i.jsxs)(n.span,{className:"vlist-r",children:[(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.3117em"},children:(0,i.jsxs)(n.span,{style:{top:"-2.55em",marginLeft:"-0.1076em",marginRight:"0.05em"},children:[(0,i.jsx)(n.span,{className:"pstrut",style:{height:"2.7em"}}),(0,i.jsx)(n.span,{className:"sizing reset-size6 size3 mtight",children:(0,i.jsxs)(n.span,{className:"mord mtight",children:[(0,i.jsx)(n.span,{className:"mord mathnormal mtight",children:"i"}),(0,i.jsx)(n.span,{className:"mbin mtight",children:"\u2212"}),(0,i.jsx)(n.span,{className:"mord mtight",children:"1"}),(0,i.jsx)(n.span,{className:"mpunct mtight",children:","}),(0,i.jsx)(n.span,{className:"mord mathnormal mtight",children:"i"})]})})]})}),(0,i.jsx)(n.span,{className:"vlist-s",children:"\u200B"})]}),(0,i.jsx)(n.span,{className:"vlist-r",children:(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.2861em"},children:(0,i.jsx)(n.span,{})})})]})})]})]})]})]})}),"\n",(0,i.jsxs)(n.p,{children:["Where ",(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsxs)(n.msub,{children:[(0,i.jsx)(n.mi,{children:"f"}),(0,i.jsxs)(n.mrow,{children:[(0,i.jsx)(n.mi,{children:"i"}),(0,i.jsx)(n.mo,{children:"\u2212"}),(0,i.jsx)(n.mn,{children:"1"}),(0,i.jsx)(n.mo,{separator:"true",children:","}),(0,i.jsx)(n.mi,{children:"i"})]})]})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"f_{i-1, i}"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.9805em",verticalAlign:"-0.2861em"}}),(0,i.jsxs)(n.span,{className:"mord",children:[(0,i.jsx)(n.span,{className:"mord mathnormal",style:{marginRight:"0.10764em"},children:"f"}),(0,i.jsx)(n.span,{className:"msupsub",children:(0,i.jsxs)(n.span,{className:"vlist-t vlist-t2",children:[(0,i.jsxs)(n.span,{className:"vlist-r",children:[(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.3117em"},children:(0,i.jsxs)(n.span,{style:{top:"-2.55em",marginLeft:"-0.1076em",marginRight:"0.05em"},children:[(0,i.jsx)(n.span,{className:"pstrut",style:{height:"2.7em"}}),(0,i.jsx)(n.span,{className:"sizing reset-size6 size3 mtight",children:(0,i.jsxs)(n.span,{className:"mord mtight",children:[(0,i.jsx)(n.span,{className:"mord mathnormal mtight",children:"i"}),(0,i.jsx)(n.span,{className:"mbin mtight",children:"\u2212"}),(0,i.jsx)(n.span,{className:"mord mtight",children:"1"}),(0,i.jsx)(n.span,{className:"mpunct mtight",children:","}),(0,i.jsx)(n.span,{className:"mord mathnormal mtight",children:"i"})]})})]})}),(0,i.jsx)(n.span,{className:"vlist-s",children:"\u200B"})]}),(0,i.jsx)(n.span,{className:"vlist-r",children:(0,i.jsx)(n.span,{className:"vlist",style:{height:"0.2861em"},children:(0,i.jsx)(n.span,{})})})]})})]})]})})]})," is the quarterly forward rate."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:"forward_term = function(yearly_term)\n # It is assumed that we have a yearly term structure passed in, and starts at year 0\n # This implies a nominal rate above 0 for the first year!\n years = length(term)-1 # because we start at 0\n structure = [(term[i+1] / term[i]) for i=1:years]\nend;\n"})}),"\n",(0,i.jsx)(n.h3,{id:"illustrating-the-term-structure",children:"Illustrating the term structure"}),"\n",(0,i.jsx)(n.p,{children:"Now that we've got our term structure, let's validate that we're getting the correct results! If we've done this correctly, then:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"term[2] == term[1] * structure[1]\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:'# Example term structure taken from:\n# http://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield\n# Linear interpolation used years in-between periods, assuming real-dollar\n# interest rates\nforward_yield = forward_term(term)\ncalculated_term2 = term[1] * forward_yield[1]\n\nprintln("Actual term[2]: $(term[2]); Calculated term[2]: $(calculated_term2)")\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" Actual term[2]: 1.0049; Calculated term[2]: 1.0049\n"})}),"\n",(0,i.jsx)(n.h3,{id:"the-full-underlying-simulation",children:"The full underlying simulation"}),"\n",(0,i.jsx)(n.p,{children:"Now that we have the term structure set up, we can actually start doing some real simulation! Let's construct some paths through the full 5-year time frame. In order to do this, we will simulate 1 year at a time, and use the forward rates at those times to compute the drift. Thus, there will be 5 total simulations batched together."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:"full_motion = ones(5) * S0\nfull_term = vcat(term[1], forward_yield)\nfor i=1:T\n \u03BC = (full_term[i] - 1 - q)\n year_motion = simulate_gbm(full_motion[:,end], \u03BC, \u03C3, 1, n)\n full_motion = hcat(full_motion, year_motion)\nend\n\ndisplay_motion(full_motion, T)\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:s(7363).Z+"",width:"535",height:"378"})}),"\n",(0,i.jsx)(n.h3,{id:"final-simulation",children:"Final simulation"}),"\n",(0,i.jsx)(n.p,{children:"We're now going to actually build out the full motion that we'll use for computing the pricing of our autocallable products. It will be largely the same, but we will use far more sample paths for the simulation."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:'full_simulation = function(S0, T, n, m, term)\n forward = vcat(term[1], forward_term(term))\n\n # And an S0 to kick things off.\n final_motion = ones(m) * S0\n for i=1:T\n \u03BC = (forward[i] - 1 - q)\n year_motion = simulate_gbm(final_motion[:,end], \u03BC, \u03C3, 1, n)\n final_motion = hcat(final_motion, year_motion)\n end\n return final_motion\nend\n\ntic()\nfull_simulation(S0, T, n, m, term)\ntime = toq()\n@printf("Time to run simulation: %.2fs", time)\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" Time to run simulation: 5.34s\n"})}),"\n",(0,i.jsx)(n.h2,{id:"athena-simulation",children:"Athena Simulation"}),"\n",(0,i.jsx)(n.p,{children:"Now that we've defined our underlying simulation, let's actually try and price an Athena note. Athena has the following characteristics:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Automatically called if the underlying is above the ",(0,i.jsx)(n.strong,{children:"call barrier"})," at observation"]}),"\n",(0,i.jsxs)(n.li,{children:["Accelerated coupon paid if the underlying is above the ",(0,i.jsx)(n.strong,{children:"call barrier"})," at observation","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["The coupon paid is ",(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsxs)(n.mrow,{children:[(0,i.jsx)(n.mi,{children:"c"}),(0,i.jsx)(n.mo,{children:"\u22C5"}),(0,i.jsx)(n.mi,{children:"i"})]}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"c \\cdot i"})]})})}),(0,i.jsxs)(n.span,{className:"katex-html","aria-hidden":"true",children:[(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.4445em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"c"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,i.jsx)(n.span,{className:"mbin",children:"\u22C5"}),(0,i.jsx)(n.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.6595em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"i"})]})]})]})," with ",(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsx)(n.mi,{children:"i"})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"i"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.6595em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"i"})]})})]})," as the current year, and ",(0,i.jsxs)(n.span,{className:"katex",children:[(0,i.jsx)(n.span,{className:"katex-mathml",children:(0,i.jsx)(n.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,i.jsxs)(n.semantics,{children:[(0,i.jsx)(n.mrow,{children:(0,i.jsx)(n.mi,{children:"c"})}),(0,i.jsx)(n.annotation,{encoding:"application/x-tex",children:"c"})]})})}),(0,i.jsx)(n.span,{className:"katex-html","aria-hidden":"true",children:(0,i.jsxs)(n.span,{className:"base",children:[(0,i.jsx)(n.span,{className:"strut",style:{height:"0.4306em"}}),(0,i.jsx)(n.span,{className:"mord mathnormal",children:"c"})]})})]})," the coupon rate"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["Principle protection up until a ",(0,i.jsx)(n.strong,{children:"protection barrier"})," at observation; All principle at risk if this barrier not met"]}),"\n",(0,i.jsx)(n.li,{children:"Observed yearly"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:'call_barrier = S0\nstrike = S0\nprotection_barrier = S0 * .6\ncoupon = nominal * .07\n\nprice_athena = function(initial_price, year_prices, call_barrier,\n protection_barrier, coupon, forward_structure)\n\n total_coupons = 0\n \n t = length(year_prices)\n\n for i=1:t\n price = year_prices[i]\n if price \u2265 call_barrier\n return (nominal + coupon*i) * exp((prod(forward_structure[i:end])-1)*(t-i))\n end\n end\n\n # We\'ve reached maturity, time to check capital protection\n if year_prices[end] > protection_barrier\n return nominal\n else\n put = (strike - year_prices[end]) / strike\n return nominal*(1-put)\n end\nend\n\nforward_structure = forward_term(term)\nprice_function = (year_prices) -> price_athena(S0, year_prices,\n call_barrier, protection_barrier, coupon, forward_structure)\n\nathena = function()\n year_indexes = [n*i for i=1:T]\n motion = full_simulation(S0, T, n, m, term)\n payoffs = [price_function(motion[i, year_indexes]) for i=1:m]\n return mean(payoffs)\nend\n\nmean_payoffs = zeros(num_simulations)\nfor i=1:num_simulations\n tic()\n mean_payoffs[i] = athena()\n time = toq()\n @printf("Mean of simulation %i: \\$%.4f; Simulation time: %.2fs\\n", i, mean_payoffs[i], time)\nend\n\nfinal_mean = mean(mean_payoffs)\nprintln("Mean over $num_simulations simulations: $(mean(mean_payoffs))")\npv = final_mean * (exp(-(prod(forward_structure)-1)*T))\n@printf("Present value of Athena note: \\$%.2f, notional: \\$%.2f", pv, nominal)\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" Mean of simulation 1: $103.2805; Simulation time: 5.59s\n Mean of simulation 2: $103.3796; Simulation time: 5.05s\n Mean of simulation 3: $103.4752; Simulation time: 5.18s\n Mean of simulation 4: $103.4099; Simulation time: 5.37s\n Mean of simulation 5: $103.3260; Simulation time: 5.32s\n Mean over 5 simulations: 103.37421610015554\n Present value of Athena note: $95.00, notional: $100.00\n"})}),"\n",(0,i.jsx)(n.h2,{id:"phoenix-without-memory-simulation",children:"Phoenix without Memory Simulation"}),"\n",(0,i.jsx)(n.p,{children:"Let's move into pricing a Phoenix without memory. It's very similar to the Athena production, with the exception that we introduce a coupon barrier so coupons are paid even when the underlying is below the initial price."}),"\n",(0,i.jsxs)(n.p,{children:["The Phoenix product has the following characteristics (example ",(0,i.jsx)(n.a,{href:"https://www.rbccm.com/usstructurednotes/file-780079.pdf",children:"here"}),"):"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Automatically called if the underlying is above the ",(0,i.jsx)(n.strong,{children:"call barrier"})," at observation"]}),"\n",(0,i.jsxs)(n.li,{children:["Coupon paid if the underlying is above a ",(0,i.jsx)(n.strong,{children:"coupon barrier"})," at observation"]}),"\n",(0,i.jsxs)(n.li,{children:["Principle protection up until a ",(0,i.jsx)(n.strong,{children:"protection barrier"})," at observation; All principle at risk if this barrier not met"]}),"\n",(0,i.jsx)(n.li,{children:"Observed yearly"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"Some example paths (all assume that a call barrier of the current price, and coupon barrier some level below that):"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"At the end of year 1, the stock is above the call barrier; the note is called and you receive the value of the stock plus the coupon being paid."}),"\n",(0,i.jsx)(n.li,{children:"At the end of year 1, the stock is above the coupon barrier, but not the call barrier; you receive the coupon. At the end of year 2, the stock is below the coupon barrier; you receive nothing. At the end of year 3, the stock is above the call barrier; the note is called and you receive the value of the stock plus a coupon for year 3."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"We're going to re-use the same simulation, with the following parameters:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Call barrier: 100%"}),"\n",(0,i.jsx)(n.li,{children:"Coupon barrier: 70%"}),"\n",(0,i.jsx)(n.li,{children:"Coupon: 6%"}),"\n",(0,i.jsx)(n.li,{children:"Capital protection until 70% (at maturity)"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:'call_barrier = S0\ncoupon_barrier = S0 * .8\nprotection_barrier = S0 * .6\ncoupon = nominal * .06\n\nprice_phoenix_no_memory = function(initial_price, year_prices, call_barrier, coupon_barrier,\n protection_barrier, coupon, forward_structure)\n\n total_coupons = 0\n t = length(year_prices)\n\n for i=1:t\n price = year_prices[i]\n if price \u2265 call_barrier\n return (nominal + coupon + total_coupons)*exp((prod(forward_structure[i:end])-1)*(t-i))\n elseif price \u2265 coupon_barrier\n total_coupons = total_coupons * exp(forward_structure[i]-1) + coupon\n else\n total_coupons *= exp(forward_structure[i]-1)\n end\n end\n\n # We\'ve reached maturity, time to check capital protection\n if year_prices[end] > protection_barrier\n return nominal + total_coupons\n else\n put = (strike - year_prices[end]) / strike\n return nominal*(1-put)\n end\nend\n\nforward_structure = forward_term(term)\nprice_function = (year_prices) -> price_phoenix_no_memory(S0, year_prices,\n call_barrier, coupon_barrier, protection_barrier, coupon, forward_structure)\n\nphoenix_no_memory = function()\n year_indexes = [n*i for i=1:T]\n motion = full_simulation(S0, T, n, m, term)\n payoffs = [price_function(motion[i, year_indexes]) for i=1:m]\n return mean(payoffs)\nend\n\nmean_payoffs = zeros(num_simulations)\nfor i=1:num_simulations\n tic()\n mean_payoffs[i] = phoenix_no_memory()\n time = toq()\n @printf("Mean of simulation %i: \\$%.4f; Simulation time: %.2fs\\n", i, mean_payoffs[i], time)\nend\n\nfinal_mean = mean(mean_payoffs)\nprintln("Mean over $num_simulations simulations: $(mean(mean_payoffs))")\npv = final_mean * exp(-(prod(forward_structure)-1)*(T))\n@printf("Present value of Phoenix without memory note: \\$%.2f", pv)\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" Mean of simulation 1: $106.0562; Simulation time: 5.72s\n Mean of simulation 2: $106.0071; Simulation time: 5.85s\n Mean of simulation 3: $105.9959; Simulation time: 5.87s\n Mean of simulation 4: $106.0665; Simulation time: 5.93s\n Mean of simulation 5: $106.0168; Simulation time: 5.81s\n Mean over 5 simulations: 106.02850857209883\n Present value of Phoenix without memory note: $97.44\n"})}),"\n",(0,i.jsx)(n.h2,{id:"phoenix-with-memory-simulation",children:"Phoenix with Memory Simulation"}),"\n",(0,i.jsxs)(n.p,{children:['The Phoenix with Memory structure is very similar to the Phoenix, but as the name implies, has a special "memory" property: ',(0,i.jsx)(n.strong,{children:"It remembers any coupons that haven't been paid at prior observation times, and pays them all if the underlying crosses the coupon barrier"}),". For example:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Note issued with 100% call barrier, 70% coupon barrier. At year 1, the underlying is at 50%, so no coupons are paid. At year 2, the underlying is at 80%, so coupons for both year 1 and 2 are paid, resulting in a double coupon."}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["You can also find an example ",(0,i.jsx)(n.a,{href:"https://www.rbccm.com/usstructurednotes/file-781232.pdf",children:"here"}),"."]}),"\n",(0,i.jsx)(n.p,{children:"Let's go ahead and set up the simulation! The parameters will be the same, but we can expect that the value will go up because of the memory attribute"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-julia",children:'call_barrier = S0\ncoupon_barrier = S0 * .8\nprotection_barrier = S0 * .6\ncoupon = nominal * .07\n\nprice_phoenix_with_memory = function(initial_price, year_prices, call_barrier,\n coupon_barrier, protection_barrier, coupon, forward_structure)\n\n last_coupon = 0\n total_coupons = 0\n \n t = length(year_prices)\n\n for i=1:t\n price = year_prices[i]\n if price > call_barrier\n return (nominal + coupon + total_coupons)*exp((prod(forward_structure[i:end])-1)*(t-i))\n elseif price > coupon_barrier\n ####################################################################\n # The only difference between with/without memory is the below lines\n memory_coupons = (i - last_coupon) * coupon\n last_coupon = i\n total_coupons = total_coupons * exp(forward_structure[i]-1) + memory_coupons\n ####################################################################\n else\n total_coupons *= exp(forward_structure[i]-1)\n end\n end\n\n # We\'ve reached maturity, time to check capital protection\n if year_prices[end] > protection_barrier\n return nominal + total_coupons\n else\n put = (strike - year_prices[end]) / strike\n return nominal*(1-put)\n end\nend\n\nforward_structure = forward_term(term)\nprice_function = (year_prices) -> price_phoenix_with_memory(S0, year_prices,\n call_barrier, coupon_barrier, protection_barrier, coupon, forward_structure)\n\nphoenix_with_memory = function()\n year_indexes = [n*i for i=1:T]\n motion = full_simulation(S0, T, n, m, term)\n payoffs = [price_function(motion[i, year_indexes]) for i=1:m]\n return mean(payoffs)\nend\n\nmean_payoffs = zeros(num_simulations)\nfor i=1:num_simulations\n tic()\n mean_payoffs[i] = phoenix_with_memory()\n time = toq()\n @printf("Mean of simulation %i: \\$%.4f; Simulation time: %.2fs\\n",\n i, mean_payoffs[i], time)\nend\n\nfinal_mean = mean(mean_payoffs)\nprintln("Mean over $num_simulations simulations: $(mean(mean_payoffs))")\npv = final_mean * exp(-(prod(forward_structure)-1)*(T))\n@printf("Present value of Phoenix with memory note: \\$%.2f", pv)\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" Mean of simulation 1: $108.8612; Simulation time: 5.89s\n Mean of simulation 2: $109.0226; Simulation time: 5.90s\n Mean of simulation 3: $108.9175; Simulation time: 5.92s\n Mean of simulation 4: $108.9426; Simulation time: 5.94s\n Mean of simulation 5: $108.8087; Simulation time: 6.06s\n Mean over 5 simulations: 108.91052564051816\n Present value of Phoenix with memory note: $100.09\n"})})]})}function h(e={}){let{wrapper:n}={...(0,t.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},7363:function(e,n,s){s.d(n,{Z:function(){return a}});let a=s.p+"assets/images/_notebook_12_0-1106bdfe947224ae55d7227b5a631d0e.svg"},1960:function(e,n,s){s.d(n,{Z:function(){return a}});let a=s.p+"assets/images/_notebook_6_0-46e660e38189a411644eac491e9b35ad.svg"},65:function(e,n,s){s.d(n,{Z:function(){return l},a:function(){return r}});var a=s(7294);let i={},t=a.createContext(i);function r(e){let n=a.useContext(t);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),a.createElement(t.Provider,{value:n},e.children)}},8279:function(e){e.exports=JSON.parse('{"permalink":"/2015/11/autocallable","source":"@site/blog/2015-11-27-autocallable/index.mdx","title":"Autocallable Bonds","description":"For a final project, my group was tasked with understanding three exotic derivatives: The Athena, Phoenix without memory, and Phoenix with memory autocallable products.","date":"2015-11-27T12:00:00.000Z","tags":[],"readingTime":11.085,"hasTruncateMarker":true,"authors":[{"name":"Bradlee Speice","socials":{"github":"https://github.com/bspeice"},"key":"bspeice","page":null}],"frontMatter":{"slug":"2015/11/autocallable","title":"Autocallable Bonds","date":"2015-11-27T12:00:00.000Z","authors":["bspeice"],"tags":[]},"unlisted":false,"lastUpdatedAt":1730678252000,"prevItem":{"title":"Testing Cramer","permalink":"/2015/12/testing-cramer"},"nextItem":{"title":"Welcome, and an algorithm","permalink":"/2015/11/welcome"}}')}}]);