public virtual double CalcPv(Forward <TUnderlying> trade, IMarketCondition market) { if (market.ValuationDate >= trade.UnderlyingMaturityDate) { return(0.0); } var cfs = trade.GetReplicatingCashflows(market); return(cfs[0].PaymentAmount * (market.DividendCurves.HasValue ? market.DividendCurves.Value.Values.First().GetDf(market.ValuationDate, trade.UnderlyingMaturityDate) : 1.0) + cfs.Last().PaymentAmount *market.DiscountCurve.Value.GetDf(market.ValuationDate, trade.UnderlyingMaturityDate) + cfs.Where((x, i) => !(i == 0 || i == cfs.Length - 1)).Sum(x => x.PaymentAmount * market.UnderlyingDiscountCurve.Value.GetDf(market.ValuationDate, x.PaymentDate))); }