/// <summary> /// An inital test to see if the guess was good.. /// </summary> /// <returns></returns> public Boolean InitialValue() { var curve = new SimpleFxCurve(_baseDate, _interpolationMethod, _extrapolation, _dates, _dfs); var impliedQuote = _priceableAsset.CalculateImpliedQuote(curve); var marketQuote = MarketQuoteHelper.NormalisePriceUnits(_priceableAsset.MarketQuote, "DecimalRate").value; var quoteError = (double)(marketQuote - impliedQuote); return(Math.Abs(quoteError) < _cTolerance); }
static public IMarketEnvironment CreateSimpleFxCurve(string curveName, DateTime baseDate, Double[] times, Double[] dfs) { var market = new MarketEnvironment(); var interpMethod = InterpolationMethodHelper.Parse("LinearInterpolation"); var curve = new SimpleFxCurve(baseDate, interpMethod, true, times, dfs); market.AddPricingStructure(curveName, curve); return(market); }
/// <summary> /// Values the specified discount factor. /// </summary> /// <param name="discountFactor">The discount factor.</param> /// <returns>Quote error - difference between market quote and implied (from the bootstrapped term structure) quote</returns> public double Value(double discountFactor) { _dfs[_dfs.Count - 1] = discountFactor; var curve = new SimpleFxCurve(_baseDate, _interpolationMethod, _extrapolation, _dates, _dfs); var impliedQuote = _priceableAsset.CalculateImpliedQuote(curve); var marketQuote = MarketQuoteHelper.NormalisePriceUnits(_priceableAsset.MarketQuote, "DecimalRate").value; var quoteError = (double)(marketQuote - impliedQuote); return(quoteError); }