Import libraries
import numpy as np
import pandas as pd
Tata motors stock price
spot_price = 430
Stock price range at expiration of the call
sT = np.arange(0.98spot_price,1.03spot_price)
Put strike and premium
strike_price = 430
premium = 3
Put payoff
Type your code here
def put_payoff(sT, strike_price, premium):
pnl = np.where(sT<strike_price,strike_price-sT,0)
return pnl
payoff_put = put_payoff(sT, strike_price, premium)
fig, ax = plt.subplots(figsize=(8,5))
ax.spines['bottom'].set_position('zero')
ax.plot(sT,payoff_put,label='Put Buyers Payoff')
plot.xlabel('Tata Motors Price')
plot.ylabel('Profit and Loss')
plot.legend()
plot.show()
I wrote the above code to work out Put Option Payoff. While running the code, it gives error at line 18 i.e. pnl = np.where(sT
Even solution code does not give any hint to my mistake. How can I correct ?