PurposeTo calculate prices of European Call and Put options using the famous Black & Scholes method. Attempt has been made to perform this calculation even for Dividend paying stocks; though still need some improvements. Black Scholes MethodWe will calculate prices for European options by applying Black Scholes method. As per Investopedia: "The BlackScholes formula (also called BlackScholesMerton) was the first widely used model for option pricing. It's used to calculate the theoretical value of Europeanstyle options using current stock prices, expected dividends, the option's strike price, expected interest rates, time to expiration and expected volatility." BlackScholes method only works for European options as they can be exercised only on the expiry date. Underlying DataAs we can see, the required input for BlackScholes method is same as the one we had downloaded and derived in Part1 of this blog. Therefore, in this blog we will skip details on how to get historical asset prices and use them to calculate asset volatility. Calculate BlackScholes' d1 and d2Now, we have all the underlying data; so let's aim to codify the above mentioned BlackScholes equations. The famous d1 and d2 values can be calculated using the below code: Calculating d1
Calculating d2
Once we have values for d1 and d2, we can plug these values in the overall equations for Call and Put option price as shown below:
If dividend is not zero, then it is subtracted from the risk free rate in the below calculations. Calculating Call and Put option prices using BlackScholes method
Running again for TSLA shortterm optionIn our previous blog, we ran MonteCarlo simulations to calculate price of American option on TSLA stock expiring Sept 7th with Strike price of $370. We will use the same parameter here to calculate the price of European options using our above code. Since the expiry is just a month ahead, prices of European options should be close to those of American ones. This is because time to expiry is short; giving lesser chance to the American option holder to exercise  the only difference between the two option types. Once we run the code as available in my GitHub repository here; we get the following output. Output of calculating European option prices using BlackScholes
As we can see, these values are extremely close to the ones we got when running MonteCarlo simulations. As a reminder, from that blog we got these values: INFO: ### Call Price calculated at 11.162400 INFO: ### Put Price calculated at 25.102147 Prices compared  $11.159 vs $11.162 and $25.137 vs $25.102; it definitely looks we are consistent in our approach with these short duration options. PutCall ParityEuropean Call and Put options must maintain a relationship called as PutCall parity. As Investopedia explains here: "Putcall parity is a principle that defines the relationship between the price of European put options and European call options of the same class, that is, with the same underlying asset, strike price and expiration date." This must be true always; else there will be an arbitrage opportunity i.e. returns without any risks. Basically, PutCall parity states that below relationship must always be held: CALLprice + PV( Strikeprice ) = PUTprice + SPOTprice We can verify whether this parity holds using the below code: PutCall Parity
Output for PutCall parity
As we can see above, both European Call and Put option prices do maintain the PutCall parity.

AuthorI am a passionate, driven polyglot programmer and architect with a knack of solving complex problems in quick and efficient way. Along with programming, software development, financial products, and management expertise, I also bring skills in statistical modeling, empowering me to work on challenging projects that require combination of software development and quantitative analysis. Categories
All
