|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.akutan.numerics.FiniteDifferenceSolver
public class FiniteDifferenceSolver
This class implements several numerical methods to compute the one dimensional solution to the Black-Scholes european call option. As a check it also uses an external implementation of an analytic solution to Black-Scholes. The methods include a simple binomial tree, explicit finite differences, implicit finite differences and Crank-Nicolson method. TODO Implement a more direct solution to the tridiagonal matrix problem so as to introduce fewer errors into the solution (because of inverting the matrix). TODO Improve the Crank-Nicolson code, it doesn't seem to work so well. TODO Implement better algorithms from the Finite Differences school, perhaps ADI?
| Constructor Summary | |
|---|---|
FiniteDifferenceSolver()
Constructs |
|
| Method Summary | |
|---|---|
double |
binomialOption(double asset,
double strike,
double expiry,
double volatility,
double rate,
int steps)
Uses binomial model to compute price of european call option |
double |
crankNicolson(double asset,
double strike,
double expiry,
double volatility,
double rate,
int param,
int steps)
Uses Crank-Nicolson Finite differences method to compute price of call option. |
double |
explicitOptionValue(double asset,
double strike,
double expiry,
double volatility,
double rate,
int param,
int steps)
Uses explicit Finite differences method to compute price of call option |
double |
implicitOptionValue(double asset,
double strike,
double expiry,
double volatility,
double rate,
int param,
int steps)
Uses implicit Finite differences method to compute price of call option. |
static void |
main(java.lang.String[] args)
Example code to illustrate the calling sequence for the various methods within this class. |
cern.colt.matrix.DoubleMatrix2D |
solveTridiagonal(cern.colt.matrix.DoubleMatrix2D Min,
cern.colt.matrix.DoubleMatrix2D Din)
Solves a tri-diagonal system of equations parsimoniusly using Gaussian Elimination. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FiniteDifferenceSolver()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
throws java.lang.Exception
args -
java.lang.Exception
public cern.colt.matrix.DoubleMatrix2D solveTridiagonal(cern.colt.matrix.DoubleMatrix2D Min,
cern.colt.matrix.DoubleMatrix2D Din)
Min - Input matrix (left side)Din - Input vector (right side)
public double binomialOption(double asset,
double strike,
double expiry,
double volatility,
double rate,
int steps)
asset - Current price of the assetstrike - Option strike priceexpiry - Time to expiry in yearsvolatility - Volatility of the asset pricerate - Risk free interest rate - rate of dividendssteps - Number of steps to use to solve
public double explicitOptionValue(double asset,
double strike,
double expiry,
double volatility,
double rate,
int param,
int steps)
throws java.lang.Exception
asset - Current price of assetstrike - Strike price of optionexpiry - Time to expiry in yearsvolatility - Volatility of the asset pricerate - Risk free rate - dividend rateparam - Indicates which quantity to compute, 0 = Price, 1 = Delta, 2 = Gamma, 3 = Thetasteps -
java.lang.Exception
public double implicitOptionValue(double asset,
double strike,
double expiry,
double volatility,
double rate,
int param,
int steps)
throws java.lang.Exception
asset - Current price of assetstrike - Strike price of optionexpiry - Time to expiry in yearsvolatility - Volatility of the asset pricerate - Risk free rate - dividend rateparam - Indicates which quantity to compute, 0 = Price, 1 = Delta, 2 = Gamma, 3 = Thetasteps -
java.lang.Exception
public double crankNicolson(double asset,
double strike,
double expiry,
double volatility,
double rate,
int param,
int steps)
throws java.lang.Exception
asset - Current price of assetstrike - Strike price of optionexpiry - Time to expiry in yearsvolatility - Volatility of the asset pricerate - Risk free rate - dividend rateparam - Indicates which quantity to compute, 0 = Price, 1 = Delta, 2 = Gamma, 3 = Thetasteps -
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||