Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2945 rd scenarios adding info to calibration #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions HullAndWhiteOneFactor/HW1.cs
Expand Up @@ -53,6 +53,26 @@ public class HW1 : IExtensibleProcessIR, IZeroRateReference, IMarkovSimulator/*I
/// </summary>
protected IModelParameter sigma1;

/// <summary>
/// RMSE Abs.
/// </summary>
protected IModelParameter rmse_a;

/// <summary>
/// RMSE Rel.
/// </summary>
protected IModelParameter rmse_r;

/// <summary>
/// Optimization problem Upper Bounds.
/// </summary>
protected IModelParameter upperBounds;

/// <summary>
/// Optimization problem Lower Bounds.
/// </summary>
protected IModelParameter lowerBounds;

/// <summary>
/// Market price of risk.
/// </summary>
Expand Down Expand Up @@ -449,6 +469,8 @@ public virtual List<IExportable> ExportObjects(bool recursive)
parameters.Add(this.sigma1);
parameters.Add(this.lambda0);
parameters.Add(this.zrReference);
parameters.Add(this.rmse_a);
parameters.Add(this.rmse_r);

return parameters;
}
Expand Down Expand Up @@ -683,6 +705,15 @@ public void Populate(IStochasticProcess stocProcess, EstimationResult estimate)
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);

if(estimate.Objects != null && estimate.Objects.Length > 0)
{
this.lowerBounds = new ModelParameterArray(estimate.Objects[0] as double[]);
this.lowerBounds.Description = "Lower Bounds";
this.upperBounds = new ModelParameterArray(estimate.Objects[1] as double[]);
this.upperBounds.Description = "Upper Bounds";
this.rmse_a = new ModelParameter((double)estimate.Objects[2], "RMSE Abs");
}
}
#endregion

Expand Down
7 changes: 5 additions & 2 deletions HullAndWhiteOneFactor/SwaptionHW1Estimator.cs
Expand Up @@ -215,15 +215,18 @@ public EstimationResult Estimate(List<object> data, IEstimationSettings settings
string[] names = new string[] { "Alpha", "Sigma" };

Console.WriteLine("SwaptionHWEstimator: hw model prices and error");
problem.Obj(solution.x,true);
double rmse_a = problem.Obj(solution.x,true);

EstimationResult result = new EstimationResult(names, solution.x);

result.ZRX = (double[])dataset.ZRMarketDates.ToArray();
result.ZRY = (double[])dataset.ZRMarket.ToArray();

double obj = problem.Obj(solution.x);

result.Objects = new object[2];
result.Objects[0] = problem.Bounds.Lb.ToArray();
result.Objects[1] = problem.Bounds.Lb.ToArray();
result.Objects[2] = rmse_a;
return result;
}
#endregion
Expand Down