public static int accruedDays(Leg leg, bool includeSettlementDateFlows, Date settlementDate = null) { if (settlementDate == null) { settlementDate = Settings.evaluationDate(); } CashFlow cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf == null) { return(0); } Date paymentDate = cf.date(); foreach (CashFlow x in leg.Where(x => x.date() == paymentDate)) { Coupon cp = x as Coupon; if (cp != null) { return(cp.accruedDays(settlementDate)); } } return(0); }
public static int accruedDays(List <CashFlow> leg, bool includeSettlementDateFlows, Date settlementDate = null) { CashFlow cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf == null) { return(0); } Date paymentDate = cf.Date; foreach (CashFlow x in leg.Where(x => x.Date == paymentDate)) { Coupon cp = x as Coupon; if (cp != null) { return(cp.accruedDays(settlementDate)); } } return(0); }