248 {
249
250 BOOST_TEST_MESSAGE("Test cross currency fix float swap pricing against known results");
251
252 SavedSettings backup;
253
254 Settings::instance().evaluationDate() = Date(11, Sep, 2018);
255
256
257 Rate spotFx = 6.4304;
258 Rate rate = 0.249;
259 Spread spread = 0.0;
260 QuantLib::ext::shared_ptr<CrossCcyFixFloatSwap> swap = makeTestSwap(spotFx, rate, spread);
261
262
263 Handle<Quote> fxSpotQuote = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0 / spotFx));
264 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<CrossCcySwapEngine>(
265 USDCurrency(), usdDiscountCurve(), TRYCurrency(), tryDiscountCurve(), fxSpotQuote);
266 swap->setPricingEngine(engine);
267
268
269 Real usdTolerance = 0.01;
270
271 Real expNpv = 129777.91;
272 BOOST_CHECK_SMALL(swap->NPV() - expNpv, usdTolerance);
273
274 Real expPayLegNpv = -12286.45;
275 Real expPayLegBps = -2628.39;
276 BOOST_CHECK_SMALL(swap->legNPV(0) - expPayLegNpv, usdTolerance);
277 BOOST_CHECK_SMALL(swap->legBPS(0) - expPayLegBps, usdTolerance);
278 BOOST_CHECK_SMALL(swap->inCcyLegNPV(0) - expPayLegNpv * spotFx, usdTolerance * spotFx);
279 BOOST_CHECK_SMALL(swap->inCcyLegBPS(0) - expPayLegBps * spotFx, usdTolerance * spotFx);
280
281 Real expRecLegNpv = 142064.36;
282 Real expRecLegBps = 4735.03;
283 BOOST_CHECK_SMALL(swap->legNPV(1) - expRecLegNpv, usdTolerance);
284 BOOST_CHECK_SMALL(swap->legBPS(1) - expRecLegBps, usdTolerance);
285 BOOST_CHECK_SMALL(swap->inCcyLegNPV(1) - expRecLegNpv, usdTolerance);
286 BOOST_CHECK_SMALL(swap->inCcyLegBPS(1) - expRecLegBps, usdTolerance);
287
288 BOOST_CHECK_SMALL(0.253937551076 - swap->fairFixedRate(), 1e-10);
289 BOOST_CHECK_SMALL(-0.002740802104 - swap->fairSpread(), 1e-10);
290}