In a
previous blog entry, I illustrated how Inference could be combined with computational libraries, such as CenterSpace’s NMath, to quickly assemble document-based statistical analysis solutions. Along those same lines, I recently downloaded a trial of
WebCab Components’ Options and Futures .NET library, which contains a collection of complex financial calculation implementations. I used this component to create a sample Inference for Word document that calculates the Present Value of European Call Options for Time to Maturity, measured in years. Say what??? Yeah, OK, on the off chance you didn't major in economics in college, let’s cover some quick background first.
European Call Options Defined
A call option is a financial contract between two parties (a buyer and a seller), whereby the buyer of the option has the right, but not the obligation to buy an agreed quantity of a particular commodity or financial instrument from the seller of the option
- at a certain time (expiration date)
- for a certain price (strike price)
If the buyer decides to do so (exercise the option), the seller of the option is obligated to sell the particular commodity or financial instrument at the strike price. For this right, the buyer pays a fee (a premium).
Call options have different styles. Specifically, a European call option allows the option holder to exercise the option only on the expiration date. Call options can be purchased on most financial instruments including stocks and stock indices (e.g., S&P 500, FTSE 100).
Factors Determining Present Value of a European Call Option on a Stock Index
Call options are traded on exchanges. The present value of a call option varies depending on the time to maturity and underlying market conditions. Accordingly, traders in call options need a mean to assess the value of a call option at any time. The present value of European option can be evaluated using the Black-Scholes model by considering the following factors:
- yield: the average dividend yield of the stocks in the index
- indexValue: the value of the index on which the option is based
- strike: the value of the index which is taken as the price at which the trade will occur
- riskFreeRate: the theoretical rate of return of an investment with zero risk, continuously compounded, typically the return on 3-month US treasuries
- volatility: the volatility of the index, which typically corresponds to the standard deviation of the continuously compounded returns of the stocks on the index
- timeToMaturity: the time until the option matures (in years)
Using Inference and WebCab Libraries to Build an Estimation Application
Estimating the present value using an analytical solution of the Black-Scholes model requires evaluation of a complex mathematical function, which is typically not available in standard software packages. You can build the function in Excel but it requires a bit of know-how and several hours of your time. However, specialized libraries of functions, like WebCab Options and Futures Library for .NET, provide a function CallOnIndex, which allows you to evaluate the present value of a call option on a stock index. To use such .NET libraries typically requires a skilled developer to build a custom applications using C# in Microsoft Visual Studio. However, mere mortals can achieve the same end in a matter of minutes using the same library in conjunction with the Inference for .NET and some IronPython glue code.
To begin, I created a new Word document, added an Inference Parts Container, and then embedded the WebCab Options and Futures .NET assembly:
Next, I added a series of Code Blocks with code to handle initialization and variable definition (pertaining to the Present Value scenario), along with explanatory text:
Then, I added another Code Block and added the IronPython code to perform the actual present value calculation and plot the results:
When exported, this yields a results document that plots the Present Value of European Call Options for Time to Maturity, where each line represents a different Time to Maturity Value:
Again, this example demonstrates how easily Inference can be combined with powerful .NET libraries, like as WebCab’s financial components, to quickly create document-based business applications.