Join the Quantcademy private membership portal that caters to the rapidly-growing retail quant trader community. You'll find a knowledgeable, like-minded group of quant traders ready to answer your most pressing quant trading questions.
Check out my ebook on quant trading where I teach you how to build profitable systematic trading strategies with Python tools, from scratch. Take a look at my new ebook on advanced trading strategies using time series analysis, machine learning and Bayesian statistics, with Python and R.
This post is part of a larger series on Option Pricing with Python. In order to get the best out of this article, you should be able to tick the following boxes:. Later articles will build production-ready Finite Difference and Monte Carlo solvers to solve more complicated derivatives. Python has a reputation primarily as a scripting language, functioning as "glue" between other codebases. I would like to augment that reputation and show that with tools like Numpy and SciPy it is perfectly capable of being utilised to price options.
However, it is yet another language to learn - so why should you invest the time? I have listed the primary benefits below:. The articles to follow will concentrate on simplicity, rather than optimisation.
We will follow Daniel Duffy 's philosophy of "First we get it working, then we get it right, then we optimise it". To this end, we will not initially be using any complicated syntax - it should be obvious how we have gone from an algorithm to its implementation, with the minimum of head-scratching.
After we have code working, we can make sure it is producing the correct values. Finally, we can optimise it and put it into production. It has already been outlined that the reader is to be familiar with the Black-Scholes formula for the pricing of European Vanilla Calls and Puts. This is the cumulative distribution function of the standard normal distribution. In addition, we would like to have closed form solutions for the "Greeks", i. For this reason we also need the formula for the probability density function of the standard normal distribution which is given below:.
Our task is now to utilise Python to implement these functions and provide us with values for the closed-form solution to the price of a European Vanilla Call or Put with their associated sensitivities. Open a new Python file in your favourite IDE and name it statistics. This function is fairly self-explanatory. The next function to code up is the CDF of the normal distribution. The method utilised The Wikipedia article on the Normal Distribution sheds more light on this and other methods.
Here is the Python listing for the algorithm:. We now have the two statistical functions necessary for calculating the closed-form options prices for European vanilla calls and puts.
It should reside in the same file directory as the statistics. The code for this function is provided below:. This concludes the coding of formulae for the statistical distribution functions in statistics. At this stage it is prudent to check that the formulae produce the correct results and satisfy the known bounds on the prices such as put-call parity. That will be the subject of the next article. You'll get instant access to a free part email course packed with hints and tips to help you get started in quantitative trading!
In order to get the best out of this article, you should be able to tick the following boxes: Just Getting Started with Quantitative Trading? Quant Trading Lessons You'll get instant access to a free part email course packed with hints and tips to help you get started in quantitative trading!
No Spam Real, actionable quant trading tips with no nonsense.More...