All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.finmath.fouriermethod.models.BlackScholesModel Maven / Gradle / Ivy

Go to download

finmath lib is a Mathematical Finance Library in Java. It provides algorithms and methodologies related to mathematical finance.

There is a newer version: 6.0.19
Show newest version
/*
 * (c) Copyright Christian P. Fries, Germany. All rights reserved. Contact: [email protected].
 *
 * Created on 23.03.2014
 */

package net.finmath.fouriermethod.models;

import net.finmath.fouriermethod.CharacteristicFunctionInterface;

import org.apache.commons.math3.complex.Complex;

/**
 * Implements the characteristic function of a Black Scholes model.
 * 
 * @author Christian Fries
 * @author Alessandro Gnoatto
 */
public class BlackScholesModel implements ProcessCharacteristicFunctionInterface {

	private final double initialValue;
	private final double riskFreeRate;		// Actually the same as the drift (which is not stochastic)
	private final double volatility;

	public BlackScholesModel(double initialValue, double riskFreeRate, double volatility) {
		super();
		this.initialValue = initialValue;
		this.riskFreeRate = riskFreeRate;
		this.volatility = volatility;
	}

	/* (non-Javadoc)
	 * @see net.finmath.fouriermethod.models.ProcessCharacteristicFunctionInterface#apply(double)
	 */
	@Override
	public CharacteristicFunctionInterface apply(final double time) {
        return new CharacteristicFunctionInterface() {
            @Override
            public Complex apply(Complex argument) {
                Complex iargument = argument.multiply(Complex.I);
                return	iargument
                        .multiply(
                                iargument
                                        .multiply(0.5*volatility*volatility*time)
                                        .add(Math.log(initialValue)-0.5*volatility*volatility*time+riskFreeRate*time))
                        .add(-riskFreeRate*time)
                        .exp();
            };
        };
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy