Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
crossccybasismtmresetswap.cpp File Reference
#include "toplevelfixture.hpp"
#include <boost/make_shared.hpp>
#include <boost/test/unit_test.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/cashflows/floatingratecoupon.hpp>
#include <ql/currencies/all.hpp>
#include <ql/indexes/ibor/gbplibor.hpp>
#include <ql/indexes/ibor/usdlibor.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/termstructures/yield/discountcurve.hpp>
#include <ql/time/calendars/all.hpp>
#include <ql/time/daycounters/actual360.hpp>
#include <ql/types.hpp>
#include <qle/instruments/crossccybasismtmresetswap.hpp>
#include <qle/pricingengines/crossccyswapengine.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testSwapPricing)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( testSwapPricing  )

Definition at line 321 of file crossccybasismtmresetswap.cpp.

321 {
322
323 BOOST_TEST_MESSAGE("Test cross currency MtM resetting swap pricing against known results");
324
325 SavedSettings backup;
326 Settings::instance().evaluationDate() = Date(11, Sep, 2018);
327
328 // Create swap
329 Rate spotFx = 1;
330 Spread spread = 0;
331 QuantLib::ext::shared_ptr<CrossCcyBasisMtMResetSwap> swap = makeTestSwap(spotFx, spread);
332
333 // Attach pricing engine
334 Handle<Quote> fxSpotQuote = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(spotFx));
335 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<CrossCcySwapEngine>(
336 USDCurrency(), USDDiscountCurve(), GBPCurrency(), GBPDiscountCurve(), fxSpotQuote);
337
338 swap->setPricingEngine(engine);
339
340 // Check values
341 Real tol = 0.01;
342
343 BOOST_CHECK_SMALL(swap->NPV(), tol);
344
345 Real expBps = -4670.170509677384; // cached value
346 BOOST_CHECK_SMALL(swap->legBPS(0) - expBps, tol);
347}