<a href="https://colab.research.google.com/github/Jun-629/20MA573/blob/master/src/Hw3_payoff_structure_of_option_combinations.ipynb" target="_parent"></a>

Recall that,

Written K-strike straddle is a portfolio of

- selling K-strike call of one unit
- selling K-strike put of one unit

Butterfly with three stikes $K_1 < K_2 < K_3$ is the portfolio of

- 1 unit of written K-strike straddle
- 1 unit of purchased K-strike call
- 1 unit of purchased K-strike put

Plot a diagram of exercise price versus payoff for the following portfolios:

- written 40-strike straddle
- a butterfly consists of
  - written 40-strike straddle
  - purchased 45-strike call
  - purchased 35-strike put

__Soln:__

When selling one unit European call with 
strike $K$ and exercise price $S$, the payoff is given as
$$C(S, K)= - (S - K)^+ = -\max\{S - K, 0\}.$$
Similarly, when selling one unit European put with 
strike $K$ and exercise price $S$, the payoff is given as
$$P(S, K)= - (S - K)^- = -\max\{K - S, 0\}.$$
Thus, the payoff of written K-strike straddle is given as

\begin{equation}
\begin{split}
V &= C(S, K) + P(S, K) \\
&= -\max\{S-K, 0\} - \max\{K-S, 0\} \\
&= -\max\{S-K, K-S\}.
\end{split}
\end{equation}

Assuming that when selling one unit European call and one unit put option, the seller will get the costs of the option \$ $5$, and purchasing the call and put option in the butterfly option will totally pay for \$ $3$.

#https://en.wikipedia.org/wiki/Butterfly_(options)



```
class VanillaOption:
    def __init__(
        self,
        otype = 1, # 1: 'call'
                  # -1: 'put'
        strike = 40.,
        maturity = 1.,
        market_price = 10.):
      self.otype = otype
      self.strike = strike
      self.maturity = maturity
      self.market_price = market_price #this will be used for calibration

    def buy_payoff(self, s):
      otype = self.otype
      k = self.strike
      maturity = self.maturity
      return max([0, (s - k)*otype])

        
    def sell_payoff(self, s): #s: excercise price
      otype = self.otype
      k = self.strike
      maturity = self.maturity
      return -max([0, (s - k)*otype])
```


```
import numpy as np
import matplotlib.pyplot as plt

opt1 = VanillaOption(otype = 1) 
opt2 = VanillaOption(otype = -1)
stk_list = range(20, 61)
#c=[a[i]+b[i] for i in range(min(len(a),len(b)))]
payoff_1 = [opt1.sell_payoff(s) for s in stk_list]
payoff_2 = [opt2.sell_payoff(s) for s in stk_list] 
payoff = [payoff_1[i] + payoff_2[i] +5 for i in range(len(stk_list))]
plt.plot(stk_list, payoff)

#decorations
plt.xlabel('exercise price')
plt.ylabel('straddle_payoff')
plt.title('written 40-strike straddle');
plt.show()
```


```
opt3 = VanillaOption(otype = 1,strike = 45) 
opt4 = VanillaOption(otype = -1, strike = 35)
stk_list = range(20, 61)

payoff_3 = [opt3.buy_payoff(s) for s in stk_list]
payoff_4 = [opt4.buy_payoff(s) for s in stk_list] 
payoff_bf = [payoff[i] + payoff_3[i] + payoff_4[i] -3 for i in range(len(stk_list))]
plt.plot(stk_list, payoff_bf)

#decorations
plt.xlabel('exercise price')
plt.ylabel('butterfly_payoff')
plt.title('Butterfly Option');
plt.show()
```

7b14f9c18c58b1fa8fae8a23776d5915a0ad82d2
ipynb
Jupyter Notebook
src/Hw3_payoff_structure_of_option_combinations.ipynb
Jun-629/20MA573
addad663d2dede0422ae690e49b230815aea4c70
MIT
src/Hw3_payoff_structure_of_option_combinations.ipynb
Jun-629/20MA573
addad663d2dede0422ae690e49b230815aea4c70
MIT
src/Hw3_payoff_structure_of_option_combinations.ipynb
Jun-629/20MA573
addad663d2dede0422ae690e49b230815aea4c70
MIT
2020-02-05T21:42:08.000Z
2020-02-05T21:42:08.000Z
Qwen/Qwen-72B
1. YES
2. YES