Financial Mathematics 1 - Homework 10
Instructor: Dr. Le Nhat Tan
1 Option as Object
class Option:
def __init__(self, position = 'long', action = 'call', strike = 0, premium = 0):
self.position = position
self.action = action
self.strike = strike
self.premium = premium
def intrinsic(self, price):
if self.position == 'long' and self.action == 'call':
return price - self.strike
if self.position == 'short' and self.action == 'put':
return price - self.strike
return self.strike - price
def payoff(self, price):
if self.position == 'long':
return max(self.intrinsic(price), 0)
return min(self.intrinsic(price), 0)
def profit(self, price):
if self.position == 'long':
return self.payoff(price) - self.premium
return self.payoff(price) + self.premium
def pp_diagram(self):
prices = list(range(0, self.strike * 2, 1))
payoffs = [self.payoff(x) for x in prices]
profits = [self.profit(x) for x in prices]
fig, ax = plt.subplots()
ax.plot(prices, payoffs, 'b')
ax.plot(prices, profits, 'g--')
plt.grid(color = 'silver', linestyle = '--', linewidth = 1,
axis = 'y', alpha = 0.7)
plt.xlabel('Price')
plt.legend(['Payoff', 'Profit'])
plt.show()2 Slide 14
Let the current stock price be $35 and the European put option is in-the-money by $3.5. Find the corresponding strike price.
Solution. \(3.5=I_P(t)=K-S_t=K-35\Rightarrow K=38.5.\)
3 Slide 16
Consider a long call option with strike price K = $100. The current stock price is \(S_t\) = $105 and the call premium is $10.
- What is the intrinsic value of the call option at time t?
- Find the payoff and profit if the spot price at the option expiration date T is \(S_T\) = $120.
- Draw the payoff and profit diagrams.
o1 = Option(strike = 100, premium = 10)
o1.intrinsic(105)## 5
o1.payoff(120)## 20
o1.profit(120)## 10
o1.pp_diagram()4 Slide 18
Consider a long put option with strike price K = $100. The current stock price is \(S_t\) = $80 and the put premium is $5.
- What is the intrinsic value of the put option at time t?
- Find the payoff and profit if the spot price at the option expiration date T is \(S_T\) = $75.
- Draw the payoff and profit diagrams.
o2 = Option(action = 'put', strike = 100, premium = 5)
o2.intrinsic(80)## 20
o2.payoff(75)## 25
o2.profit(75)## 20
o2.pp_diagram()5 Slide 20 - P1
Consider a short position in a call option (a short call option) with strike price K = $100. The current stock price is \(S_t\) = $105 and the call premium is $10.
- What is the intrinsic value of the short call option at time t?
- Find the formula of the payoff and profit of the option at expiry. Compute the payoff and profit if the spot price at the option expiration date T is \(S_T\) = $120.
- Draw the payoff and profit diagrams.
o1.position = 'short'
o1.intrinsic(105)## -5
o1.payoff(120)## -20
o1.profit(120)## -10
o1.pp_diagram()6 Slide 20 - P2
Consider a short put option with strike price K = $100. The current stock price is \(S_t\) = $80 and the call premium is $5.
- What is the intrinsic value of the short put option at time t?
- Find the formula of the payoff and profit of the option at expiry. Compute the payoff and profit if the spot price at the option expiration date T is \(S_T\) = $75.
- Draw the payoff and profit diagrams.
o2.position = 'short'
o2.intrinsic(80)## -20
o2.payoff(75)## -25
o2.profit(75)## -20
o2.pp_diagram()