Skip to content

Commit

Permalink
Equity price curve fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gavbrennan committed Aug 9, 2024
1 parent f8d0c65 commit ceac809
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Qwack.Core/Curves/EquityPriceCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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()
Expand All @@ -112,15 +113,15 @@ 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))
{
foreach (var d in DiscreteDivDates.Where(x => x > BuildDate && x <= fwdDate))
{
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>0.8.74</VersionPrefix>
<VersionPrefix>0.8.75</VersionPrefix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.74
0.8.75

0 comments on commit ceac809

Please sign in to comment.