Welcome to Java Black-Scholes valuation engine
Author: Michael Bret (mBret) Blackford
= Java Black-Scholes valuation engine =
=Java Black-Scholes valuation engine=
Author: Michael Bret (mBret) Blackford
Unable to find any well documented Java source code for the Black-Scholes option model I decided to write my own. This project contains the following Java classes which generate a mark-to-model (MtM):
-
BlackScholesFormula: this class attempts to clearly layout the Black-Scholes model as expressed in the formula. Each step is defined.
- the calculate() method will return the a double with the calculated MtM
- the calculateWithGreeks() will return the MtM value along with the greeks (delta, gamma, rho, theta, and vega)
-
BlackScholes_Abbreviated: this class obfuscates the Black-Scholes equation.
- blackScholesCall() returns the MtM as a double. Relies on the Apache Common Math Library for the NormalDistributionImpl class.
-
Black_76: this class implements the Black 76 option model.
- Black76() method returns a double with the MtM.
.
Useful information was found at the following websites …
- BlackScholes.java by Robert Sedgewick and Kevin Wayne -- http://introcs.cs.princeton.edu/java/22library/BlackScholes.java.html
- A decomposed implementation in Java by Dhruba Bandopadhyay … http://dhruba.name/2012/08/22/the-black-scholes-algorithm-a-decomposed-implementation-in-java/
- Black-Scholes in Multiple Languages … http://cseweb.ucsd.edu/~goguen/courses/130/SayBlackScholes.html
- ~~Jernej Kovse … http://www1.relacija.com/?p=57 ~~
In addition to the Black-Scholes classes described above I also wrote some code to extract data from a Db (using jdbc, which requires the ojdbc.jar). The Black-Scholes classes are then used to calculate the MtM for the data in the extracted result set. Output is written to Excel using the http://poi.apache.org/ Apache POI.
==== The input parameters to the Black-Scholes option valuation model are ... ====
- s = Spot price of underlying stock/asset
- k = Strike price
- r = Risk free annual interest rate continuously compounded
- t = Time in years until option expiration (maturity)
- v = Implied volatility of returns of underlying stock/asset
==== The option greeks are … ====
Delta - measures the rate of change of option value with respect to changes in the underlying asset's price. Measures the exposure of option price to movement of underlying stock price
Vega - measures sensitivity to volatility. Measures the exposure of the option price to changes in volatility of the underlying
Theta - measures the sensitivity of the value of the derivative to the passage of time. Measures the exposure of the option price to the passage of time
Rho - measures sensitivity to the interest rate: it is the derivative of the option value with respect to the risk free interest rate
Lambda - omega, or elasticity is the percentage change in option value per percentage change in the underlying price, a measure of leverage, sometimes called gearing.
_Gamma_ - measures the rate of change in the delta with respect to changes in the underlying price. Measures the exposure of the option delta to the movement of the underlying stock price
An interesting article from the BBC here, with companion video below.
External Links:
Authors and Contributors
M Bret Blackford (@bret-blackford)