From ceac80965ecbd38eb96b27b1f480ef962101788d Mon Sep 17 00:00:00 2001 From: Gavin Brennan Date: Fri, 9 Aug 2024 15:43:56 +0100 Subject: [PATCH] Equity price curve fix --- src/Qwack.Core/Curves/EquityPriceCurve.cs | 7 ++++--- version.props | 2 +- version.txt | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Qwack.Core/Curves/EquityPriceCurve.cs b/src/Qwack.Core/Curves/EquityPriceCurve.cs index 7409280b..573e7d1f 100644 --- a/src/Qwack.Core/Curves/EquityPriceCurve.cs +++ b/src/Qwack.Core/Curves/EquityPriceCurve.cs @@ -80,7 +80,7 @@ public EquityPriceCurve(DateTime buildDate, double spot, string ccy, IIrCurve ir IrCurve = irCurve; SpotDate = spotDate; - PillarLabels = new string[1] {"SPOT"}; + PillarLabels = new string[1] { "SPOT" }; Initialize(); } @@ -92,6 +92,7 @@ public EquityPriceCurve(TO_EquityPriceCurve to, IFundingModel fundingModel, ICur AssetId = to.AssetId; Name = to.Name; Currency = currencyProvider.GetCurrencySafe(to.Currency); + IrCurve = to.IrCurve == null ? null : fundingModel.GetCurve(to.IrCurve); } private void Initialize() @@ -112,7 +113,7 @@ public double GetPriceForFixingDate(DateTime date) private double GetFwd(DateTime fwdDate, double divYield) { var t = SpotDate.CalculateYearFraction(fwdDate, Basis); - var df = IrCurve.GetDf(BuildDate, fwdDate); + var df = IrCurve?.GetDf(BuildDate, fwdDate) ?? 1.0; var fwd = Spot / df / (1 + divYield * t); if (DiscreteDivDates.Any(x => x > BuildDate && x <= fwdDate)) { @@ -120,7 +121,7 @@ private double GetFwd(DateTime fwdDate, double divYield) { var ix = Array.IndexOf(DiscreteDivDates, d); //Array.BinarySearch(DiscreteDivDates, d); var div = DiscreteDivs[ix]; - var dfDiv = IrCurve.GetDf(d, fwdDate); + var dfDiv = IrCurve?.GetDf(d, fwdDate) ?? 1.0; fwd -= div / dfDiv; } } diff --git a/version.props b/version.props index d791d0d2..43f6cd78 100644 --- a/version.props +++ b/version.props @@ -1,5 +1,5 @@ - 0.8.74 + 0.8.75 diff --git a/version.txt b/version.txt index 944e10b7..330cced5 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.8.74 \ No newline at end of file +0.8.75 \ No newline at end of file