Beispiel #1
0
 public DupireProcess()
 {
     this.s0       = new ModelParameter(string.Empty, "S0");
     this.r        = new ModelParameter(string.Empty, "Time Dependent Risk Free Rate (Zero Rate)");
     this.q        = new ModelParameter(string.Empty, "Time Dependent Continuous Dividend Yield");
     this.localVol = new ModelParameter(string.Empty, "Local Volatility");
 }
Beispiel #2
0
 /// <summary>
 /// Prepares the serialized model parameters with the provided values.
 /// </summary>
 private void SetParametersValue()
 {
     this.k     = new ModelParameter(this.parameterValues[0], parameterNames[0]);
     this.theta = new ModelParameter(this.parameterValues[1], parameterNames[1]);
     this.sigma = new ModelParameter(this.parameterValues[2], parameterNames[2]);
     this.r0    = new ModelParameter(this.parameterValues[3], parameterNames[3]);
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the HW1 class given alpha, sigma, lambda and a zero rate reference.
 /// </summary>
 /// <param name="alpha">The rate of the mean reversion to be used to initialize HW.</param>
 /// <param name="sigma">The standard deviation to be used to initialize HW.</param>
 /// <param name="lambda">The market price of risk to be used to initialize HW.</param>
 /// <param name="zeroRateReference">
 /// Reference to the zero rate to be used to initialize HW.
 /// </param>
 public HW1(double alpha, double sigma, double lambda, string zeroRateReference)
 {
     this.alpha1      = new ModelParameter(alpha, alphaDescription);
     this.sigma1      = new ModelParameter(sigma, sigmaDescription);
     this.lambda0     = new ModelParameter(lambda, lambda0Description);
     this.zrReference = new ModelParameter(zeroRateReference, zeroRateDescription);
 }
Beispiel #4
0
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to the Heston extended process.
        /// </summary>
        /// <param name="stocProcess">
        /// The stochastic process which is being referenced to.
        /// </param>
        /// <param name="estimate">
        /// The estimation result which contains values and names of parameters.
        /// It will be searched for S0, kappa, theta, sigma, V0 and rho.
        /// </param>
        public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
        {
            bool found;

            this.S0    = new ModelParameter(PopulateHelper.GetValue("S0", estimate.Names, estimate.Values, out found), this.S0.Description);
            this.k     = new ModelParameter(PopulateHelper.GetValue("kappa", estimate.Names, estimate.Values, out found), this.k.Description);
            this.theta = new ModelParameter(PopulateHelper.GetValue("theta", estimate.Names, estimate.Values, out found), this.theta.Description);
            this.sigma = new ModelParameter(PopulateHelper.GetValue("sigma", estimate.Names, estimate.Values, out found), this.sigma.Description);
            this.V0    = new ModelParameter(PopulateHelper.GetValue("V0", estimate.Names, estimate.Values, out found), this.V0.Description);

            int            index = stocProcess.NoiseIndex;
            ProjectProcess prj   = stocProcess.Context as ProjectProcess;

            // Update the correlation matrix.
            prj.Processes.r.Set(index, index + 1, (RightValue)PopulateHelper.GetValue("rho", estimate.Names, estimate.Values, out found));
            bool errors = RetrieveCurve(stocProcess.Context, false);

            if (!errors)
            {
                this.zrCurve.Expr = (estimate.Objects[0] as Matrix).ToArray();
                this.dyCurve.Expr = (estimate.Objects[1] as Matrix).ToArray();
                //Calibrator assumes dividend yield is a step constant function, the simulation model must be coherent with that assumption.
                (this.dyCurve as PFunction).m_Function.iType = DVPLUtils.EInterpolationType.ZERO_ORDER_LEFT;
            }
        }
Beispiel #5
0
 public void OnDeserialized(StreamingContext context)
 {
     if (this.driftAdjustment == null)
     {
         this.driftAdjustment = new ModelParameter(0, driftAdjustmentDescription);
     }
 }
Beispiel #6
0
        public void Populate(IStochasticProcess container, EstimationResult estimate)
        {
            bool found;

            this.s0 = new ModelParameter(PopulateHelper.GetValue("S0", estimate.Names, estimate.Values, out found), this.s0.Description);

            bool errors = RetrieveCurve(container.Context, false);

            if (!errors)
            {
                PFunction rFunc     = estimate.Objects[0] as PFunction;
                PFunction rFuncDest = this.r.fVRef() as PFunction;
                rFuncDest.Expr = rFunc.Expr;

                PFunction qFunc     = estimate.Objects[1] as PFunction;
                PFunction qFuncDest = this.q.fVRef() as PFunction;
                qFuncDest.Expr = qFunc.Expr;
                //Calibrator assumes dividend yield is a step constant function, the simulation model must be coherent with that assumption.
                qFuncDest.m_Function.iType = DVPLUtils.EInterpolationType.ZERO_ORDER_LEFT;


                PFunction2D.PFunction2D localVolSrc  = estimate.Objects[2] as PFunction2D.PFunction2D;
                PFunction2D.PFunction2D localVolDest = this.localVol.fVRef() as PFunction2D.PFunction2D;
                localVolDest.Expr          = localVolSrc.Expr;
                localVolDest.Interpolation = localVolSrc.Interpolation;
            }
        }
 void Init()
 {
     this.spot   = new ModelParameter(0, spotLabel);
     this.mu     = new ModelParameter(0, muLabel);
     this.lambda = new ModelParameter(0, lambdaLabel);
     this.sigma  = new ModelParameter(0, sigmaLabel);
 }
 /// <summary>
 /// Constructor which builds a new SquareGaussianModel with provided values.
 /// </summary>
 /// <param name="sigma">The sigma factor of the model.</param>
 /// <param name="lambda">The parameter is not used.</param>
 /// <param name="a1">The alpha factor of the model.</param>
 /// <param name="zeroRateReference">A reference to a zero rate.</param>
 public SquaredGaussianModel(double sigma, double lambda, double a1, string zeroRateReference)
 {
     this.sigma1 = new ModelParameter(sigma, sigma1Description);
     this.a1     = new ModelParameter(a1, a1Description);
     this.zr     = new ModelParameter(zeroRateReference, zrDescription);
     this.lamda0 = new ModelParameter(lambda, lambda0Description);
 }
Beispiel #9
0
        /*
         * /// <summary>
         * /// Populate editable fields from name and value vectors
         * /// specific to HW.
         * /// </summary>
         * /// <param name="names">
         * /// An array with the names of the variable,
         * /// will search for alpha (or a1), sigma (or sigma1).
         * /// </param>
         * /// <param name="values">The values associated to the parameters in names.</param>
         * public void Populate(string[] names, double[] values)
         * {
         *  bool found = false;
         *  this.alpha1 = new ModelParameter(PopulateHelper.GetValue("alpha", "a1", names, values, out found), alphaDescription);
         *  this.sigma1 = new ModelParameter(PopulateHelper.GetValue("sigma", "sigma1", names, values, out found), sigmaDescription);
         *  this.lambda0 = new ModelParameter(PopulateHelper.GetValue("Lambda0", "lambda0", names, values, out found), lambda0Description);
         * }
         */

        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to the Heston extended process.
        /// </summary>
        /// <param name="stocProcess">
        /// The stochastic process which is being referenced to.
        /// </param>
        /// <param name="estimate">
        /// The estimation result which contains values and names of parameters.
        /// It will be searched for S0, kappa, theta, sigma, V0 and rho.
        /// </param>
        public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
        {
            bool found;

            this.alpha1  = new ModelParameter(PopulateHelper.GetValue("alpha", "a1", estimate.Names, estimate.Values, out found), alphaDescription);
            this.sigma1  = new ModelParameter(PopulateHelper.GetValue("sigma", "sigma1", estimate.Names, estimate.Values, out found), sigmaDescription);
            this.lambda0 = new ModelParameter(PopulateHelper.GetValue("Lambda0", "lambda0", estimate.Names, estimate.Values, out found), lambda0Description);
        }
Beispiel #10
0
 /// <summary>
 /// Sets some default values for the parameters.
 /// * k = 2.5
 /// * theta = 0.4
 /// * sigma = 0.2
 /// * S0 = 1
 /// * V0 = 0.3.
 /// </summary>
 public void DefaultInstance()
 {
     this.k     = new ModelParameter(2.5, "k");
     this.theta = new ModelParameter(0.4, "theta");
     this.sigma = new ModelParameter(0.2, "sigma");
     this.S0    = new ModelParameter(1, "S0");
     this.V0    = new ModelParameter(0.3, "V0");
 }
Beispiel #11
0
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to Pelsser.
        /// </summary>
        /// <param name="names">
        /// An array with the names of the variable,
        /// will search for alpha1 (or a), sigma1 (or sigma) and lamba0.
        /// </param>
        /// <param name="values">The values associated to the parameters in names.</param>
        public void Populate(string[] names, double[] values)
        {
            bool found;

            this.a1     = new ModelParameter(PopulateHelper.GetValue("alpha1", "a", names, values, out found), a1Description);
            this.sigma1 = new ModelParameter(PopulateHelper.GetValue("sigma1", "sigma", names, values, out found), sigma1Description);
            this.lamda0 = new ModelParameter(PopulateHelper.GetValue("lambda0", "lambda", names, values, out found), lambda0Description);
        }
Beispiel #12
0
 void OnDeserialized(StreamingContext context)
 {
     //Fix lambda0: some old files have it set to null
     if (this.lamda0 == null)
     {
         this.lamda0 = new ModelParameter(0, lambda0Description);
     }
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the HestonExtendedProcess class.
 /// This is the default constructor setting all parameters to zero/empty.
 /// </summary>
 public HestonExtendedProcess()
 {
     InitOptionalFields();
     this.k     = new ModelParameter(0.0, "k");
     this.theta = new ModelParameter(0.0, "theta");
     this.sigma = new ModelParameter(0.0, "sigma");
     this.S0    = new ModelParameter(0.0, "S0");
     this.V0    = new ModelParameter(0.0, "V0");
 }
        public void Populate(string[] names, double[] values)
        {
            bool found;

            this.spot   = new ModelParameter(PopulateHelper.GetValue(spotLabel, names, values, out found), spotLabel);
            this.mu     = new ModelParameter(PopulateHelper.GetValue(muLabel, names, values, out found), muLabel);
            this.lambda = new ModelParameter(PopulateHelper.GetValue(lambdaLabel, names, values, out found), lambdaLabel);
            this.sigma  = new ModelParameter(PopulateHelper.GetValue(sigmaLabel, names, values, out found), sigmaLabel);
        }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the VarianceGamma class.
 /// Defines a new process with given parameter values.
 /// </summary>
 /// <param name="s0">Starting value.</param>
 /// <param name="theta">VG theta parameter.</param>
 /// <param name="sigma">VG sigma parameter.</param>
 /// <param name="nu">VG nu parameter.</param>
 /// <param name="r">Risk free rate.</param>
 /// <param name="q">Continuous dividend yield.</param>
 public VarianceGamma(double s0, double theta, double sigma, double nu, double r, double q)
 {
     this.s0       = new ModelParameter(s0, s0Description);
     this.theta    = new ModelParameter(theta, thetaDescription);
     this.sigma    = new ModelParameter(sigma, sigmaDescription);
     this.nu       = new ModelParameter(nu, nuDescription);
     this.rate     = new ModelParameter(r, rateDescription);
     this.dividend = new ModelParameter(q, dividendDescription);
 }
Beispiel #16
0
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to HW2.
        /// </summary>
        /// <param name="names">
        /// An array with the names of the variable,
        /// will search for alpha1 (or a1), sigma1 (or sigma), alpha2 (or a2), sigma2 and rho.
        /// </param>
        /// <param name="values">The values associated to the parameters in names.</param>
        public void Populate(string[] names, double[] values)
        {
            bool found = false;

            this._a1  = new ModelParameter(PopulateHelper.GetValue("alpha1", "a1", names, values, out found), a1Description);
            this._s1  = new ModelParameter(PopulateHelper.GetValue("sigma1", "sigma", names, values, out found), s1Description);
            this._a2  = new ModelParameter(PopulateHelper.GetValue("alpha2", "a2", names, values, out found), a2Description);
            this._s2  = new ModelParameter(PopulateHelper.GetValue("sigma2", names, values, out found), s2Description);
            this._rho = new ModelParameter(PopulateHelper.GetValue("rho", names, values, out found), rhoDescription);
        }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the HestonProcess class.
 /// This is the default constructor and sets all parameters to 0.0.
 /// </summary>
 public HestonProcess()
 {
     this.r     = new ModelParameter(0.0, "r");
     this.q     = new ModelParameter(0.0, "q");
     this.k     = new ModelParameter(0.0, "k");
     this.theta = new ModelParameter(0.0, "theta");
     this.sigma = new ModelParameter(0.0, "sigma");
     this.S0    = new ModelParameter(0.0, "S0");
     this.V0    = new ModelParameter(0.0, "V0");
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HullAndWhiteTwoFactors.HW2"/> class.
 /// This is the default constructor and sets the
 /// default values of several components of the model:
 /// * alpha 1 = 0.1
 /// * sigma 1 = 0.001
 /// * alpha 2 = 0.01
 /// * sigma 2 = 0.001
 /// * rho = 0.001
 /// * No zero rate.
 /// * drift correction = 0.
 /// </summary>
 public HW2()
 {
     this._zr             = new ModelParameter(string.Empty, zeroRateDescription);
     this._a1             = new ModelParameter(0.1, a1Description);
     this._s1             = new ModelParameter(0.001, s1Description);
     this._a2             = new ModelParameter(0.01, a2Description);
     this._s2             = new ModelParameter(0.001, s2Description);
     this._rho            = new ModelParameter(0.001, rhoDescription);
     this.driftAdjustment = new ModelParameter(0, driftAdjustmentDescription);
 }
Beispiel #19
0
 /// <summary>
 /// Initializes a new instance of the HestonProcess class.
 /// This is the default constructor and sets all parameters to 0.0.
 /// </summary>
 public HestonProcess()
 {
     this.r = new ModelParameter(0.0, "r");
     this.q = new ModelParameter(0.0, "q");
     this.k = new ModelParameter(0.0, "k");
     this.theta = new ModelParameter(0.0, "theta");
     this.sigma = new ModelParameter(0.0, "sigma");
     this.S0 = new ModelParameter(0.0, "S0");
     this.V0 = new ModelParameter(0.0, "V0");
 }
Beispiel #20
0
        /// <summary>
        /// Initializes a new instance of the VarianceGamma class.
        /// Initializes the object based on the serialized data.
        /// </summary>
        /// <param name="info">The SerializationInfo that holds the serialized object data.</param>
        /// <param name="context">The StreamingContext that contains contextual
        /// information about the source.</param>
        protected VarianceGamma(SerializationInfo info, StreamingContext context)
        {
            int readVersion = info.GetInt32("varianceGammaVersion");

            this.s0       = (IModelParameter)ObjectSerialization.GetValue2(info, "s0", typeof(IModelParameter));
            this.theta    = (IModelParameter)ObjectSerialization.GetValue2(info, "theta", typeof(IModelParameter));
            this.sigma    = (IModelParameter)ObjectSerialization.GetValue2(info, "sigma", typeof(IModelParameter));
            this.nu       = (IModelParameter)ObjectSerialization.GetValue2(info, "nu", typeof(IModelParameter));
            this.rate     = (IModelParameter)ObjectSerialization.GetValue2(info, "rate", typeof(IModelParameter));
            this.dividend = (IModelParameter)ObjectSerialization.GetValue2(info, "dividend", typeof(IModelParameter));
        }
Beispiel #21
0
        /// <summary>
        /// Populate editable fields from name and value vectors specific to VG.
        /// </summary>
        /// <param name="names">
        /// An array with the names of the variables.
        /// </param>
        /// <param name="values">The values associated to the parameters in names.</param>
        public void Populate(string[] names, double[] values)
        {
            bool found = false;

            this.theta = new ModelParameter(PopulateHelper.GetValue("S0", names, values, out found), thetaDescription);
            this.sigma = new ModelParameter(PopulateHelper.GetValue("theta", names, values, out found), sigmaDescription);
            this.theta = new ModelParameter(PopulateHelper.GetValue("sigma", names, values, out found), thetaDescription);
            this.theta = new ModelParameter(PopulateHelper.GetValue("nu", names, values, out found), thetaDescription);
            this.theta = new ModelParameter(PopulateHelper.GetValue("rate", names, values, out found), thetaDescription);
            this.theta = new ModelParameter(PopulateHelper.GetValue("dividend", names, values, out found), thetaDescription);
        }
Beispiel #22
0
 private void OnDeserialized(StreamingContext context)
 {
     if (this.driftAdjustment == null)
     {
         this.driftAdjustment = new ModelParameter(0, driftAdjustmentDescription);
     }
     if (this.lambda0 == null)
     {
         this.lambda0 = new ModelParameter(0, lambda0Description);
     }
 }
Beispiel #23
0
        /// <summary>
        /// Initializes the zr and dy reference to empty values, in case they are not initialized.
        /// </summary>
        private void InitOptionalFields()
        {
            if (this.zrReference == null)
            {
                this.zrReference = new ModelParameter(string.Empty, "zero rate curve");
            }

            if (this.dyReference == null)
            {
                this.dyReference = new ModelParameter(string.Empty, "dividend yield curve");
            }
        }
Beispiel #24
0
 /// <summary>
 /// Sets the default values for the components.
 /// </summary>
 public void DefaultValues()
 {
     this.k1             = new ModelParameter(0.026758131);
     this.k2             = new ModelParameter(0.226406137);
     this.theta1         = new ModelParameter(0.023147821);
     this.theta2         = new ModelParameter(0.01);
     this.sigma1         = new ModelParameter(0.1);
     this.sigma2         = new ModelParameter(0.0001);
     this.startingValue1 = new ModelParameter(0.00001);
     this.startingValue2 = new ModelParameter(0.00001);
     this.ZRReference    = (ModelParameter)"@ZR";
     SetDescription();
 }
Beispiel #25
0
        /// <summary>
        /// Creates a list of all the sub-objects that can be edited.
        /// </summary>
        /// <param name="recursive">
        /// The parameter is not used.
        /// </param>
        /// <returns>
        /// The created list with all the sub objects that can be edited.
        /// </returns>
        public List <IExportable> ExportObjects(bool recursive)
        {
            List <IExportable> parameters = new List <IExportable>();

            parameters.Add(this.a1);
            parameters.Add(this.sigma1);
            /// Manage the case in which lamda0 is null
            if (this.lamda0 == null)
            {
                this.lamda0 = new ModelParameter(0.0, lambda0Description);
            }
            parameters.Add(this.lamda0);
            parameters.Add(this.zr);
            return(parameters);
        }
Beispiel #26
0
        /// <summary>
        /// Parses the process (in this case nothing has to be done).
        /// </summary>
        /// <param name="context">The project representing the context of the parsing.</param>
        /// <returns>true if the the parsing caused errors; otherwise false.</returns>
        public bool Parse(IProject context)
        {
            bool errors = false;

            errors = this.s0.Parse(context);
            errors = BoolHelper.AddBool(errors, this.q.Parse(context));
            errors = BoolHelper.AddBool(errors, this.r.Parse(context));
            errors = BoolHelper.AddBool(errors, this.localVol.Parse(context));

            this.context          = new DupireContext();
            this.context.s0       = this.s0.fV();
            this.context.q        = this.q.fVRef() as IFunction;
            this.context.r        = this.r.fVRef() as IFunction;
            this.context.localVol = this.localVol.fVRef() as IFunction;

            return(RetrieveCurve(context, errors));
        }
Beispiel #27
0
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to the Heston extended process.
        /// </summary>
        /// <param name="stocProcess">
        /// The stochastic process which is being referenced to.
        /// </param>
        /// <param name="estimate">
        /// The estimation result which contains values and names of parameters.
        /// It will be searched for S0, kappa, theta, sigma, V0, r, q and rho.
        /// </param>
        public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
        {
            bool found;

            this.S0    = new ModelParameter(PopulateHelper.GetValue("S0", estimate.Names, estimate.Values, out found), this.S0.Description);
            this.k     = new ModelParameter(PopulateHelper.GetValue("kappa", estimate.Names, estimate.Values, out found), this.k.Description);
            this.theta = new ModelParameter(PopulateHelper.GetValue("theta", estimate.Names, estimate.Values, out found), this.theta.Description);
            this.sigma = new ModelParameter(PopulateHelper.GetValue("sigma", estimate.Names, estimate.Values, out found), this.sigma.Description);
            this.V0    = new ModelParameter(PopulateHelper.GetValue("V0", estimate.Names, estimate.Values, out found), this.V0.Description);
            this.r     = new ModelParameter(PopulateHelper.GetValue("r", estimate.Names, estimate.Values, out found), this.r.Description);
            this.q     = new ModelParameter(PopulateHelper.GetValue("q", estimate.Names, estimate.Values, out found), this.q.Description);

            int            index = stocProcess.NoiseIndex;
            ProjectProcess prj   = stocProcess.Context as ProjectProcess;

            // Updates the correlation.
            prj.Processes.r.Set(index, index + 1, (RightValue)PopulateHelper.GetValue("rho", estimate.Names, estimate.Values, out found));
        }
Beispiel #28
0
 /// <summary>
 /// Prepares the serialized model parameters with the provided values.
 /// </summary>
 private void SetParametersValue()
 {
     this.k = new ModelParameter(this.parameterValues[0], parameterNames[0]);
     this.theta = new ModelParameter(this.parameterValues[1], parameterNames[1]);
     this.sigma = new ModelParameter(this.parameterValues[2], parameterNames[2]);
     this.r0 = new ModelParameter(this.parameterValues[3], parameterNames[3]);
 }
Beispiel #29
0
 public DupireProcess()
 {
     this.s0 = new ModelParameter(string.Empty, "S0");
     this.r = new ModelParameter(string.Empty, "Time Dependent Risk Free Rate (Zero Rate)");
     this.q = new ModelParameter(string.Empty, "Time Dependent Continuous Dividend Yield");
     this.localVol = new ModelParameter(string.Empty, "Local Volatility");
 }
 /// <summary>
 /// Associate the process to a zero rate and a dividend yield defined in the Fairmat model
 /// (e.g. @zr1).
 /// </summary>
 /// <param name='zrstring'>
 /// The zero rate reference.
 /// </param>
 /// <param name='dystring'>
 /// The dividend yield reference.
 /// </param>
 public void SetCurveReference(string zrstring, string dystring)
 {
     this.zrReference = new ModelParameter(zrstring);
     this.dyReference = new ModelParameter(dystring);
 }
Beispiel #31
0
 /// <summary>
 /// Sets some default values for the parameters.
 /// * r = 0.05
 /// * q = 0.03
 /// * k = 2.5
 /// theta = 0.4
 /// sigma = 0.2
 /// S0 = 100
 /// V0 = 0.3.
 /// </summary>
 public void DefaultInstance()
 {
     this.r = new ModelParameter(0.05, "r");
     this.q = new ModelParameter(0.03, "q");
     this.k = new ModelParameter(2.5, "k");
     this.theta = new ModelParameter(0.4, "theta");
     this.sigma = new ModelParameter(0.2, "sigma");
     this.S0 = new ModelParameter(100, "S0");
     this.V0 = new ModelParameter(0.3, "V0");
 }
Beispiel #32
0
 /// <summary>
 /// Associate the process to a zero rate defined in the Fairmat model
 /// (e.g. @zr1).
 /// </summary>
 /// <param name='zr'>
 /// The zero rate reference.
 /// </param>
 public void SetZeroRateReference(string zr)
 {
     this.zr = new ModelParameter(zr, zrDescription);
 }
Beispiel #33
0
 /// <summary>
 /// Creates a list of all the sub-objects that can be edited.
 /// </summary>
 /// <param name="recursive">
 /// The parameter is not used.
 /// </param>
 /// <returns>
 /// The created list with all the sub objects that can be edited.
 /// </returns>
 public List<IExportable> ExportObjects(bool recursive)
 {
     List<IExportable> parameters = new List<IExportable>();
     parameters.Add(this.a1);
     parameters.Add(this.sigma1);
     /// Manage the case in which lamda0 is null
     if (this.lamda0 == null)
         this.lamda0 = new ModelParameter(0.0, lambda0Description);
     parameters.Add(this.lamda0);
     parameters.Add(this.zr);
     return parameters;
 }
Beispiel #34
0
 /// <summary>
 /// Associate the process to a zero rate defined in the Fairmat model
 /// (e.g. @zr1).
 /// </summary>
 /// <param name='zr'>
 /// The zero rate reference.
 /// </param>
 public void SetZeroRateReference(string zr)
 {
     this._zr = new ModelParameter(zr, "Zero Rate");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HullAndWhiteTwoFactors.HW2"/> class.
 /// This is the default constructor and sets the
 /// default values of several components of the model:
 /// * alpha 1 = 0.1
 /// * sigma 1 = 0.001
 /// * alpha 2 = 0.01
 /// * sigma 2 = 0.001
 /// * rho = 0.001
 /// * No zero rate.
 /// * drift correction = 0.
 /// </summary>
 public HW2()
 {
     this._zr = new ModelParameter(string.Empty, zeroRateDescription);
     this._a1 = new ModelParameter(0.1, a1Description);
     this._s1 = new ModelParameter(0.001, s1Description);
     this._a2 = new ModelParameter(0.01, a2Description);
     this._s2 = new ModelParameter(0.001, s2Description);
     this._rho = new ModelParameter(0.001, rhoDescription);
     this.driftAdjustment = new ModelParameter(0, driftAdjustmentDescription);
 }
 /// <summary>
 /// Populate editable fields from name and value vectors
 /// specific to HW2.
 /// </summary>
 /// <param name="names">
 /// An array with the names of the variable,
 /// will search for alpha1 (or a1), sigma1 (or sigma), alpha2 (or a2), sigma2 and rho.
 /// </param>
 /// <param name="values">The values associated to the parameters in names.</param>
 public void Populate(string[] names, double[] values)
 {
     bool found = false;
     this._a1 = new ModelParameter(PopulateHelper.GetValue("alpha1", "a1", names, values, out found), a1Description);
     this._s1 = new ModelParameter(PopulateHelper.GetValue("sigma1", "sigma", names, values, out found), s1Description);
     this._a2 = new ModelParameter(PopulateHelper.GetValue("alpha2", "a2", names, values, out found), a2Description);
     this._s2 = new ModelParameter(PopulateHelper.GetValue("sigma2", names, values, out found), s2Description);
     this._rho = new ModelParameter(PopulateHelper.GetValue("rho", names, values, out found), rhoDescription);
 }
Beispiel #37
0
 /// <summary>
 /// Sets the default values for the components.
 /// </summary>
 public void DefaultValues()
 {
     this.k1 = new ModelParameter(0.026758131);
     this.k2 = new ModelParameter(0.226406137);
     this.theta1 = new ModelParameter(0.023147821);
     this.theta2 = new ModelParameter(0.01);
     this.sigma1 = new ModelParameter(0.1);
     this.sigma2 = new ModelParameter(0.0001);
     this.startingValue1 = new ModelParameter(0.00001);
     this.startingValue2 = new ModelParameter(0.00001);
     this.ZRReference = (ModelParameter)"@ZR";
     SetDescription();
 }
Beispiel #38
0
 /// <summary>
 /// Populate editable fields from name and value vectors specific to VG.
 /// </summary>
 /// <param name="names">
 /// An array with the names of the variables.
 /// </param>
 /// <param name="values">The values associated to the parameters in names.</param>
 public void Populate(string[] names, double[] values)
 {
     bool found = false;
     this.theta = new ModelParameter(PopulateHelper.GetValue("S0", names, values, out found), thetaDescription);
     this.sigma = new ModelParameter(PopulateHelper.GetValue("theta", names, values, out found), sigmaDescription);
     this.theta = new ModelParameter(PopulateHelper.GetValue("sigma", names, values, out found), thetaDescription);
     this.theta = new ModelParameter(PopulateHelper.GetValue("nu", names, values, out found), thetaDescription);
     this.theta = new ModelParameter(PopulateHelper.GetValue("rate", names, values, out found), thetaDescription);
     this.theta = new ModelParameter(PopulateHelper.GetValue("dividend", names, values, out found), thetaDescription);
 }
Beispiel #39
0
 /// <summary>
 /// Initializes a new instance of the VarianceGamma class.
 /// Initializes the object based on the serialized data.
 /// </summary>
 /// <param name="info">The SerializationInfo that holds the serialized object data.</param>
 /// <param name="context">The StreamingContext that contains contextual
 /// information about the source.</param>
 protected VarianceGamma(SerializationInfo info, StreamingContext context)
 {
     int readVersion = info.GetInt32("varianceGammaVersion");
     this.s0 = (IModelParameter)ObjectSerialization.GetValue2(info, "s0", typeof(IModelParameter));
     this.theta = (IModelParameter)ObjectSerialization.GetValue2(info, "theta", typeof(IModelParameter));
     this.sigma = (IModelParameter)ObjectSerialization.GetValue2(info, "sigma", typeof(IModelParameter));
     this.nu = (IModelParameter)ObjectSerialization.GetValue2(info, "nu", typeof(IModelParameter));
     this.rate = (IModelParameter)ObjectSerialization.GetValue2(info, "rate", typeof(IModelParameter));
     this.dividend = (IModelParameter)ObjectSerialization.GetValue2(info, "dividend", typeof(IModelParameter));
 }
Beispiel #40
0
 /// <summary>
 /// Initializes a new instance of the VarianceGamma class.
 /// Defines a new process with given parameter values.
 /// </summary>
 /// <param name="s0">Starting value.</param>
 /// <param name="theta">VG theta parameter.</param>
 /// <param name="sigma">VG sigma parameter.</param>
 /// <param name="nu">VG nu parameter.</param>
 /// <param name="r">Risk free rate.</param>
 /// <param name="q">Continuous dividend yield.</param>
 public VarianceGamma(double s0, double theta, double sigma, double nu, double r, double q)
 {
     this.s0 = new ModelParameter(s0, s0Description);
     this.theta = new ModelParameter(theta, thetaDescription);
     this.sigma = new ModelParameter(sigma, sigmaDescription);
     this.nu = new ModelParameter(nu, nuDescription);
     this.rate = new ModelParameter(r, rateDescription);
     this.dividend = new ModelParameter(q, dividendDescription);
 }
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to the Heston extended process.
        /// </summary>
        /// <param name="stocProcess">
        /// The stochastic process which is being referenced to.
        /// </param>
        /// <param name="estimate">
        /// The estimation result which contains values and names of parameters.
        /// It will be searched for S0, kappa, theta, sigma, V0 and rho.
        /// </param>
        public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
        {
            bool found;
            this.S0 = new ModelParameter(PopulateHelper.GetValue("S0", estimate.Names, estimate.Values, out found), this.S0.Description);
            this.k = new ModelParameter(PopulateHelper.GetValue("kappa", estimate.Names, estimate.Values, out found), this.k.Description);
            this.theta = new ModelParameter(PopulateHelper.GetValue("theta", estimate.Names, estimate.Values, out found), this.theta.Description);
            this.sigma = new ModelParameter(PopulateHelper.GetValue("sigma", estimate.Names, estimate.Values, out found), this.sigma.Description);
            this.V0 = new ModelParameter(PopulateHelper.GetValue("V0", estimate.Names, estimate.Values, out found), this.V0.Description);

            int index = stocProcess.NoiseIndex;
            ProjectProcess prj = stocProcess.Context as ProjectProcess;

            // Update the correlation matrix.
            prj.Processes.r.Set(index, index + 1, (RightValue)PopulateHelper.GetValue("rho", estimate.Names, estimate.Values, out found));
            bool errors = RetrieveCurve(stocProcess.Context, false);
            if (!errors)
            {
                this.zrCurve.Expr = (estimate.Objects[0] as Matrix).ToArray();
                this.dyCurve.Expr = (estimate.Objects[1] as Matrix).ToArray();
                //Calibrator assumes dividend yield is a step constant function, the simulation model must be coherent with that assumption.
                (this.dyCurve as PFunction).m_Function.iType = DVPLUtils.EInterpolationType.ZERO_ORDER_LEFT;
            }
        }
Beispiel #42
0
        /// <summary>
        /// Parses the process (in this case nothing has to be done).
        /// </summary>
        /// <param name="context">The project representing the context of the parsing.</param>
        /// <returns>true if the the parsing caused errors; otherwise false.</returns>
        public bool Parse(IProject context)
        {
            bool errors = false;
            errors = this.s0.Parse(context);
            errors = BoolHelper.AddBool(errors, this.q.Parse(context));
            errors = BoolHelper.AddBool(errors, this.r.Parse(context));
            errors = BoolHelper.AddBool(errors, this.localVol.Parse(context));

            this.context = new DupireContext();
            this.context.s0 = this.s0.fV();
            this.context.q = this.q.fVRef() as IFunction;
            this.context.r = this.r.fVRef() as IFunction;
            this.context.localVol = this.localVol.fVRef() as IFunction;

            return RetrieveCurve(context, errors);
        }
 public void OnDeserialized(StreamingContext context)
 {
     if (this.driftAdjustment == null)
     {
         this.driftAdjustment = new ModelParameter(0, driftAdjustmentDescription);
     }
 }
Beispiel #44
0
        /*
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to HW.
        /// </summary>
        /// <param name="names">
        /// An array with the names of the variable,
        /// will search for alpha (or a1), sigma (or sigma1).
        /// </param>
        /// <param name="values">The values associated to the parameters in names.</param>
        public void Populate(string[] names, double[] values)
        {
            bool found = false;
            this.alpha1 = new ModelParameter(PopulateHelper.GetValue("alpha", "a1", names, values, out found), alphaDescription);
            this.sigma1 = new ModelParameter(PopulateHelper.GetValue("sigma", "sigma1", names, values, out found), sigmaDescription);
            this.lambda0 = new ModelParameter(PopulateHelper.GetValue("Lambda0", "lambda0", names, values, out found), lambda0Description);
        }
        */

        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to the Heston extended process.
        /// </summary>
        /// <param name="stocProcess">
        /// The stochastic process which is being referenced to.
        /// </param>
        /// <param name="estimate">
        /// The estimation result which contains values and names of parameters.
        /// It will be searched for S0, kappa, theta, sigma, V0 and rho.
        /// </param>
        public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
        {
            bool found;
            this.alpha1 = new ModelParameter(PopulateHelper.GetValue("alpha", "a1", estimate.Names, estimate.Values, out found), alphaDescription);
            this.sigma1 = new ModelParameter(PopulateHelper.GetValue("sigma", "sigma1", estimate.Names, estimate.Values, out found), sigmaDescription);
            this.lambda0 = new ModelParameter(PopulateHelper.GetValue("Lambda0", "lambda0", estimate.Names, estimate.Values, out found), lambda0Description);
        }
        /// <summary>
        /// Initializes the zr and dy reference to empty values, in case they are not initialized.
        /// </summary>
        private void InitOptionalFields()
        {
            if (this.zrReference == null)
                this.zrReference = new ModelParameter(string.Empty, "zero rate curve");

            if (this.dyReference == null)
                this.dyReference = new ModelParameter(string.Empty, "dividend yield curve");
        }
Beispiel #46
0
 /// <summary>
 /// Associate the process to a zero rate defined in the Fairmat model
 /// (e.g. @zr1).
 /// </summary>
 /// <param name='zr'>
 /// The zero rate reference.
 /// </param>
 public void SetZeroRateReference(string zr)
 {
     this.zrReference = new ModelParameter(zr, "Zero Rate");
 }
Beispiel #47
0
 /// <summary>
 /// Constructor which builds a new SquareGaussianModel with provided values.
 /// </summary>
 /// <param name="sigma">The sigma factor of the model.</param>
 /// <param name="lambda">The parameter is not used.</param>
 /// <param name="a1">The alpha factor of the model.</param>
 /// <param name="zeroRateReference">A reference to a zero rate.</param>
 public SquaredGaussianModel(double sigma, double lambda, double a1, string zeroRateReference)
 {
     this.sigma1 = new ModelParameter(sigma, sigma1Description);
     this.a1 = new ModelParameter(a1, a1Description);
     this.zr = new ModelParameter(zeroRateReference, zrDescription);
     this.lamda0 = new ModelParameter(lambda, lambda0Description);
 }
Beispiel #48
0
 /// <summary>
 /// Associate the process to a zero rate and a dividend yield defined in the Fairmat model
 /// (e.g. @zr1).
 /// </summary>
 /// <param name='zrstring'>
 /// The zero rate reference.
 /// </param>
 /// <param name='dystring'>
 /// The dividend yield reference.
 /// </param>
 public void SetCurveReference(string zrstring, string dystring)
 {
     this.zrReference = new ModelParameter(zrstring);
     this.dyReference = new ModelParameter(dystring);
 }
Beispiel #49
0
 /// <summary>
 /// Populate editable fields from name and value vectors
 /// specific to Pelsser.
 /// </summary>
 /// <param name="names">
 /// An array with the names of the variable,
 /// will search for alpha1 (or a), sigma1 (or sigma) and lamba0.
 /// </param>
 /// <param name="values">The values associated to the parameters in names.</param>
 public void Populate(string[] names, double[] values)
 {
     bool found;
     this.a1 = new ModelParameter(PopulateHelper.GetValue("alpha1", "a", names, values, out found), a1Description);
     this.sigma1 = new ModelParameter(PopulateHelper.GetValue("sigma1", "sigma", names, values, out found), sigma1Description);
     this.lamda0 = new ModelParameter(PopulateHelper.GetValue("lambda0", "lambda", names, values, out found), lambda0Description);
 }
Beispiel #50
0
 private void OnDeserialized(StreamingContext context)
 {
     if (this.driftAdjustment == null)
         this.driftAdjustment = new ModelParameter(0, driftAdjustmentDescription);
     if (this.lambda0 == null)
         this.lambda0= new ModelParameter(0, lambda0Description);
 }
Beispiel #51
0
 void OnDeserialized(StreamingContext context)
 {
     //Fix lambda0: some old files have it set to null
     if (this.lamda0 == null)
         this.lamda0 = new ModelParameter(0, lambda0Description);
 }
Beispiel #52
0
 /// <summary>
 /// Initializes a new instance of the HW1 class given alpha, sigma, lambda and a zero rate reference.
 /// </summary>
 /// <param name="alpha">The rate of the mean reversion to be used to initialize HW.</param>
 /// <param name="sigma">The standard deviation to be used to initialize HW.</param>
 /// <param name="lambda">The market price of risk to be used to initialize HW.</param>
 /// <param name="zeroRateReference">
 /// Reference to the zero rate to be used to initialize HW.
 /// </param>
 public HW1(double alpha, double sigma, double lambda, string zeroRateReference)
 {
     this.alpha1 = new ModelParameter(alpha, alphaDescription);
     this.sigma1 = new ModelParameter(sigma, sigmaDescription);
     this.lambda0 = new ModelParameter(lambda, lambda0Description);
     this.zrReference = new ModelParameter(zeroRateReference, zeroRateDescription);
 }
Beispiel #53
0
        /// <summary>
        /// Populate editable fields from name and value vectors
        /// specific to the Heston extended process.
        /// </summary>
        /// <param name="stocProcess">
        /// The stochastic process which is being referenced to.
        /// </param>
        /// <param name="estimate">
        /// The estimation result which contains values and names of parameters.
        /// It will be searched for S0, kappa, theta, sigma, V0, r, q and rho.
        /// </param>
        public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
        {
            bool found;
            this.S0 = new ModelParameter(PopulateHelper.GetValue("S0", estimate.Names, estimate.Values, out found), this.S0.Description);
            this.k = new ModelParameter(PopulateHelper.GetValue("kappa", estimate.Names, estimate.Values, out found), this.k.Description);
            this.theta = new ModelParameter(PopulateHelper.GetValue("theta", estimate.Names, estimate.Values, out found), this.theta.Description);
            this.sigma = new ModelParameter(PopulateHelper.GetValue("sigma", estimate.Names, estimate.Values, out found), this.sigma.Description);
            this.V0 = new ModelParameter(PopulateHelper.GetValue("V0", estimate.Names, estimate.Values, out found), this.V0.Description);
            this.r = new ModelParameter(PopulateHelper.GetValue("r", estimate.Names, estimate.Values, out found), this.r.Description);
            this.q = new ModelParameter(PopulateHelper.GetValue("q", estimate.Names, estimate.Values, out found), this.q.Description);

            int index = stocProcess.NoiseIndex;
            ProjectProcess prj = stocProcess.Context as ProjectProcess;

            // Updates the correlation.
            prj.Processes.r.Set(index, index + 1, (RightValue)PopulateHelper.GetValue("rho", estimate.Names, estimate.Values, out found));
        }
Beispiel #54
0
 /// <summary>
 /// Associate the process to a zero rate defined in the Fairmat model
 /// (e.g. @zr1).
 /// </summary>
 /// <param name='zr'>
 /// The zero rate reference.
 /// </param>
 public void SetZeroRateReference(string zr)
 {
     this.zr = new ModelParameter(zr, zrDescription);
 }
 /// <summary>
 /// Initializes a new instance of the HestonExtendedProcess class.
 /// This is the default constructor setting all parameters to zero/empty.
 /// </summary>
 public HestonExtendedProcess()
 {
     InitOptionalFields();
     this.k = new ModelParameter(0.0, "k");
     this.theta = new ModelParameter(0.0, "theta");
     this.sigma = new ModelParameter(0.0, "sigma");
     this.S0 = new ModelParameter(0.0, "S0");
     this.V0 = new ModelParameter(0.0, "V0");
 }
Beispiel #56
0
        public void Populate(IStochasticProcess container, EstimationResult estimate)
        {
            bool found;
            this.s0 = new ModelParameter(PopulateHelper.GetValue("S0", estimate.Names, estimate.Values, out found), this.s0.Description);

            bool errors = RetrieveCurve(container.Context, false);
            if (!errors)
            {
                PFunction rFunc = estimate.Objects[0] as PFunction;
                PFunction rFuncDest = this.r.fVRef() as PFunction;
                rFuncDest.Expr = rFunc.Expr;

                PFunction qFunc = estimate.Objects[1] as PFunction;
                PFunction qFuncDest = this.q.fVRef() as PFunction;
                qFuncDest.Expr = qFunc.Expr;
                //Calibrator assumes dividend yield is a step constant function, the simulation model must be coherent with that assumption.
                qFuncDest.m_Function.iType = DVPLUtils.EInterpolationType.ZERO_ORDER_LEFT;

                PFunction2D.PFunction2D localVolSrc = estimate.Objects[2] as PFunction2D.PFunction2D;
                PFunction2D.PFunction2D localVolDest = this.localVol.fVRef() as PFunction2D.PFunction2D;
                localVolDest.Expr = localVolSrc.Expr;
                localVolDest.Interpolation = localVolSrc.Interpolation;
            }
        }