Module net.finmath.lib
Class MonteCarloMultiAssetBlackScholesModel
java.lang.Object
net.finmath.montecarlo.model.AbstractProcessModel
net.finmath.montecarlo.assetderivativevaluation.MonteCarloMultiAssetBlackScholesModel
- All Implemented Interfaces:
Model
,AssetModelMonteCarloSimulationModel
,ProcessModel
,MonteCarloSimulationModel
public class MonteCarloMultiAssetBlackScholesModel
extends AbstractProcessModel
implements AssetModelMonteCarloSimulationModel
This class implements a multi-asset Black Schole Model as Monte-Carlo simulation implementing
AssetModelMonteCarloSimulationModel
.
The model is
\[
dS_{i} = r S_{i} dt + \sigma_{i} S_{i} dW_{i}, \quad S_{i}(0) = S_{i,0},
\]
\[
dN = r N dt, \quad N(0) = N_{0},
\]
\[
dW_{i} dW_{j} = \rho_{i,j} dt,
\]
The class provides the model of \( S_{i} \) to an MonteCarloProcess
via the specification of
\( f = exp \), \( \mu_{i} = r - \frac{1}{2} \sigma_{i}^2 \), \( \lambda_{i,j} = \sigma_{i} g_{i,j} \), i.e.,
of the SDE
\[
dX_{i} = \mu_{i} dt + \lambda_{i,j} dW, \quad X_{i}(0) = \log(S_{i,0}),
\]
with \( S = f(X) \). See MonteCarloProcess
for the notation.- Version:
- 1.1
- Author:
- Christian Fries, Roland Bachl
- See Also:
The interface for numerical schemes.
,The interface for models provinding parameters to numerical schemes.
-
Constructor Summary
ConstructorsConstructorDescriptionMonteCarloMultiAssetBlackScholesModel(BrownianMotion brownianMotion, double[] initialValues, double riskFreeRate, double[] volatilities, double[][] correlations)
Create a Monte-Carlo simulation using given time discretization.MonteCarloMultiAssetBlackScholesModel(RandomVariableFactory randomVariableFactory, BrownianMotion brownianMotion, double[] initialValues, double riskFreeRate, double[][] factorLoadings)
Create a Monte-Carlo simulation using given time discretization.MonteCarloMultiAssetBlackScholesModel(TimeDiscretization timeDiscretization, int numberOfPaths, double[] initialValues, double riskFreeRate, double[] volatilities, double[][] correlations)
Create a Monte-Carlo simulation using given time discretization.MonteCarloMultiAssetBlackScholesModel(TimeDiscretization timeDiscretization, int numberOfPaths, int seed, double[] initialValues, double riskFreeRate, double[] volatilities, double[][] correlations)
Create a Monte-Carlo simulation using given time discretization. -
Method Summary
Modifier and TypeMethodDescriptionapplyStateSpaceTransform(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)
Applies the state space transform fi to the given state random variable such that Yi → fi(Yi) =: Xi.applyStateSpaceTransformInverse(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)
Applies the inverse state space transform f-1i to the given random variable such that Xi → f-1i(Xi) =: Yi.getAssetValue(double time, int assetIndex)
Returns the random variable representing the asset's value at a given time for a given asset.getAssetValue(int timeIndex, int assetIndex)
Returns the random variable representing the asset's value at a given time for a given asset.getCloneWithModifiedData(Map<String,Object> dataModified)
Create a clone of this simulation modifying some of its properties (if any).getCloneWithModifiedSeed(int seed)
Create a clone of the object implementingAssetModelMonteCarloSimulationModel
using a different Monte-Carlo seed.double[][]
Returns the volatility parameters of this model.getDrift(MonteCarloProcess process, int timeIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)
This method has to be implemented to return the drift, i.e.getFactorLoading(MonteCarloProcess process, int timeIndex, int component, RandomVariable[] realizationAtTimeIndex)
This method has to be implemented to return the factor loadings, i.e.double[][]
Returns the factorLoadings parameters of this model.getInitialState(MonteCarloProcess process)
Returns the initial value of the state variable of the process Y, not to be confused with the initial value of the model X (which is the state space transform applied to this state value.getMonteCarloWeights(double time)
This method returns the weights of a weighted Monte Carlo method (the probability density).getMonteCarloWeights(int timeIndex)
This method returns the weights of a weighted Monte Carlo method (the probability density).int
Returns the number of asset price processes.int
Returns the number of componentsint
Returns the number of factors m, i.e., the number of independent Brownian drivers.int
Returns the number of paths.getNumeraire(double time)
Returns the numeraire associated with the valuation measure used by this model.getNumeraire(int timeIndex)
Returns the numeraire associated with the valuation measure used by this model.getNumeraire(MonteCarloProcess process, double time)
Return the numeraire at a given time index.getRandomVariableForConstant(double value)
Returns a random variable which is initialized to a constant, but has exactly the same number of paths or discretization points as the ones used by thisMonteCarloSimulationModel
.double
Returns the risk free rate parameter of this model.double
getTime(int timeIndex)
Returns the time for a given time index.Returns the timeDiscretizationFromArray.int
getTimeIndex(double time)
Returns the time index for a given time.double[]
Returns the volatility parameters of this model.toString()
Methods inherited from class net.finmath.montecarlo.model.AbstractProcessModel
getInitialValue, getReferenceDate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.finmath.montecarlo.MonteCarloSimulationModel
getReferenceDate
-
Constructor Details
-
MonteCarloMultiAssetBlackScholesModel
public MonteCarloMultiAssetBlackScholesModel(RandomVariableFactory randomVariableFactory, BrownianMotion brownianMotion, double[] initialValues, double riskFreeRate, double[][] factorLoadings)Create a Monte-Carlo simulation using given time discretization.- Parameters:
randomVariableFactory
- The RandomVariableFactory used to construct model parameters as random variables.brownianMotion
- The Brownian motion to be used for the numerical scheme.initialValues
- Spot values.riskFreeRate
- The risk free rate.factorLoadings
- The matrix of factor loadings, where factorLoadings[underlyingIndex][factorIndex] is the coefficient of the Brownian driver factorIndex used for the underlying underlyingIndex.
-
MonteCarloMultiAssetBlackScholesModel
public MonteCarloMultiAssetBlackScholesModel(BrownianMotion brownianMotion, double[] initialValues, double riskFreeRate, double[] volatilities, double[][] correlations)Create a Monte-Carlo simulation using given time discretization.- Parameters:
brownianMotion
- The Brownian motion to be used for the numerical scheme.initialValues
- Spot values.riskFreeRate
- The risk free rate.volatilities
- The log volatilities.correlations
- A correlation matrix.
-
MonteCarloMultiAssetBlackScholesModel
public MonteCarloMultiAssetBlackScholesModel(TimeDiscretization timeDiscretization, int numberOfPaths, double[] initialValues, double riskFreeRate, double[] volatilities, double[][] correlations)Create a Monte-Carlo simulation using given time discretization.- Parameters:
timeDiscretization
- The time discretization.numberOfPaths
- The number of Monte-Carlo path to be used.initialValues
- Spot values.riskFreeRate
- The risk free rate.volatilities
- The log volatilities.correlations
- A correlation matrix.
-
MonteCarloMultiAssetBlackScholesModel
public MonteCarloMultiAssetBlackScholesModel(TimeDiscretization timeDiscretization, int numberOfPaths, int seed, double[] initialValues, double riskFreeRate, double[] volatilities, double[][] correlations)Create a Monte-Carlo simulation using given time discretization.- Parameters:
timeDiscretization
- The time discretization.numberOfPaths
- The number of Monte-Carlo path to be used.seed
- The seed to be used.initialValues
- Spot values.riskFreeRate
- The risk free rate.volatilities
- The log volatilities.correlations
- A correlation matrix.
-
-
Method Details
-
getInitialState
Description copied from interface:ProcessModel
Returns the initial value of the state variable of the process Y, not to be confused with the initial value of the model X (which is the state space transform applied to this state value.- Specified by:
getInitialState
in interfaceProcessModel
- Parameters:
process
- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.- Returns:
- The initial value of the state variable of the process Y(t=0).
-
getDrift
public RandomVariable[] getDrift(MonteCarloProcess process, int timeIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)Description copied from interface:ProcessModel
This method has to be implemented to return the drift, i.e. the coefficient vector
μ = (μ1, ..., μn) such that X = f(Y) and
dYj = μj dt + λ1,j dW1 + ... + λm,j dWm
in an m-factor model. Here j denotes index of the component of the resulting process. Since the model is provided only on a time discretization, the method may also (should try to) return the drift as \( \frac{1}{t_{i+1}-t_{i}} \int_{t_{i}}^{t_{i+1}} \mu(\tau) \mathrm{d}\tau \).- Specified by:
getDrift
in interfaceProcessModel
- Parameters:
process
- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex
- The time index (related to the model times discretization).realizationAtTimeIndex
- The given realization at timeIndexrealizationPredictor
- The given realization attimeIndex+1
or null if no predictor is available.- Returns:
- The drift or average drift from timeIndex to timeIndex+1, i.e. \( \frac{1}{t_{i+1}-t_{i}} \int_{t_{i}}^{t_{i+1}} \mu(\tau) \mathrm{d}\tau \) (or a suitable approximation).
-
getFactorLoading
public RandomVariable[] getFactorLoading(MonteCarloProcess process, int timeIndex, int component, RandomVariable[] realizationAtTimeIndex)Description copied from interface:ProcessModel
This method has to be implemented to return the factor loadings, i.e. the coefficient vector
λj = (λ1,j, ..., λm,j) such that X = f(Y) and
dYj = μj dt + λ1,j dW1 + ... + λm,j dWm
in an m-factor model. Here j denotes index of the component of the resulting process.- Specified by:
getFactorLoading
in interfaceProcessModel
- Parameters:
process
- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex
- The time index (related to the model times discretization).component
- The index j of the driven component.realizationAtTimeIndex
- The realization of X at the time corresponding to timeIndex (in order to implement local and stochastic volatlity models).- Returns:
- The factor loading for given factor and component.
-
applyStateSpaceTransform
public RandomVariable applyStateSpaceTransform(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)Description copied from interface:ProcessModel
Applies the state space transform fi to the given state random variable such that Yi → fi(Yi) =: Xi.- Specified by:
applyStateSpaceTransform
in interfaceProcessModel
- Parameters:
process
- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex
- The time index (related to the model times discretization).componentIndex
- The component index i.randomVariable
- The state random variable Yi.- Returns:
- New random variable holding the result of the state space transformation.
-
applyStateSpaceTransformInverse
public RandomVariable applyStateSpaceTransformInverse(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)Description copied from interface:ProcessModel
Applies the inverse state space transform f-1i to the given random variable such that Xi → f-1i(Xi) =: Yi.- Specified by:
applyStateSpaceTransformInverse
in interfaceProcessModel
- Parameters:
process
- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex
- The time index (related to the model times discretization).componentIndex
- The component index i.randomVariable
- The state random variable Xi.- Returns:
- New random variable holding the result of the state space transformation.
-
getAssetValue
Description copied from interface:AssetModelMonteCarloSimulationModel
Returns the random variable representing the asset's value at a given time for a given asset.- Specified by:
getAssetValue
in interfaceAssetModelMonteCarloSimulationModel
- Parameters:
time
- Simulation timeassetIndex
- Index of the asset (0 for a single asset model)- Returns:
- The asset process as seen on simulation time
- Throws:
CalculationException
- Thrown if the valuation fails, specific cause may be available via thecause()
method.
-
getAssetValue
Description copied from interface:AssetModelMonteCarloSimulationModel
Returns the random variable representing the asset's value at a given time for a given asset.- Specified by:
getAssetValue
in interfaceAssetModelMonteCarloSimulationModel
- Parameters:
timeIndex
- Index of simulation timeassetIndex
- Index of the asset (0 for a single asset model)- Returns:
- The asset process as seen on simulation time
- Throws:
CalculationException
- Thrown if the valuation fails, specific cause may be available via thecause()
method.
-
getMonteCarloWeights
Description copied from interface:MonteCarloSimulationModel
This method returns the weights of a weighted Monte Carlo method (the probability density).- Specified by:
getMonteCarloWeights
in interfaceMonteCarloSimulationModel
- Parameters:
time
- Time at which the process should be observed- Returns:
- A vector of positive weights which sums up to one
- Throws:
CalculationException
- Thrown if the valuation fails, specific cause may be available via thecause()
method.
-
getNumeraire
Description copied from interface:ProcessModel
Return the numeraire at a given time index. Note: The random variable returned is a defensive copy and may be modified.- Specified by:
getNumeraire
in interfaceProcessModel
- Parameters:
process
- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.time
- The time t for which the numeraire N(t) should be returned.- Returns:
- The numeraire at the specified time as
RandomVariable
-
getNumeraire
Description copied from interface:AssetModelMonteCarloSimulationModel
Returns the numeraire associated with the valuation measure used by this model.- Specified by:
getNumeraire
in interfaceAssetModelMonteCarloSimulationModel
- Parameters:
timeIndex
- The time index (associated with this models time discretization).- Returns:
- The numeraire associated with the valuation measure used by this model.
- Throws:
CalculationException
- Thrown if calculation of numeraire fails.
-
getNumeraire
Description copied from interface:AssetModelMonteCarloSimulationModel
Returns the numeraire associated with the valuation measure used by this model.- Specified by:
getNumeraire
in interfaceAssetModelMonteCarloSimulationModel
- Parameters:
time
- The time for which the numeraire is requested.- Returns:
- The numeraire associated with the valuation measure used by this model.
- Throws:
CalculationException
- Thrown if calculation of numeraire fails.
-
getRandomVariableForConstant
Description copied from interface:MonteCarloSimulationModel
Returns a random variable which is initialized to a constant, but has exactly the same number of paths or discretization points as the ones used by thisMonteCarloSimulationModel
.- Specified by:
getRandomVariableForConstant
in interfaceMonteCarloSimulationModel
- Specified by:
getRandomVariableForConstant
in interfaceProcessModel
- Parameters:
value
- The constant value to be used for initialized the random variable.- Returns:
- A new random variable.
-
getNumberOfComponents
public int getNumberOfComponents()Description copied from interface:ProcessModel
Returns the number of components- Specified by:
getNumberOfComponents
in interfaceProcessModel
- Returns:
- The number of components
-
getNumberOfAssets
public int getNumberOfAssets()Description copied from interface:AssetModelMonteCarloSimulationModel
Returns the number of asset price processes.- Specified by:
getNumberOfAssets
in interfaceAssetModelMonteCarloSimulationModel
- Returns:
- The number of asset price processes
-
toString
-
getRiskFreeRate
public double getRiskFreeRate()Returns the risk free rate parameter of this model.- Returns:
- Returns the riskFreeRate.
-
getFactorLoadings
public double[][] getFactorLoadings()Returns the factorLoadings parameters of this model.- Returns:
- Returns the factorLoadings.
-
getVolatilities
public double[] getVolatilities()Returns the volatility parameters of this model.- Returns:
- Returns the volatilities.
-
getCorrelations
public double[][] getCorrelations()Returns the volatility parameters of this model.- Returns:
- Returns the volatilities.
-
getNumberOfPaths
public int getNumberOfPaths()Returns the number of paths.- Specified by:
getNumberOfPaths
in interfaceMonteCarloSimulationModel
- Returns:
- The number of paths.
- See Also:
MonteCarloProcess.getNumberOfPaths()
-
getCloneWithModifiedData
public MonteCarloMultiAssetBlackScholesModel getCloneWithModifiedData(Map<String,Object> dataModified)Description copied from interface:AssetModelMonteCarloSimulationModel
Create a clone of this simulation modifying some of its properties (if any).- Specified by:
getCloneWithModifiedData
in interfaceAssetModelMonteCarloSimulationModel
- Specified by:
getCloneWithModifiedData
in interfaceMonteCarloSimulationModel
- Specified by:
getCloneWithModifiedData
in interfaceProcessModel
- Parameters:
dataModified
- The data which should be changed in the new model- Returns:
- Returns a clone of this model, with some data modified (then it is no longer a clone :-)
-
getCloneWithModifiedSeed
Description copied from interface:AssetModelMonteCarloSimulationModel
Create a clone of the object implementingAssetModelMonteCarloSimulationModel
using a different Monte-Carlo seed.- Specified by:
getCloneWithModifiedSeed
in interfaceAssetModelMonteCarloSimulationModel
- Parameters:
seed
- The seed of the underlying random number generator.- Returns:
- Returns a clone of this model except for a modified Monte-Carlo seed.
-
getTimeDiscretization
Description copied from interface:MonteCarloSimulationModel
Returns the timeDiscretizationFromArray.- Specified by:
getTimeDiscretization
in interfaceMonteCarloSimulationModel
- Returns:
- Returns the timeDiscretizationFromArray.
-
getTime
public double getTime(int timeIndex)Description copied from interface:MonteCarloSimulationModel
Returns the time for a given time index.- Specified by:
getTime
in interfaceMonteCarloSimulationModel
- Parameters:
timeIndex
- Time index- Returns:
- Returns the time for a given time index.
-
getTimeIndex
public int getTimeIndex(double time)Description copied from interface:MonteCarloSimulationModel
Returns the time index for a given time.- Specified by:
getTimeIndex
in interfaceMonteCarloSimulationModel
- Parameters:
time
- The time.- Returns:
- Returns the time index for a given time.
-
getMonteCarloWeights
Description copied from interface:MonteCarloSimulationModel
This method returns the weights of a weighted Monte Carlo method (the probability density).- Specified by:
getMonteCarloWeights
in interfaceMonteCarloSimulationModel
- Parameters:
timeIndex
- Time index at which the process should be observed- Returns:
- A vector of positive weights which sums up to one
- Throws:
CalculationException
- Thrown if the valuation fails, specific cause may be available via thecause()
method.
-
getNumberOfFactors
public int getNumberOfFactors()Description copied from interface:ProcessModel
Returns the number of factors m, i.e., the number of independent Brownian drivers.- Specified by:
getNumberOfFactors
in interfaceProcessModel
- Returns:
- The number of factors.
-