Module net.finmath.lib
Class MonteCarloBlackScholesModel2
java.lang.Object
net.finmath.montecarlo.templatemethoddesign.LogNormalProcess
net.finmath.montecarlo.templatemethoddesign.assetderivativevaluation.MonteCarloBlackScholesModel2
- All Implemented Interfaces:
Model
,AssetModelMonteCarloSimulationModel
,MonteCarloSimulationModel
public class MonteCarloBlackScholesModel2
extends LogNormalProcess
implements AssetModelMonteCarloSimulationModel
Monte Carlo simulation of a simple Black-Scholes model for a stock generated discrete process
- Version:
- 1.2
- Author:
- Christian Fries
-
Nested Class Summary
Nested classes/interfaces inherited from class net.finmath.montecarlo.templatemethoddesign.LogNormalProcess
LogNormalProcess.Scheme
-
Constructor Summary
ConstructorsConstructorDescriptionMonteCarloBlackScholesModel2(TimeDiscretization timeDiscretization, int numberOfPaths, double initialValue, double riskFreeRate, double volatility)
Create a Monte-Carlo simulation using given time discretization.MonteCarloBlackScholesModel2(TimeDiscretization timeDiscretization, int numberOfPaths, double initialValue, double riskFreeRate, double volatility, int seed)
Create a Monte-Carlo simulation using given time discretization. -
Method Summary
Modifier and TypeMethodDescriptiongetAssetValue(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.getDrift(int timeIndex, int componentIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)
getFactorLoading(int timeIndex, int factor, int component, RandomVariable[] realizationAtTimeIndex)
This method should be overwritten and return the factor loading, i.e.getMonteCarloWeights(double time)
This method returns the weights of a weighted Monte Carlo method (the probability density).int
Returns the number of asset price processes.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.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
.Returns the model's date corresponding to the time discretization's \( t = 0 \).double
Returns the riskFreeRate.double
Returns the volatility.toString()
Methods inherited from class net.finmath.montecarlo.templatemethoddesign.LogNormalProcess
getBrownianMotion, getDrift, getMonteCarloWeights, getNumberOfComponents, getNumberOfFactors, getNumberOfPaths, getProcessValue, getProcessValue, getScheme, getTime, getTimeDiscretization, getTimeIndex, setBrownianMotion, setScheme
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
getMonteCarloWeights, getNumberOfPaths, getTime, getTimeDiscretization, getTimeIndex
-
Constructor Details
-
MonteCarloBlackScholesModel2
public MonteCarloBlackScholesModel2(TimeDiscretization timeDiscretization, int numberOfPaths, double initialValue, double riskFreeRate, double volatility)Create a Monte-Carlo simulation using given time discretization.- Parameters:
timeDiscretization
- The time discretizationnumberOfPaths
- The number of Monte-Carlo path to be usedinitialValue
- Spot valueriskFreeRate
- The risk free ratevolatility
- The log volatility
-
MonteCarloBlackScholesModel2
public MonteCarloBlackScholesModel2(TimeDiscretization timeDiscretization, int numberOfPaths, double initialValue, double riskFreeRate, double volatility, int seed)Create a Monte-Carlo simulation using given time discretization.- Parameters:
timeDiscretization
- The time discretization.numberOfPaths
- The number of Monte-Carlo path to be used.initialValue
- Spot value.riskFreeRate
- The risk free rate.volatility
- The log volatility.seed
- The seed for the random number generator.
-
-
Method Details
-
getReferenceDate
Description copied from interface:MonteCarloSimulationModel
Returns the model's date corresponding to the time discretization's \( t = 0 \).- Specified by:
getReferenceDate
in interfaceMonteCarloSimulationModel
- Returns:
- The model's date corresponding to the time discretization's \( t = 0 \).
-
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
-
getInitialValue
- Specified by:
getInitialValue
in classLogNormalProcess
- Returns:
- Returns the initialValue.
-
getDrift
public RandomVariable getDrift(int timeIndex, int componentIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)- Specified by:
getDrift
in classLogNormalProcess
-
getFactorLoading
public RandomVariable getFactorLoading(int timeIndex, int factor, int component, RandomVariable[] realizationAtTimeIndex)Description copied from class:LogNormalProcess
This method should be overwritten and return the factor loading, i.e. the coeffient λ(i,j) such that
dS(j) = (...) dt + S(j) * (λ(1,j) dW(1) + ... + λ(m,j) dW(m))
in an m-factor model. Here j denotes index of the component of the resulting log-normal process and i denotes the index of the factor.Overwrite this method if you would like to implement a multi factor model.
- Specified by:
getFactorLoading
in classLogNormalProcess
- Parameters:
timeIndex
- The time index of the simulation time discretization.factor
- The factor index.component
- The component index.realizationAtTimeIndex
- The realization at the current time index.- Returns:
- factor loading for given factor and component
-
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
-
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
-
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
-
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.
-
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.
-
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
- Parameters:
value
- The constant value to be used for initialized the random variable.- Returns:
- A new random variable.
-
toString
-
getRiskFreeRate
public double getRiskFreeRate()Returns the riskFreeRate.- Returns:
- The riskFreeRate.
-
getVolatility
public double getVolatility()Returns the volatility.- Returns:
- The volatility.
-
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.
-
getCloneWithModifiedData
public AssetModelMonteCarloSimulationModel 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
- 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 :-)
-