Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CrossCurrencySwap Class Reference

Cross currency swap. More...

#include <qle/instruments/currencyswap.hpp>

+ Inheritance diagram for CrossCurrencySwap:
+ Collaboration diagram for CrossCurrencySwap:

Public Member Functions

 CrossCurrencySwap (bool payFixed, Currency fixedCcy, std::vector< Real > fixedNominals, const Schedule &fixedSchedule, std::vector< Rate > fixedRates, const DayCounter &fixedDayCount, Currency floatCcy, std::vector< Real > floatNominals, const Schedule &floatSchedule, const QuantLib::ext::shared_ptr< IborIndex > &iborIndex, std::vector< Rate > floatSpreads, boost::optional< BusinessDayConvention > paymentConvention=boost::none, const bool isPhysicallySettled=true, const bool isResettable=false)
 
 CrossCurrencySwap (bool pay1, Currency ccy1, std::vector< Real > nominals1, const Schedule &schedule1, std::vector< Rate > fixedRates1, const DayCounter &fixedDayCount1, Currency ccy2, std::vector< Real > nominals2, const Schedule &schedule2, std::vector< Rate > fixedRates2, const DayCounter &fixedDayCount2, boost::optional< BusinessDayConvention > paymentConvention=boost::none, const bool isPhysicallySettled=true, const bool isResettable=false)
 
 CrossCurrencySwap (bool pay1, Currency ccy1, std::vector< Real > nominals1, const Schedule &schedule1, const QuantLib::ext::shared_ptr< IborIndex > &iborIndex1, std::vector< Rate > spreads1, Currency ccy2, std::vector< Real > nominals2, const Schedule &schedule2, const QuantLib::ext::shared_ptr< IborIndex > &iborIndex2, std::vector< Rate > spreads2, boost::optional< BusinessDayConvention > paymentConvention=boost::none, const bool isPhysicallySettled=true, const bool isResettable=false)
 
- Public Member Functions inherited from CurrencySwap
void alwaysForwardNotifications () override
 
void deepUpdate () override
 
Date startDate () const
 
Date maturityDate () const
 
Real legBPS (Size j) const
 
Real legNPV (Size j) const
 
Real inCcyLegBPS (Size j) const
 
Real inCcyLegNPV (Size j) const
 
DiscountFactor startDiscounts (Size j) const
 
DiscountFactor endDiscounts (Size j) const
 
DiscountFactor npvDateDiscount () const
 
const Leg & leg (Size j) const
 
const Currency & legCurrency (Size j) const
 
std::vector< Leg > legs ()
 
std::vector< Currency > currencies ()
 
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 
void fetchResults (const PricingEngine::results *) const override
 
 CurrencySwap (const std::vector< Leg > &legs, const std::vector< bool > &payer, const std::vector< Currency > &currency, const bool isPhysicallySettled=true, const bool isResettable=false)
 

Additional Inherited Members

- Protected Member Functions inherited from CurrencySwap
void setupExpired () const override
 
 CurrencySwap (Size legs)
 
- Protected Attributes inherited from CurrencySwap
std::vector< Leg > legs_
 
std::vector< Real > payer_
 
std::vector< Currency > currency_
 
bool isPhysicallySettled_
 
bool isResettable_
 
std::vector< Real > legNPV_
 
std::vector< Real > inCcyLegNPV_
 
std::vector< Real > legBPS_
 
std::vector< Real > inCcyLegBPS_
 
std::vector< DiscountFactor > startDiscounts_
 
std::vector< DiscountFactor > endDiscounts_
 
DiscountFactor npvDateDiscount_
 

Detailed Description

Cross currency swap.

Specialised CurrencySwap: Two currencies, variable notionals, rates and spreads; flavours fix/float, fix/fix, float/float

\ingroup instruments

Definition at line 188 of file currencyswap.hpp.

Constructor & Destructor Documentation

◆ CrossCurrencySwap() [1/3]

