28 inline bool isResetTimeInPast(
const Time& resetTime,
30 const bool& includeTodaysCashFlows) {
31 return (resetTime < 0.0) &&
32 ((payTime > 0.0) || (includeTodaysCashFlows && (payTime == 0.0)));
37 const Date& referenceDate,
47 const Date& referenceDate,
49 std::vector<CouponAdjustment> fixedCouponAdjustments,
50 std::vector<CouponAdjustment> floatingCouponAdjustments)
51 : arguments_(args), fixedCouponAdjustments_(
std::move(fixedCouponAdjustments)),
52 floatingCouponAdjustments_(
std::move(floatingCouponAdjustments)) {
55 "The fixed coupon adjustments must have the same size as the number of fixed coupons.");
57 "The floating coupon adjustments must have the same size as the number of "
68 for (
Size i = 0; i < nrOfFixedCoupons; ++i) {
71 auto resetIsInPast = isResetTimeInPast(resetTime, payTime, includeTodaysCashFlows);
84 for (
Size i = 0; i < nrOfFloatingCoupons; ++i) {
87 auto resetIsInPast = isResetTimeInPast(resetTime, payTime, includeTodaysCashFlows);
103 std::vector<Time> times;
175 "current floating coupon not given");
177 values_ += currentFloatingCoupon;
179 values_ -= currentFloatingCoupon;
205 "non-constant nominals are not supported yet");
210 Real accruedSpread = nominal *
T * spread;
212 Real coupon = nominal * (1.0 - bond.
values()[j]) + accruedSpread * bond.
values()[j];
1-D array used in linear algebra.
Size size() const
dimension of the array
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
bool isOnTime(Time t) const
const Array & values() const
const ext::shared_ptr< Lattice > & method() const
void initialize(const ext::shared_ptr< Lattice > &, Time t)
Useful discretized discount bond asset.
std::vector< Time > floatingPayTimes_
void addFloatingCoupon(Size i)
void addFixedCoupon(Size i)
std::vector< bool > floatingResetTimeIsInPast_
void preAdjustValuesImpl() override
std::vector< CouponAdjustment > floatingCouponAdjustments_
std::vector< Time > fixedResetTimes_
std::vector< CouponAdjustment > fixedCouponAdjustments_
std::vector< bool > fixedResetTimeIsInPast_
std::vector< Time > floatingResetTimes_
VanillaSwap::arguments arguments_
DiscretizedSwap(const VanillaSwap::arguments &args, const Date &referenceDate, const DayCounter &dayCounter)
void postAdjustValuesImpl() override
std::vector< Time > mandatoryTimes() const override
std::vector< Time > fixedPayTimes_
void reset(Size size) override
Arguments for simple swap calculation
std::vector< Date > floatingResetDates
std::vector< Spread > floatingSpreads
std::vector< Date > fixedPayDates
std::vector< Date > fixedResetDates
std::vector< Real > floatingCoupons
std::vector< Time > floatingAccrualTimes
std::vector< Real > fixedCoupons
std::vector< Date > floatingPayDates
template class providing a null value for a given type.
ext::optional< bool > & includeTodaysCashFlows()
static Settings & instance()
access to the unique instance
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
Real Spread
spreads on interest rates
std::size_t Size
size of a container
global repository for run-time library settings