Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | List of all members
CrossCcySwap Class Reference

Cross currency swap. More...

#include <qle/instruments/crossccyswap.hpp>

+ Inheritance diagram for CrossCcySwap:
+ Collaboration diagram for CrossCcySwap:

Classes

class  arguments
 
class  engine
 
class  results
 

Public Member Functions

Additional interface
const Currency & legCurrency (Size j) const
 
Real inCcyLegBPS (Size j) const
 
Real inCcyLegNPV (Size j) const
 
DiscountFactor npvDateDiscounts (Size j) const
 

Instrument interface

std::vector< Currency > currencies_
 
std::vector< Real > inCcyLegNPV_
 
std::vector< Real > inCcyLegBPS_
 
std::vector< DiscountFactor > npvDateDiscounts_
 
void setupArguments (PricingEngine::arguments *args) const override
 
void fetchResults (const PricingEngine::results *) const override
 
void setupExpired () const override
 

Constructors

 CrossCcySwap (const Leg &firstLeg, const Currency &firstLegCcy, const Leg &secondLeg, const Currency &secondLegCcy)
 First leg is paid and the second is received. More...
 
 CrossCcySwap (const std::vector< Leg > &legs, const std::vector< bool > &payer, const std::vector< Currency > &currencies)
 
 CrossCcySwap (Size legs)
 

Detailed Description

Cross currency swap.

The first leg holds the pay currency cashflows and second leg holds the receive currency cashflows.

    \ingroup instruments

Definition at line 40 of file crossccyswap.hpp.

Constructor & Destructor Documentation

◆ CrossCcySwap() [1/3]

CrossCcySwap ( const Leg &  firstLeg,
const Currency &  firstLegCcy,
const Leg &  secondLeg,
const Currency &  secondLegCcy 
)

First leg is paid and the second is received.

Definition at line 23 of file crossccyswap.cpp.

25 : Swap(firstLeg, secondLeg) {
26 currencies_.resize(2);
27 currencies_[0] = firstLegCcy;
28 currencies_[1] = secondLegCcy;
29}
std::vector< Currency > currencies_

◆ CrossCcySwap() [2/3]

CrossCcySwap ( const std::vector< Leg > &  legs,
const std::vector< bool > &  payer,
const std::vector< Currency > &  currencies 
)

Multi leg constructor.

Definition at line 31 of file crossccyswap.cpp.

33 : Swap(legs, payer), currencies_(currencies) {
34 QL_REQUIRE(payer.size() == currencies_.size(), "Size mismatch "
35 "between payer ("
36 << payer.size() << ") and currencies (" << currencies_.size()
37 << ")");
38}

◆ CrossCcySwap() [3/3]

CrossCcySwap ( Size  legs)
protected

This constructor can be used by derived classes that will build their legs themselves.

Definition at line 40 of file crossccyswap.cpp.

41 : Swap(legs), currencies_(legs), inCcyLegNPV_(legs, 0.0), inCcyLegBPS_(legs, 0.0), npvDateDiscounts_(legs, 0.0) {}
std::vector< Real > inCcyLegNPV_
std::vector< DiscountFactor > npvDateDiscounts_
std::vector< Real > inCcyLegBPS_

Member Function Documentation

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 43 of file crossccyswap.cpp.

43 {
44
45 Swap::setupArguments(args);
46
47 CrossCcySwap::arguments* arguments = dynamic_cast<CrossCcySwap::arguments*>(args);
48 QL_REQUIRE(arguments, "The arguments are not of type "
49 "cross currency swap");
50
51 arguments->currencies = currencies_;
52}
+ Here is the caller graph for this function:

◆ fetchResults()

void fetchResults ( const PricingEngine::results *  r) const
override

Definition at line 54 of file crossccyswap.cpp.

