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
Constructors Constructor Description MonteCarloBlackScholesModel2(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RandomVariablegetAssetValue(double time, int assetIndex)Returns the random variable representing the asset's value at a given time for a given asset.RandomVariablegetAssetValue(int timeIndex, int assetIndex)Returns the random variable representing the asset's value at a given time for a given asset.AssetModelMonteCarloSimulationModelgetCloneWithModifiedData(Map<String,Object> dataModified)Create a clone of this simulation modifying some of its properties (if any).AssetModelMonteCarloSimulationModelgetCloneWithModifiedSeed(int seed)Create a clone of the object implementingAssetModelMonteCarloSimulationModelusing a different Monte-Carlo seed.RandomVariablegetDrift(int timeIndex, int componentIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)RandomVariablegetFactorLoading(int timeIndex, int factor, int component, RandomVariable[] realizationAtTimeIndex)This method should be overwritten and return the factor loading, i.e.RandomVariable[]getInitialValue()RandomVariablegetMonteCarloWeights(double time)This method returns the weights of a weighted Monte Carlo method (the probability density).intgetNumberOfAssets()Returns the number of asset price processes.RandomVariablegetNumeraire(double time)Returns the numeraire associated with the valuation measure used by this model.RandomVariablegetNumeraire(int timeIndex)Returns the numeraire associated with the valuation measure used by this model.RandomVariablegetRandomVariableForConstant(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.LocalDateTimegetReferenceDate()Returns the model's date corresponding to the time discretization's \( t = 0 \).doublegetRiskFreeRate()Returns the riskFreeRate.doublegetVolatility()Returns the volatility.StringtoString()-
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 Detail
-
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 Detail
-
getReferenceDate
public LocalDateTime getReferenceDate()
Description copied from interface:MonteCarloSimulationModelReturns the model's date corresponding to the time discretization's \( t = 0 \).- Specified by:
getReferenceDatein interfaceMonteCarloSimulationModel- Returns:
- The model's date corresponding to the time discretization's \( t = 0 \).
-
getNumberOfAssets
public int getNumberOfAssets()
Description copied from interface:AssetModelMonteCarloSimulationModelReturns the number of asset price processes.- Specified by:
getNumberOfAssetsin interfaceAssetModelMonteCarloSimulationModel- Returns:
- The number of asset price processes
-
getInitialValue
public RandomVariable[] getInitialValue()
- Specified by:
getInitialValuein classLogNormalProcess- Returns:
- Returns the initialValue.
-
getDrift
public RandomVariable getDrift(int timeIndex, int componentIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)
- Specified by:
getDriftin classLogNormalProcess
-
getFactorLoading
public RandomVariable getFactorLoading(int timeIndex, int factor, int component, RandomVariable[] realizationAtTimeIndex)
Description copied from class:LogNormalProcessThis 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:
getFactorLoadingin 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
public RandomVariable getAssetValue(int timeIndex, int assetIndex)
Description copied from interface:AssetModelMonteCarloSimulationModelReturns the random variable representing the asset's value at a given time for a given asset.- Specified by:
getAssetValuein 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
public RandomVariable getAssetValue(double time, int assetIndex)
Description copied from interface:AssetModelMonteCarloSimulationModelReturns the random variable representing the asset's value at a given time for a given asset.- Specified by:
getAssetValuein 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
public RandomVariable getMonteCarloWeights(double time)
Description copied from interface:MonteCarloSimulationModelThis method returns the weights of a weighted Monte Carlo method (the probability density).- Specified by:
getMonteCarloWeightsin interfaceMonteCarloSimulationModel- Parameters:
time- Time at which the process should be observed- Returns:
- A vector of positive weights which sums up to one
-
getNumeraire
public RandomVariable getNumeraire(int timeIndex)
Description copied from interface:AssetModelMonteCarloSimulationModelReturns the numeraire associated with the valuation measure used by this model.- Specified by:
getNumerairein 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
public RandomVariable getNumeraire(double time)
Description copied from interface:AssetModelMonteCarloSimulationModelReturns the numeraire associated with the valuation measure used by this model.- Specified by:
getNumerairein interfaceAssetModelMonteCarloSimulationModel- Parameters:
time- The time for which the numeraire is requested.- Returns:
- The numeraire associated with the valuation measure used by this model.
-
getRandomVariableForConstant
public RandomVariable getRandomVariableForConstant(double value)
Description copied from interface:MonteCarloSimulationModelReturns 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:
getRandomVariableForConstantin interfaceMonteCarloSimulationModel- Parameters:
value- The constant value to be used for initialized the random variable.- Returns:
- A new random variable.
-
getRiskFreeRate
public double getRiskFreeRate()
Returns the riskFreeRate.- Returns:
- The riskFreeRate.
-
getVolatility
public double getVolatility()
Returns the volatility.- Returns:
- The volatility.
-
getCloneWithModifiedSeed
public AssetModelMonteCarloSimulationModel getCloneWithModifiedSeed(int seed)
Description copied from interface:AssetModelMonteCarloSimulationModelCreate a clone of the object implementingAssetModelMonteCarloSimulationModelusing a different Monte-Carlo seed.- Specified by:
getCloneWithModifiedSeedin 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:AssetModelMonteCarloSimulationModelCreate a clone of this simulation modifying some of its properties (if any).- Specified by:
getCloneWithModifiedDatain interfaceAssetModelMonteCarloSimulationModel- Specified by:
getCloneWithModifiedDatain 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 :-)
-
-