Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
oiccbasisswap.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <ql/cashflows/overnightindexedcoupon.hpp>
20#include <ql/cashflows/simplecashflow.hpp>
22
23namespace QuantExt {
24
26 Real payNominal, Currency payCurrency, const Schedule& paySchedule,
27 const QuantLib::ext::shared_ptr<OvernightIndex>& payIndex, Real paySpread, Real recNominal, Currency recCurrency,
28 const Schedule& recSchedule, const QuantLib::ext::shared_ptr<OvernightIndex>& recIndex, Real recSpread)
29 : Swap(2), payNominal_(payNominal), recNominal_(recNominal), payCurrency_(payCurrency), recCurrency_(recCurrency),
30 paySchedule_(paySchedule), recSchedule_(recSchedule), payIndex_(payIndex), recIndex_(recIndex),
31 paySpread_(paySpread), recSpread_(recSpread), currency_(2) {
32
33 registerWith(payIndex);
34 registerWith(recIndex);
35 initialize();
36}
37
40 legs_[0].insert(legs_[0].begin(),
41 QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(-payNominal_, paySchedule_.dates().front())));
42 legs_[0].push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(payNominal_, paySchedule_.dates().back())));
43
45 legs_[1].insert(legs_[1].begin(),
46 QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(-recNominal_, recSchedule_.dates().front())));
47 legs_[1].push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(recNominal_, recSchedule_.dates().back())));
48
49 for (Size j = 0; j < 2; ++j) {
50 for (Leg::iterator i = legs_[j].begin(); i != legs_[j].end(); ++i)
51 registerWith(*i);
52 }
53
54 payer_[0] = -1.0;
55 payer_[1] = +1.0;
56
59}
60
62 calculate();
63 QL_REQUIRE(fairPayLegSpread_ != Null<Real>(), "result not available");
64 return fairPayLegSpread_;
65}
66
68 calculate();
69 QL_REQUIRE(fairRecLegSpread_ != Null<Real>(), "result not available");
70 return fairRecLegSpread_;
71}
72
74 calculate();
75 QL_REQUIRE(legBPS_[0] != Null<Real>(), "result not available");
76 return legBPS_[0];
77}
78
80 calculate();
81 QL_REQUIRE(legBPS_[1] != Null<Real>(), "result not available");
82 return legBPS_[1];
83}
84
86 calculate();
87 QL_REQUIRE(legNPV_[0] != Null<Real>(), "result not available");
88 return legNPV_[0];
89}
90
92 calculate();
93 QL_REQUIRE(legNPV_[1] != Null<Real>(), "result not available");
94 return legNPV_[1];
95}
96
97void OvernightIndexedCrossCcyBasisSwap::setupArguments(PricingEngine::arguments* args) const {
98 Swap::setupArguments(args);
99
102 QL_REQUIRE(arguments != 0, "wrong argument type");
103
107}
108
109void OvernightIndexedCrossCcyBasisSwap::fetchResults(const PricingEngine::results* r) const {
110 Swap::fetchResults(r);
111
113 dynamic_cast<const OvernightIndexedCrossCcyBasisSwap::results*>(r);
114 QL_REQUIRE(results != 0, "wrong result type");
115
118}
119
121 Swap::results::reset();
122 fairPayLegSpread = Null<Real>();
123 fairRecLegSpread = Null<Real>();
124}
125} // namespace QuantExt
QuantLib::ext::shared_ptr< OvernightIndex > recIndex_
OvernightIndexedCrossCcyBasisSwap(Real payNominal, Currency payCurrency, const Schedule &paySchedule, const QuantLib::ext::shared_ptr< OvernightIndex > &payIndex, Real paySpread, Real recNominal, Currency recCurrency, const Schedule &recSchedule, const QuantLib::ext::shared_ptr< OvernightIndex > &recIndex, Real recSpread)
const QuantLib::ext::shared_ptr< OvernightIndex > & payIndex()
void setupArguments(PricingEngine::arguments *args) const override
QuantLib::ext::shared_ptr< OvernightIndex > payIndex_
void fetchResults(const PricingEngine::results *) const override
const QuantLib::ext::shared_ptr< OvernightIndex > & recIndex()
helper class building a sequence of overnight coupons
OvernightLeg & withNotionals(Real notional)
OvernightLeg & withSpreads(Spread spread)
Cross currency overnight index swap paying compounded overnight vs. float.