final InterestRate y = new InterestRate(yield, dayCounter, compounding,
frequency);
/* @Real */double price = 0.0;
/* @DiscountFactor */double discount = 1.0;
Date lastDate = new Date();
for (int i = 0; i < cashflows.size(); ++i) {
if (cashflows.get(i).hasOccurred(settlement)) {
continue;
}
final Date couponDate = cashflows.get(i).date();
/* @Real */final double amount = cashflows.get(i).amount();
if (lastDate.isNull()) {
// first not-expired coupon
if (i > 0) {
lastDate = cashflows.get(i - 1).date();
} else {
// Coupon coupon = (Coupon )cashflows.get(i);
final CashFlow coupon = cashflows.get(i);
if (coupon instanceof Coupon && coupon != null) {
// if (coupon)
lastDate = ((Coupon) coupon).accrualStartDate();
} else {
lastDate = couponDate.sub(new Period(1, TimeUnit.Years));
}
}
discount *= y.discountFactor(settlement, couponDate, lastDate,
couponDate);
} else {