This Code was made in Anaconda-Spyder, so while running in Ubuntu there may be some indentation error.
To run this code, keep all the Files and Folders in the Same Folder
The Data Folder contains the input data of option contacts price snapshot for different expiry dates for NIFTY
The Graph folder contains the Output files for new premium vs strike price , and graphs of the same
Before running the Code, make sure that Graph file is Empty.
To Execute, be in the same folder as 'estimate_premium.py'.
Run the command ' python estimate_premium.py'
Make sure all imports are already installed
There are call options with different strike price and their corresponding premium and moneyness for different time intervals
from the current date till the expiry date. Similarly, there are put options.
About input files:
We have taken the option chain data from 'NSE Option Chain(Equity Derivatives)' for NIFTY and symbol 'ACC': https://www.nseindia.com/option-chain
Data from
Current date : 20-05-2020
till
Expiry dates: 28-05-2020, 04-06-2020, 11-06-2020 and 18-06-2020
for strike prices 8000 to 11000
- Inputs:
- User inputs:
Initial Volaitilty %
Initial Spot Price
Estimated CHANGE in Spot Price of Underlying
Change in % Volatility(+/-)
Number of days before or till expiry for which user wants to know the option premium - File inputs:
strike_price
premium
current_date
expiry_date
option_type
- Outputs:
- File outputs:
strike_price & new_premium in csv file - Graph ouputs:
Multiple curves of call and put options with new premium in a single plot
Separate plots for call and put options for different expiry dates
From the Black-Scholes-Merton Model, values of greeks are calculated for call and put options.
Initial spot price and volatility are updated according to user's view of change in spot price and volatility.
For call and put options both the following sequence of the effect of greeks is followed to calculate new premium:
1: 'spot price' and 'volatility' are updated according to their respective changes
2: 'gamma' is calculated from options greeks formulae
3: 'old delta' is calculated from options greeks formulae and using the calculated 'gamma', 'new delta' is calculated
4: 'theta' for options is calculated from options greeks formulae
5: 'vega' for options is calculated from options greeks formulae and 'vega effect' is calculated using this 'vega' and 'change in volatility'
6: 'new premium' is calculated initially by effect of 'new delta' followed by effect of 'theta' and 'vega'
Thus, 'gamma' is used to calculate 'new delta', and further 'new premium' is calculated with the effect of 'new delta', 'theta' and 'vega'.
The new premium for all strike prices are stored in the output csv file.
Graphs for call options and put options together plotted so as to compare the 'new premium' for different expiry dates for both options.
Graphs for call options and put options are plotted separately and for each expiry date individually to observe the difference between old premium and new premium.