Skip to content

Commit

Permalink
YTW in base logic (BondUtils)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavbrennan committed Sep 22, 2022
1 parent 5947503 commit 42f5d70
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Qwack.Math/BondUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public static double YieldToWorst(double couponRate, double faceValue, double cl
public static double YieldToWorst(double couponRate, double[] redemptionPrices, double cleanPrice, double[] tRedeem)
=> tRedeem.Select((t, ix) => YieldToMaturity(couponRate, redemptionPrices[ix], cleanPrice, t)).Min();


// public static double YtmInBase(double couponRate, double faceValue, double periodsPerYear, double tMaturity, double tNext, Func<double,double> fxRates, double dirtyPriceInLocal)
public static double YieldToWorstInBase(double couponRate, double[] redemptionPrices, double periodsPerYear, double tNext, double cleanPrice, double[] tRedeem, Func<double, double> fxRates)
=> tRedeem.Select((t, ix) => YtmInBase(couponRate, redemptionPrices[ix], periodsPerYear, t, tNext, fxRates, cleanPrice)).Min();

public static double PriceFromYtm(double couponRate, double faceValue, double ytm, double t)
=> (couponRate * 2 + faceValue * (2 / t - ytm)) / (ytm + 2 / t);

Expand Down

0 comments on commit 42f5d70

Please sign in to comment.