inline ImpliedVolTermStructure::ImpliedVolTermStructure( const Handle<BlackVolTermStructure>& originalTS, const Date& referenceDate) : BlackVarianceTermStructure(referenceDate), originalTS_(originalTS) { registerWith(originalTS_); }
CmsCouponPricer(const Handle<SwaptionVolatilityStructure>& v = Handle<SwaptionVolatilityStructure>()) : swaptionVol_(v) { registerWith(swaptionVol_); }
JuQuadraticApproximationEngine::JuQuadraticApproximationEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
AnalyticPerformanceEngine::AnalyticPerformanceEngine( const ext::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
AnalyticDigitalAmericanEngine::AnalyticDigitalAmericanEngine( const ext::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
FFTEngine::FFTEngine( const boost::shared_ptr<StochasticProcess1D>& process, Real logStrikeSpacing) : process_(process), lambda_(logStrikeSpacing) { registerWith(process_); }
inline void FittedBondDiscountCurve::setup() { for (Size i=0; i<bondHelpers_.size(); ++i) registerWith(bondHelpers_[i]); }
inline ImpliedTermStructure::ImpliedTermStructure( const Handle<YieldTermStructure>& h, const Date& referenceDate) : YieldTermStructure(referenceDate), originalCurve_(h) { registerWith(originalCurve_); }
AnalyticDividendEuropeanEngine::AnalyticDividendEuropeanEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
void CompositeInstrument::add( const boost::shared_ptr<Instrument>& instrument, Real multiplier) { components_.push_back(std::make_pair(instrument,multiplier)); registerWith(instrument); update(); }
CreditDefaultSwap::CreditDefaultSwap(Protection::Side side, Real notional, Rate upfront, Rate runningSpread, const Schedule& schedule, BusinessDayConvention convention, const DayCounter& dayCounter, bool settlesAccrual, bool paysAtDefaultTime, const Date& protectionStart, const Date& upfrontDate, const boost::shared_ptr<Claim>& claim, const DayCounter& lastPeriodDayCounter, const Natural standardCdsStartDelayDays, const Natural standardCdsUpfrontDelayDays) : side_(side), notional_(notional), upfront_(upfront), runningSpread_(runningSpread), settlesAccrual_(settlesAccrual), paysAtDefaultTime_(paysAtDefaultTime), claim_(claim), protectionStart_(protectionStart == Null<Date>() ? schedule[0] : protectionStart) { Date d = upfrontDate == Null<Date>() ? schedule[0] : upfrontDate; try { if (schedule.rule() == DateGeneration::CDS) { // a standard CDS is identified // by the schedule rule Date evalDate = Settings::instance().evaluationDate(); if (protectionStart == Null<Date>()) protectionStart_ = evalDate + standardCdsStartDelayDays; // if protection // start is given it // is not set here if (upfrontDate == Null<Date>()) d = schedule.calendar().advance( evalDate, standardCdsUpfrontDelayDays * Days, schedule.businessDayConvention(), schedule.endOfMonth()); // if upfront date is // given it is not set // here QL_REQUIRE(protectionStart_ >= schedule[0], "protection must start on or after accrual " "start for standard CDS"); } } catch (...) { QL_REQUIRE(protectionStart_ <= schedule[0], "protection can not start after accrual for non " "standard CDS"); } leg_ = FixedRateLeg(schedule) .withNotionals(notional) .withCouponRates(runningSpread, dayCounter) .withPaymentAdjustment(convention) .withLastPeriodDayCounter(lastPeriodDayCounter); upfrontPayment_.reset(new SimpleCashFlow(notional*upfront, d)); QL_REQUIRE(upfrontPayment_->date() >= protectionStart_, "upfront can not be due before contract start"); if (!claim_) claim_ = boost::shared_ptr<Claim>(new FaceValueClaim); registerWith(claim_); }
void CapFloorTermVolSurface::registerWithMarketData() { for (Size i=0; i<nOptionTenors_; ++i) for (Size j=0; j<nStrikes_; ++j) registerWith(volHandles_[i][j]); }
VarianceGammaEngine::VarianceGammaEngine( const boost::shared_ptr<VarianceGammaProcess>& process) : process_(process) { registerWith(process_); }
void SwaptionVolatilityHullWhite::registerWithMarketData() { for (Size i=0; i<volHandles_.size(); ++i) for (Size j=0; j<volHandles_.front().size(); ++j) registerWith(volHandles_[i][j]); }
AssetSwap::AssetSwap(bool payBondCoupon, const shared_ptr<Bond>& bond, Real bondCleanPrice, const shared_ptr<IborIndex>& iborIndex, Spread spread, const Schedule& floatSchedule, const DayCounter& floatingDayCounter, bool parSwap) : Swap(2), bond_(bond), bondCleanPrice_(bondCleanPrice), nonParRepayment_(100), spread_(spread), parSwap_(parSwap) { Schedule schedule = floatSchedule; if (floatSchedule.empty()) schedule = Schedule(bond_->settlementDate(), bond_->maturityDate(), iborIndex->tenor(), iborIndex->fixingCalendar(), iborIndex->businessDayConvention(), iborIndex->businessDayConvention(), DateGeneration::Backward, false); // endOfMonth // the following might become an input parameter BusinessDayConvention paymentAdjustment = Following; Date finalDate = schedule.calendar().adjust( schedule.endDate(), paymentAdjustment); Date adjBondMaturityDate = schedule.calendar().adjust( bond_->maturityDate(), paymentAdjustment); QL_REQUIRE(finalDate==adjBondMaturityDate, "adjusted schedule end date (" << finalDate << ") must be equal to adjusted bond maturity date (" << adjBondMaturityDate << ")"); // bondCleanPrice must be the (forward) clean price // at the floating schedule start date upfrontDate_ = schedule.startDate(); Real dirtyPrice = bondCleanPrice_ + bond_->accruedAmount(upfrontDate_); Real notional = bond_->notional(upfrontDate_); /* In the market asset swap, the bond is purchased in return for payment of the full price. The notional of the floating leg is then scaled by the full price. */ if (!parSwap_) notional *= dirtyPrice/100.0; if (floatingDayCounter==DayCounter()) legs_[1] = IborLeg(schedule, iborIndex) .withNotionals(notional) .withPaymentAdjustment(paymentAdjustment) .withSpreads(spread); else legs_[1] = IborLeg(schedule, iborIndex) .withNotionals(notional) .withPaymentDayCounter(floatingDayCounter) .withPaymentAdjustment(paymentAdjustment) .withSpreads(spread); for (Leg::const_iterator i=legs_[1].begin(); i<legs_[1].end(); ++i) registerWith(*i); const Leg& bondLeg = bond_->cashflows(); for (Leg::const_iterator i=bondLeg.begin(); i<bondLeg.end(); ++i) { // whatever might be the choice for the discounting engine // bond flows on upfrontDate_ must be discarded bool upfrontDateBondFlows = false; if (!(*i)->hasOccurred(upfrontDate_, upfrontDateBondFlows)) legs_[0].push_back(*i); } QL_REQUIRE(!legs_[0].empty(), "empty bond leg to start with"); // special flows if (parSwap_) { // upfront on the floating leg Real upfront = (dirtyPrice-100.0)/100.0*notional; shared_ptr<CashFlow> upfrontCashFlow(new SimpleCashFlow(upfront, upfrontDate_)); legs_[1].insert(legs_[1].begin(), upfrontCashFlow); // backpayment on the floating leg // (accounts for non-par redemption, if any) Real backPayment = notional; shared_ptr<CashFlow> backPaymentCashFlow(new SimpleCashFlow(backPayment, finalDate)); legs_[1].push_back(backPaymentCashFlow); } else { // final notional exchange shared_ptr<CashFlow> finalCashFlow(new SimpleCashFlow(notional, finalDate)); legs_[1].push_back(finalCashFlow); } QL_REQUIRE(!legs_[0].empty(), "empty bond leg"); for (Leg::const_iterator i=legs_[0].begin(); i<legs_[0].end(); ++i) registerWith(*i); if (payBondCoupon) { payer_[0]=-1.0; payer_[1]=+1.0; } else { payer_[0]=+1.0; payer_[1]=-1.0; } }
FloatingRateBond::FloatingRateBond( Natural settlementDays, Real faceAmount, const Date& startDate, const Date& maturityDate, Frequency couponFrequency, const Calendar& calendar, const ext::shared_ptr<IborIndex>& iborIndex, const DayCounter& accrualDayCounter, BusinessDayConvention accrualConvention, BusinessDayConvention paymentConvention, Natural fixingDays, const std::vector<Real>& gearings, const std::vector<Spread>& spreads, const std::vector<Rate>& caps, const std::vector<Rate>& floors, bool inArrears, Real redemption, const Date& issueDate, const Date& stubDate, DateGeneration::Rule rule, bool endOfMonth) : Bond(settlementDays, calendar, issueDate) { maturityDate_ = maturityDate; Date firstDate, nextToLastDate; switch (rule) { case DateGeneration::Backward: firstDate = Date(); nextToLastDate = stubDate; break; case DateGeneration::Forward: firstDate = stubDate; nextToLastDate = Date(); break; case DateGeneration::Zero: case DateGeneration::ThirdWednesday: case DateGeneration::Twentieth: case DateGeneration::TwentiethIMM: QL_FAIL("stub date (" << stubDate << ") not allowed with " << rule << " DateGeneration::Rule"); default: QL_FAIL("unknown DateGeneration::Rule (" << Integer(rule) << ")"); } Schedule schedule(startDate, maturityDate_, Period(couponFrequency), calendar_, accrualConvention, accrualConvention, rule, endOfMonth, firstDate, nextToLastDate); cashflows_ = IborLeg(schedule, iborIndex) .withNotionals(faceAmount) .withPaymentDayCounter(accrualDayCounter) .withPaymentAdjustment(paymentConvention) .withFixingDays(fixingDays) .withGearings(gearings) .withSpreads(spreads) .withCaps(caps) .withFloors(floors) .inArrears(inArrears); addRedemptionsToCashflows(std::vector<Real>(1, redemption)); QL_ENSURE(!cashflows().empty(), "bond with no cashflows!"); QL_ENSURE(redemptions_.size() == 1, "multiple redemptions created"); registerWith(iborIndex); }
AssetSwap::AssetSwap(bool parSwap, const boost::shared_ptr<Bond>& bond, Real bondCleanPrice, Real nonParRepayment, Real gearing, const boost::shared_ptr<IborIndex>& iborIndex, Spread spread, const DayCounter& floatingDayCounter, Date dealMaturity, bool payBondCoupon) : Swap(2), bond_(bond), bondCleanPrice_(bondCleanPrice), nonParRepayment_(nonParRepayment), spread_(spread), parSwap_(parSwap) { Schedule tempSch(bond_->settlementDate(), bond_->maturityDate(), iborIndex->tenor(), iborIndex->fixingCalendar(), iborIndex->businessDayConvention(), iborIndex->businessDayConvention(), DateGeneration::Backward, false); // endOfMonth if (dealMaturity==Date()) dealMaturity = bond_->maturityDate(); QL_REQUIRE(dealMaturity <= tempSch.dates().back(), "deal maturity " << dealMaturity << " cannot be later than (adjusted) bond maturity " << tempSch.dates().back()); // the following might become an input parameter BusinessDayConvention paymentAdjustment = Following; Date finalDate = tempSch.calendar().adjust( dealMaturity, paymentAdjustment); Schedule schedule = tempSch.until(finalDate); // bondCleanPrice must be the (forward) clean price // at the floating schedule start date upfrontDate_ = schedule.startDate(); Real dirtyPrice = bondCleanPrice_ + bond_->accruedAmount(upfrontDate_); Real notional = bond_->notional(upfrontDate_); /* In the market asset swap, the bond is purchased in return for payment of the full price. The notional of the floating leg is then scaled by the full price. */ if (!parSwap_) notional *= dirtyPrice/100.0; if (floatingDayCounter==DayCounter()) legs_[1] = IborLeg(schedule, iborIndex) .withNotionals(notional) .withPaymentAdjustment(paymentAdjustment) .withGearings(gearing) .withSpreads(spread); else legs_[1] = IborLeg(schedule, iborIndex) .withNotionals(notional) .withPaymentDayCounter(floatingDayCounter) .withPaymentAdjustment(paymentAdjustment) .withGearings(gearing) .withSpreads(spread); for (Leg::const_iterator i=legs_[1].begin(); i<legs_[1].end(); ++i) registerWith(*i); const Leg& bondLeg = bond_->cashflows(); Leg::const_iterator i = bondLeg.begin(); // skip bond redemption for (; i<bondLeg.end()-1 && (*i)->date()<=dealMaturity; ++i) { // whatever might be the choice for the discounting engine // bond flows on upfrontDate_ must be discarded bool upfrontDateBondFlows = false; if (!(*i)->hasOccurred(upfrontDate_, upfrontDateBondFlows)) legs_[0].push_back(*i); } // if the first skipped cashflow is not the redemption // and it is a coupon then add the accrued coupon if (i<bondLeg.end()-1) { shared_ptr<Coupon> c = boost::dynamic_pointer_cast<Coupon>(*i); if (c) { shared_ptr<CashFlow> accruedCoupon(new SimpleCashFlow(c->accruedAmount(dealMaturity), finalDate)); legs_[0].push_back(accruedCoupon); } } // add the nonParRepayment_ shared_ptr<CashFlow> nonParRepaymentFlow(new SimpleCashFlow(nonParRepayment_, finalDate)); legs_[0].push_back(nonParRepaymentFlow); QL_REQUIRE(!legs_[0].empty(), "empty bond leg to start with"); // special flows if (parSwap_) { // upfront on the floating leg Real upfront = (dirtyPrice-100.0)/100.0*notional; shared_ptr<CashFlow> upfrontCashFlow(new SimpleCashFlow(upfront, upfrontDate_)); legs_[1].insert(legs_[1].begin(), upfrontCashFlow); // backpayment on the floating leg // (accounts for non-par redemption, if any) Real backPayment = notional; shared_ptr<CashFlow> backPaymentCashFlow(new SimpleCashFlow(backPayment, finalDate)); legs_[1].push_back(backPaymentCashFlow); } else { // final notional exchange shared_ptr<CashFlow> finalCashFlow (new SimpleCashFlow(notional, finalDate)); legs_[1].push_back(finalCashFlow); } QL_REQUIRE(!legs_[0].empty(), "empty bond leg"); for (Leg::const_iterator i=legs_[0].begin(); i<legs_[0].end(); ++i) registerWith(*i); if (payBondCoupon) { payer_[0]=-1.0; payer_[1]=+1.0; } else { payer_[0]=+1.0; payer_[1]=-1.0; } }
ForwardVanillaEngine<Engine>::ForwardVanillaEngine( const ext::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
void setMeanReversion(const Handle<Quote>& meanReversion) { unregisterWith(meanReversion_); meanReversion_ = meanReversion; registerWith(meanReversion_); update(); };
ForwardValueQuote::ForwardValueQuote( const ext::shared_ptr<Index>& index, const Date& fixingDate) : index_(index), fixingDate_(fixingDate) { registerWith(index_); }
IntegralHestonVarianceOptionEngine::IntegralHestonVarianceOptionEngine( const boost::shared_ptr<HestonProcess>& process) : process_(process) { registerWith(process_); }
void AbcdAtmVolCurve::registerWithMarketData() { for (Size i=0; i<volHandles_.size(); ++i) registerWith(volHandles_[i]); }
AnalyticContinuousFloatingLookbackEngine:: AnalyticContinuousFloatingLookbackEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
/* Generally inflation indices are available with a lag of 1month and then observed with a lag of 2-3 months depending whether they use an interpolated fixing or not. Here, we make the swap use the interpolation of the index to avoid incompatibilities. */ ZeroCouponInflationSwap::ZeroCouponInflationSwap( Type type, Real nominal, const Date& startDate, // start date of contract (only) const Date& maturity, // this is pre-adjustment! const Calendar& fixCalendar, BusinessDayConvention fixConvention, const DayCounter& dayCounter, Rate fixedRate, const boost::shared_ptr<ZeroInflationIndex> &infIndex, const Period& observationLag, bool adjustInfObsDates, Calendar infCalendar, BusinessDayConvention infConvention) : Swap(2), type_(type), nominal_(nominal), fixedRate_(fixedRate), infIndex_(infIndex), observationLag_(observationLag), dayCounter_(dayCounter) { // first check compatibility of index and swap definitions if (infIndex_->interpolated()) { Period pShift(infIndex_->frequency()); QL_REQUIRE(observationLag_ - pShift > infIndex_->availabilityLag(), "inconsistency between swap observation of index " << observationLag_ << " index availability " << infIndex_->availabilityLag() << " interpolated index period " << pShift << " and index availability " << infIndex_->availabilityLag() << " need (obsLag-index period) > availLag"); } else { QL_REQUIRE(infIndex_->availabilityLag() < observationLag_, "index tries to observe inflation fixings that do not yet exist: " << " availability lag " << infIndex_->availabilityLag() << " versus obs lag = " << observationLag_); } if (infCalendar==Calendar()) infCalendar = fixCalendar; if (infConvention==BusinessDayConvention()) infConvention = fixConvention; if (adjustInfObsDates) { baseDate_ = infCalendar.adjust(startDate - observationLag_, infConvention); obsDate_ = infCalendar.adjust(maturity - observationLag_, infConvention); } else { baseDate_ = startDate - observationLag_; obsDate_ = maturity - observationLag_; } Date infPayDate = infCalendar.adjust(maturity, infConvention); Date fixedPayDate = fixCalendar.adjust(maturity, fixConvention); // At this point the index may not be able to forecast // i.e. do not want to force the existence of an inflation // term structure before allowing users to create instruments. Real T = inflationYearFraction(infIndex_->frequency(), infIndex_->interpolated(), dayCounter_, baseDate_, obsDate_); // N.B. the -1.0 is because swaps only exchange growth, not notionals as well Real fixedAmount = nominal * ( std::pow(1.0 + fixedRate, T) - 1.0 ); legs_[0].push_back(boost::shared_ptr<CashFlow>( new SimpleCashFlow(fixedAmount, fixedPayDate))); bool growthOnly = true; legs_[1].push_back(boost::shared_ptr<CashFlow>( new IndexedCashFlow(nominal,infIndex,baseDate_,obsDate_,infPayDate,growthOnly))); for (Size j=0; j<2; ++j) { for (Leg::iterator i = legs_[j].begin(); i!= legs_[j].end(); ++i) registerWith(*i); } switch (type_) { case Payer: payer_[0] = +1.0; payer_[1] = -1.0; break; case Receiver: payer_[0] = -1.0; payer_[1] = +1.0; break; default: QL_FAIL("Unknown zero-inflation-swap type"); } }
IntegralEngine::IntegralEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
AnalyticDoubleBarrierBinaryEngine::AnalyticDoubleBarrierBinaryEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
IborCouponPricer(const Handle<OptionletVolatilityStructure>& v = Handle<OptionletVolatilityStructure>()) : capletVol_(v) { registerWith(capletVol_); }
BootstrapHelper<TS>::BootstrapHelper(const Handle<Quote>& quote) : quote_(quote), termStructure_(0) { registerWith(quote_); }
AnalyticCliquetEngine::AnalyticCliquetEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }
BjerksundStenslandApproximationEngine:: BjerksundStenslandApproximationEngine( const boost::shared_ptr<GeneralizedBlackScholesProcess>& process) : process_(process) { registerWith(process_); }