CrossCurrencySwap ( bool  payFixed,
Currency  fixedCcy,
std::vector< Real >  fixedNominals,
const Schedule &  fixedSchedule,
std::vector< Rate >  fixedRates,
const DayCounter &  fixedDayCount,
Currency  floatCcy,
std::vector< Real >  floatNominals,
const Schedule &  floatSchedule,
const QuantLib::ext::shared_ptr< IborIndex > &  iborIndex,
std::vector< Rate >  floatSpreads,
boost::optional< BusinessDayConvention >  paymentConvention = boost::none,
const bool  isPhysicallySettled = true,
const bool  isResettable = false 
)

Definition at line 262 of file currencyswap.cpp.

269 : CurrencySwap(4) {
270
271 isPhysicallySettled_ = isPhysicallySettled;
272 isResettable_ = isResettable;
273
274 BusinessDayConvention convention;
275 if (paymentConvention)
276 convention = *paymentConvention;
277 else
278 convention = floatSchedule.businessDayConvention();
279
280 // fixed leg
281 currency_[0] = fixedCcy;
282 payer_[0] = (payFixed ? -1 : +1);
283 legs_[0] = FixedRateLeg(fixedSchedule)
284 .withNotionals(fixedNominals)
285 .withCouponRates(fixedRates, fixedDayCount)
286 .withPaymentAdjustment(convention);
287
288 // add initial, interim and final notional flows
289 currency_[1] = fixedCcy;
290 payer_[1] = payer_[0];
291 legs_[1].push_back(
292 QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(-fixedNominals[0], fixedSchedule.dates().front())));
293 QL_REQUIRE(fixedNominals.size() < fixedSchedule.size(), "too many fixed nominals provided");
294 for (Size i = 1; i < fixedNominals.size(); i++) {
295 Real flow = fixedNominals[i - 1] - fixedNominals[i];
296 legs_[1].push_back(QuantLib::ext::shared_ptr<CashFlow>(
297 new SimpleCashFlow(flow, fixedSchedule.calendar().adjust(fixedSchedule[i], convention))));
298 }
299 if (fixedNominals.back() > 0)
300 legs_[1].push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(
301 fixedNominals.back(), fixedSchedule.calendar().adjust(fixedSchedule.dates().back(), convention))));
302
303 // floating leg
304 currency_[2] = floatCcy;
305 payer_[2] = (payFixed ? +1 : -1);
306 legs_[2] = IborLeg(floatSchedule, iborIndex)
307 .withNotionals(floatNominals)
308 .withPaymentDayCounter(iborIndex->dayCounter())
309 .withPaymentAdjustment(convention)
310 .withSpreads(floatSpreads);
311 for (Leg::const_iterator i = legs_[2].begin(); i < legs_[2].end(); ++i)
312 registerWith(*i);
313
314 // add initial, interim and final notional flows
315 currency_[3] = floatCcy;
316 payer_[3] = payer_[2];
317 legs_[3].push_back(
318 QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(-floatNominals[0], floatSchedule.dates().front())));
319 QL_REQUIRE(floatNominals.size() < floatSchedule.size(), "too many float nominals provided");
320 for (Size i = 1; i < floatNominals.size(); i++) {
321 Real flow = floatNominals[i - 1] - floatNominals[i];
322 legs_[3].push_back(QuantLib::ext::shared_ptr<CashFlow>(
323 new SimpleCashFlow(flow, floatSchedule.calendar().adjust(floatSchedule[i], convention))));
324 }
325 if (floatNominals.back() > 0)
326 legs_[3].push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(
327 floatNominals.back(), floatSchedule.calendar().adjust(floatSchedule.dates().back(), convention))));
328}
std::vector< Currency > currency_
CurrencySwap(const std::vector< Leg > &legs, const std::vector< bool > &payer, const std::vector< Currency > &currency, const bool isPhysicallySettled=true, const bool isResettable=false)
std::vector< Leg > legs_
std::vector< Real > payer_

◆ CrossCurrencySwap() [2/3]

CrossCurrencySwap ( bool  pay1,
Currency  ccy1,
std::vector< Real >  nominals1,
const Schedule &  schedule1,
std::vector< Rate >  fixedRates1,
const DayCounter &  fixedDayCount1,
Currency  ccy2,
std::vector< Real >  nominals2,
const Schedule &  schedule2,
std::vector< Rate >  fixedRates2,
const DayCounter &  fixedDayCount2,
boost::optional< BusinessDayConvention >  paymentConvention = boost::none,
const bool  isPhysicallySettled = true,
const bool  isResettable = false 
)