54 {
55
56 Swap::fetchResults(r);
57
58 const CrossCcySwap::results* results = dynamic_cast<const CrossCcySwap::results*>(r);
59 QL_REQUIRE(results, "The results are not of type "
60 "cross currency swap");
61
62 if (!results->inCcyLegNPV.empty()) {
63 QL_REQUIRE(results->inCcyLegNPV.size() == inCcyLegNPV_.size(),
64 "Wrong number of in currency leg NPVs returned by engine");
65 inCcyLegNPV_ = results->inCcyLegNPV;
66 } else {
67 std::fill(inCcyLegNPV_.begin(), inCcyLegNPV_.end(), Null<Real>());
68 }
69
70 if (!results->inCcyLegBPS.empty()) {
71 QL_REQUIRE(results->inCcyLegBPS.size() == inCcyLegBPS_.size(),
72 "Wrong number of in currency leg BPSs returned by engine");
73 inCcyLegBPS_ = results->inCcyLegBPS;
74 } else {
75 std::fill(inCcyLegBPS_.begin(), inCcyLegBPS_.end(), Null<Real>());
76 }
77
78 if (!results->npvDateDiscounts.empty()) {
79 QL_REQUIRE(results->npvDateDiscounts.size() == npvDateDiscounts_.size(),
80 "Wrong number of npv date discounts returned by engine");
81 npvDateDiscounts_ = results->npvDateDiscounts;
82 } else {
83 std::fill(npvDateDiscounts_.begin(), npvDateDiscounts_.end(), Null<DiscountFactor>());
84 }
85}
+ Here is the caller graph for this function:

◆ legCurrency()

const Currency & legCurrency ( Size  j) const

Definition at line 59 of file crossccyswap.hpp.

59 {
60 QL_REQUIRE(j < legs_.size(), "leg# " << j << " doesn't exist!");
61 return currencies_[j];
62 }

◆ inCcyLegBPS()

Real inCcyLegBPS ( Size  j) const

Definition at line 63 of file crossccyswap.hpp.

63 {
64 QL_REQUIRE(j < legs_.size(), "leg# " << j << " doesn't exist!");
65 calculate();
66 return inCcyLegBPS_[j];
67 }
+ Here is the caller graph for this function:

◆ inCcyLegNPV()

Real inCcyLegNPV ( Size  j) const

Definition at line 68 of file crossccyswap.hpp.

68 {
69 QL_REQUIRE(j < legs_.size(), "leg #" << j << " doesn't exist!");
70 calculate();
71 return inCcyLegNPV_[j];
72 }
+ Here is the caller graph for this function:

◆ npvDateDiscounts()

DiscountFactor npvDateDiscounts ( Size  j) const

Definition at line 73 of file crossccyswap.hpp.

73 {
74 QL_REQUIRE(j < legs_.size(), "leg #" << j << " doesn't exist!");
75 calculate();
76 return npvDateDiscounts_[j];
77 }
+ Here is the caller graph for this function:

◆ setupExpired()

void setupExpired ( ) const
overrideprotected

Definition at line 87 of file crossccyswap.cpp.

87 {
88 Swap::setupExpired();
89 std::fill(inCcyLegBPS_.begin(), inCcyLegBPS_.end(), 0.0);
90 std::fill(inCcyLegNPV_.begin(), inCcyLegNPV_.end(), 0.0);
91 std::fill(npvDateDiscounts_.begin(), npvDateDiscounts_.end(), 0.0);
92}
+ Here is the caller graph for this function:

Member Data Documentation

◆ currencies_

std::vector<Currency> currencies_
protected

Definition at line 92 of file crossccyswap.hpp.

◆ inCcyLegNPV_

std::vector<Real> inCcyLegNPV_
mutableprivate

Definition at line 95 of file crossccyswap.hpp.

◆ inCcyLegBPS_

std::vector<Real> inCcyLegBPS_
mutableprivate

Definition at line 96 of file crossccyswap.hpp.

◆ npvDateDiscounts_

std::vector<DiscountFactor> npvDateDiscounts_
mutableprivate

Definition at line 97 of file crossccyswap.hpp.