Using TikZ and PGFPlots for a class on Options and Derivatives

Using TikZ and PGFPlots for a class on Options and Derivatives

January 23, 2020

To use the code just insert it into any LaTeX code with the appropriate tikz libraries; see here for examples.

Payoff of a Forward Contract #

Payoff of a forward contract is linear in the underlying security:

Forward Contract Payoff
\begin{tikzpicture}
    \begin{axis}[
    height=10cm,
    width=14cm,
    axis x line=bottom,
    axis y line=left,
    xlabel = Spot Price $S_T$,
    ylabel = Payoff,
    ymin=-32, ymax=32,
    xmin=70, xmax=132,    
    xtick={80, 100, 120, 130},
    ytick={-20, 0, 20, 30},
    grid = major,
    grid style={dashed},
    scatter/classes={
      a={mark=*, mark size = 3pt,draw=black, fill = black}      
    }
]
  \definecolor{maroon}{RGB}{128, 0, 0}
  \addplot[color=black, domain=70:130, line width=1pt]
    {x - 100};
  \addplot[color=maroon, dashed, domain=70:130, line width=1pt]
    {100 - x};
  \node[pin={[pin edge={thick}, text width=3cm, pin distance=2cm]-90:{{\centering Forward Price $F_{0,T}$}}}, align=center] at (axis cs:100, -1) {};
  \addplot[scatter,only marks,
    scatter src=explicit symbolic]
    coordinates {
      (100,0)        [a]
    };        
  \node[text width=3cm,align=right] at (axis cs:120, 20) [anchor=south east] {\textbf{Long Forward}\\$S_T - F_{0,T}$};
  \node[text width=3cm,align=left] at (axis cs:80, 20) [anchor=south west] {\textbf{Short Forward}\\$F_{0,T} - S_T$};
\end{axis}
\end{tikzpicture}

Covered Interest Parity #

Replicating foreign interest rate using exchange rate and a forward:

CIP
% Definition of blocks:
\tikzset{%
  block/.style    = {draw, thick, rectangle, minimum height = 3em,
    minimum width = 3em},
  sum/.style      = {draw, circle, node distance = 2cm}, % Adder
  input/.style    = {coordinate}, % Input
  output/.style   = {coordinate}, % Output
  >={Latex[width=2mm,length=2mm]},
  % Specifications for style of nodes:
            base/.style = {rectangle, rounded corners, draw=black,
                           minimum width=4cm, minimum height=1cm,
                           text centered, font=\sffamily},
  activityStarts/.style = {base, fill=blue!30},
       startstop/.style = {base, fill=red!30},
    activityRuns/.style = {base, fill=green!30},
         process/.style = {base, minimum width=2.5cm, fill=orange!15,
                           font=\ttfamily}
}

\begin{tikzpicture}[
  node distance=2cm,
  every node/.style={fill=white, font=\sffamily},
  align=center
  ]
  % Specification of nodes (position, etc.)
  \node (start)             [activityStarts]                {US Investor at $t=0$};
  \node (borrowing0)        [process, above=2.5cm of start]       {US Bank};
  \node (exchange0)         [process, below=2.5cm of start]       {Exchange Counterparty};  
  \node (lending01)         [process, right=3.5cm of start]       {Japanese Investor};
  \node (end)               [activityStarts, right=3.5cm of lending01] {US Investor at $t=1$};
  \node (borrowing1)        [process, above=2.5cm of end]       {US Bank};
  \node (exchange1)         [process, below=2.5cm of end]       {Exchange Counterparty};  
  % Link the nodes
  \draw[->](borrowing0) -- node[]{Borrowing in USD} (start);
  \draw[->](start)  -- node[]{Buy Yen at rate $x_0$\\ buy for $\$1$ receive $\text{\textyen}\ 1 / x_0$}(exchange0);
  \draw[->](start)  -- node[text width = 2.4cm]{Lend $1/x_0$ Yens at $t=0$} (lending01);
  \draw[->](lending01)  -- node[text width = 2.4cm]{Receive Yens: $\frac{1}{x_0} \cdot (1+r^{\text{\textyen}})$} (end);
  \draw[->](end)  -- node[]{Repay USD loan at $t=1$ for \\$1+r$} (borrowing1);
  \draw[->](exchange1)  -- node[]{Exchange the \textyen \ investment in USD\\ $\frac{1}{x_0} \cdot (1+r^{\text{\textyen}}) \cdot F_{0,1}$} (end);
\end{tikzpicture}


TeX