◆ CrossCurrencySwap() [3/3]

CrossCurrencySwap ( bool  pay1,
Currency  ccy1,
std::vector< Real >  nominals1,
const Schedule &  schedule1,
const QuantLib::ext::shared_ptr< IborIndex > &  iborIndex1,
std::vector< Rate >  spreads1,
Currency  ccy2,
std::vector< Real >  nominals2,
const Schedule &  schedule2,
const QuantLib::ext::shared_ptr< IborIndex > &  iborIndex2,
std::vector< Rate >  spreads2,
boost::optional< BusinessDayConvention >  paymentConvention = boost::none,
const bool  isPhysicallySettled = true,
const bool  isResettable = false 
)

Definition at line 396 of file currencyswap.cpp.

402 : CurrencySwap(4) {
403
404 isPhysicallySettled_ = isPhysicallySettled;
405 isResettable_ = isResettable;
406
407 BusinessDayConvention convention;
408 if (paymentConvention)
409 convention = *paymentConvention;
410 else
411 convention = schedule1.businessDayConvention();
412
413 // floating leg 1
414 currency_[0] = ccy1;
415 payer_[0] = (pay1 ? -1 : +1);
416 legs_[0] = IborLeg(schedule1, iborIndex1)
417 .withNotionals(nominals1)
418 .withPaymentDayCounter(iborIndex1->dayCounter())
419 .withPaymentAdjustment(convention)
420 .withSpreads(spreads1);
421 for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i)
422 registerWith(*i);
423
424 // add initial, interim and final notional flows
425 currency_[1] = ccy1;
426 payer_[1] = payer_[0];
427 legs_[1].push_back(QuantLib::ext::shared_ptr<CashFlow>(
428 new SimpleCashFlow(-nominals1[0], schedule1.calendar().adjust(schedule1.dates().front(), convention))));
429 QL_REQUIRE(nominals1.size() < schedule1.size(), "too many float nominals provided");
430 for (Size i = 1; i < nominals1.size(); i++) {
431 Real flow = nominals1[i - 1] - nominals1[i];
432 legs_[1].push_back(QuantLib::ext::shared_ptr<CashFlow>(
433 new SimpleCashFlow(flow, schedule1.calendar().adjust(schedule1[i], convention))));
434 }
435 if (nominals1.back() > 0)
436 legs_[1].push_back(QuantLib::ext::shared_ptr<CashFlow>(
437 new SimpleCashFlow(nominals1.back(), schedule1.calendar().adjust(schedule1.dates().back(), convention))));
438
439 // floating leg 2
440 currency_[2] = ccy2;
441 payer_[2] = (pay1 ? +1 : -1);
442 legs_[2] = IborLeg(schedule2, iborIndex2)
443 .withNotionals(nominals2)
444 .withPaymentDayCounter(iborIndex2->dayCounter())
445 .withPaymentAdjustment(convention)
446 .withSpreads(spreads2);
447 for (Leg::const_iterator i = legs_[2].begin(); i < legs_[2].end(); ++i)
448 registerWith(*i);
449
450 // add initial, interim and final notional flows
451 currency_[3] = ccy2;
452 payer_[3] = payer_[2];
453 legs_[3].push_back(QuantLib::ext::shared_ptr<CashFlow>(
454 new SimpleCashFlow(-nominals2[0], schedule2.calendar().adjust(schedule2.dates().front(), convention))));
455 QL_REQUIRE(nominals2.size() < schedule2.size(), "too many float nominals provided");
456 for (Size i = 1; i < nominals2.size(); i++) {
457 Real flow = nominals2[i - 1] - nominals2[i];
458 legs_[3].push_back(QuantLib::ext::shared_ptr<CashFlow>(
459 new SimpleCashFlow(flow, schedule2.calendar().adjust(schedule2[i], convention))));
460 }
461 if (nominals2.back() > 0)
462 legs_[3].push_back(QuantLib::ext::shared_ptr<CashFlow>(
463 new SimpleCashFlow(nominals2.back(), schedule2.calendar().adjust(schedule2.dates().back(), convention))));
464}