/*! Returns an approximation of the covariance defined as * \f$ \sigma(t_0, \mathbf{x}_0)^2 \Delta t \f$. */ public Matrix covariance(StochasticProcess process, double t0, Vector x0, double dt) { Matrix sigma = process.diffusion(t0, x0); Matrix result = sigma * Matrix.transpose(sigma) * dt; return(result); }
// constructor public MCLookbackEngine(GeneralizedBlackScholesProcess process, int?timeSteps, int?timeStepsPerYear, bool brownianBridge, bool antitheticVariate, int?requiredSamples, double?requiredTolerance, int?maxSamples, ulong seed) : base(antitheticVariate, false) { process_ = process; timeSteps_ = timeSteps; timeStepsPerYear_ = timeStepsPerYear; requiredSamples_ = requiredSamples; maxSamples_ = maxSamples; requiredTolerance_ = requiredTolerance; brownianBridge_ = brownianBridge; seed_ = seed; Utils.QL_REQUIRE(timeSteps != null || timeStepsPerYear != null, () => "no time steps provided"); Utils.QL_REQUIRE(timeSteps == null || timeStepsPerYear == null, () => "both time steps and time steps per year were provided"); if (timeSteps != null) { Utils.QL_REQUIRE(timeSteps > 0, () => "timeSteps must be positive, " + timeSteps + " not allowed"); } if (timeStepsPerYear != null) { Utils.QL_REQUIRE(timeStepsPerYear > 0, () => "timeStepsPerYear must be positive, " + timeStepsPerYear + " not allowed"); } process_.registerWith(update); }
// constructors public PathGenerator(StochasticProcess process, double length, int timeSteps, GSG generator, bool brownianBridge) { brownianBridge_ = brownianBridge; generator_ = generator; dimension_ = generator_.dimension(); timeGrid_ = new TimeGrid(length, timeSteps); process_ = process as StochasticProcess1D; next_ = new Sample <IPath>(new Path(timeGrid_), 1.0); temp_ = new InitializedList <double>(dimension_); bb_ = new BrownianBridge(timeGrid_); Utils.QL_REQUIRE(dimension_ == timeSteps, () => "sequence generator dimensionality (" + dimension_ + ") != timeSteps (" + timeSteps + ")"); }
protected MCVanillaEngine(StochasticProcess process, int?timeSteps, int?timeStepsPerYear, bool brownianBridge, bool antitheticVariate, bool controlVariate, int?requiredSamples, double?requiredTolerance, int?maxSamples, ulong seed) : base(process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, requiredSamples, requiredTolerance, maxSamples, seed) { }
protected MCLongstaffSchwartzEngine(StochasticProcess process, int?timeSteps, int?timeStepsPerYear, bool brownianBridge, bool antitheticVariate, bool controlVariate, int?requiredSamples, double?requiredTolerance, int?maxSamples, ulong seed, int nCalibrationSamples) : base(process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, requiredSamples, requiredTolerance, maxSamples, seed, nCalibrationSamples) { }
public DiscretizedVanillaOption(VanillaOption.Arguments args, StochasticProcess process, TimeGrid grid) { arguments_ = args; stoppingTimes_ = new InitializedList <double>(args.exercise.dates().Count); for (int i = 0; i < stoppingTimes_.Count; ++i) { stoppingTimes_[i] = process.time(args.exercise.date(i)); if (!grid.empty()) { // adjust to the given grid stoppingTimes_[i] = grid.closestTime(stoppingTimes_[i]); } } }
public MultiPathGenerator(StochasticProcess process, TimeGrid times, GSG generator, bool brownianBridge) { brownianBridge_ = brownianBridge; process_ = process; generator_ = generator; next_ = new Sample <IPath>(new MultiPath(process.size(), times), 1.0); Utils.QL_REQUIRE(generator_.dimension() == process.factors() * (times.size() - 1), () => "dimension (" + generator_.dimension() + ") is not equal to (" + process.factors() + " * " + (times.size() - 1) + ") the number of factors " + "times the number of time steps"); Utils.QL_REQUIRE(times.size() > 1, () => "no times given"); }
public DiscretizedBarrierOption(BarrierOption.Arguments args, StochasticProcess process, TimeGrid grid = null) { arguments_ = args; vanilla_ = new DiscretizedVanillaOption(arguments_, process, grid); Utils.QL_REQUIRE(args.exercise.dates().Count > 0, () => "specify at least one stopping date"); stoppingTimes_ = new InitializedList <double>(args.exercise.dates().Count); for (int i = 0; i < stoppingTimes_.Count; ++i) { stoppingTimes_[i] = process.time(args.exercise.date(i)); if (grid != null && !grid.empty()) { // adjust to the given grid stoppingTimes_[i] = grid.closestTime(stoppingTimes_[i]); } } }
public DiscretizedDermanKaniBarrierOption(BarrierOption.Arguments args, StochasticProcess process, TimeGrid grid = null) { unenhanced_ = new DiscretizedBarrierOption(args, process, grid); }
/*! Returns an approximation of the diffusion defined as * \f$ \sigma(t_0, \mathbf{x}_0) \sqrt{\Delta t} \f$. */ public Matrix diffusion(StochasticProcess process, double t0, Vector x0, double dt) { return(process.diffusion(t0, x0) * Math.Sqrt(dt)); }
/*! Returns an approximation of the drift defined as * \f$ \mu(t_0, \mathbf{x}_0) \Delta t \f$. */ public Vector drift(StochasticProcess process, double t0, Vector x0, double dt) { return(process.drift(t0, x0) * dt); }