336 {
337
338 BOOST_TEST_MESSAGE("Testing market datum parsing...");
339
340 BOOST_TEST_MESSAGE("Testing cap/floor market datum parsing...");
341
342 {
343 Date d(1, Jan, 1990);
345
346 string input = "CAPFLOOR/RATE_NVOL/USD/5Y/3M/0/0/0";
347
349
350 BOOST_CHECK(datum->asofDate() == d);
351 BOOST_CHECK(datum->quote()->value() ==
value);
354
355 QuantLib::ext::shared_ptr<ore::data::CapFloorQuote> capfloorVolDatum =
356 QuantLib::ext::dynamic_pointer_cast<ore::data::CapFloorQuote>(datum);
357
358 BOOST_CHECK(capfloorVolDatum->ccy() == "USD");
359 BOOST_CHECK(capfloorVolDatum->term() == Period(5, Years));
360 BOOST_CHECK(capfloorVolDatum->underlying() == Period(3, Months));
361 BOOST_CHECK(capfloorVolDatum->atm() == false);
362 BOOST_CHECK(capfloorVolDatum->relative() == false);
363 BOOST_CHECK_CLOSE(capfloorVolDatum->strike(), 0.0, 1e-12);
364 }
365
366 {
367 Date d(1, Jan, 1990);
369
370 string input = "CAPFLOOR/RATE_SLNVOL/JPY/EYTIBOR/5Y/3M/1/1/0.0075";
371
373
374 BOOST_CHECK(datum->asofDate() == d);
375 BOOST_CHECK(datum->quote()->value() ==
value);
378
379 QuantLib::ext::shared_ptr<ore::data::CapFloorQuote> capfloorVolDatum =
380 QuantLib::ext::dynamic_pointer_cast<ore::data::CapFloorQuote>(datum);
381
382 BOOST_CHECK(capfloorVolDatum->ccy() == "JPY");
383 BOOST_CHECK(capfloorVolDatum->indexName() == "EYTIBOR");
384 BOOST_CHECK(capfloorVolDatum->term() == Period(5, Years));
385 BOOST_CHECK(capfloorVolDatum->underlying() == Period(3, Months));
386 BOOST_CHECK(capfloorVolDatum->atm() == true);
387 BOOST_CHECK(capfloorVolDatum->relative() == true);
388 BOOST_CHECK_CLOSE(capfloorVolDatum->strike(), 0.0075, 1e-12);
389 }
390
391 {
392 Date d(1, Jan, 1990);
394
395 string input = "CAPFLOOR/SHIFT/USD/5Y";
396
398
399 BOOST_CHECK(datum->asofDate() == d);
400 BOOST_CHECK(datum->quote()->value() ==
value);
403
404 QuantLib::ext::shared_ptr<ore::data::CapFloorShiftQuote> capfloorShiftDatum =
405 QuantLib::ext::dynamic_pointer_cast<ore::data::CapFloorShiftQuote>(datum);
406
407 BOOST_CHECK(capfloorShiftDatum->ccy() == "USD");
408 BOOST_CHECK(capfloorShiftDatum->indexTenor() == Period(5, Years));
409 }
410
411 {
412 Date d(1, Jan, 1990);
414
415 string input = "CAPFLOOR/SHIFT/JPY/EYTIBOR/5Y";
416
418
419 BOOST_CHECK(datum->asofDate() == d);
420 BOOST_CHECK(datum->quote()->value() ==
value);
423
424 QuantLib::ext::shared_ptr<ore::data::CapFloorShiftQuote> capfloorShiftDatum =
425 QuantLib::ext::dynamic_pointer_cast<ore::data::CapFloorShiftQuote>(datum);
426
427 BOOST_CHECK(capfloorShiftDatum->ccy() == "JPY");
428 BOOST_CHECK(capfloorShiftDatum->indexName() == "EYTIBOR");
429 BOOST_CHECK(capfloorShiftDatum->indexTenor() == Period(5, Years));
430 }
431
432 {
433 Date d(1, Jan, 1990);
435
436 string input = "CAPFLOOR/PRICE/USD/5Y/3M/0/0/0/C";
437
439
440 BOOST_CHECK(datum->asofDate() == d);
441 BOOST_CHECK(datum->quote()->value() ==
value);
444
445 QuantLib::ext::shared_ptr<ore::data::CapFloorQuote> capfloorPremiumDatum =
446 QuantLib::ext::dynamic_pointer_cast<ore::data::CapFloorQuote>(datum);
447
448 BOOST_CHECK(capfloorPremiumDatum->ccy() == "USD");
449 BOOST_CHECK(capfloorPremiumDatum->term() == Period(5, Years));
450 BOOST_CHECK(capfloorPremiumDatum->underlying() == Period(3, Months));
451 BOOST_CHECK(capfloorPremiumDatum->atm() == false);
452 BOOST_CHECK(capfloorPremiumDatum->relative() == false);
453 BOOST_CHECK_CLOSE(capfloorPremiumDatum->strike(), 0.0, 1e-12);
454 BOOST_CHECK(capfloorPremiumDatum->isCap() == true);
455 }
456
457 {
458 Date d(1, Jan, 1990);
460
461 string input = "CAPFLOOR/PRICE/JPY/EYTIBOR/5Y/3M/1/1/-0.0075/F";
462
464
465 BOOST_CHECK(datum->asofDate() == d);
466 BOOST_CHECK(datum->quote()->value() ==
value);
469
470 QuantLib::ext::shared_ptr<ore::data::CapFloorQuote> capfloorVolDatum =
471 QuantLib::ext::dynamic_pointer_cast<ore::data::CapFloorQuote>(datum);
472
473 BOOST_CHECK(capfloorVolDatum->ccy() == "JPY");
474 BOOST_CHECK(capfloorVolDatum->indexName() == "EYTIBOR");
475 BOOST_CHECK(capfloorVolDatum->term() == Period(5, Years));
476 BOOST_CHECK(capfloorVolDatum->underlying() == Period(3, Months));
477 BOOST_CHECK(capfloorVolDatum->atm() == true);
478 BOOST_CHECK(capfloorVolDatum->relative() == true);
479 BOOST_CHECK_CLOSE(capfloorVolDatum->strike(), -0.0075, 1e-12);
480 BOOST_CHECK(capfloorVolDatum->isCap() == false);
481 }
482
483 {
484 Date d(3, Mar, 2018);
486
487 BOOST_CHECK_THROW(
489 QuantLib::Error);
490 BOOST_CHECK_THROW(
492 QuantLib::Error);
494 QuantLib::Error);
495 BOOST_CHECK_THROW(
497 QuantLib::Error);
499 QuantLib::Error);
501 QuantLib::Error);
503 QuantLib::Error);
504 }
505
506 BOOST_TEST_MESSAGE("Testing swaption market datum parsing...");
507
508 {
509 Date d(1, Jan, 1990);
511
512 string input = "SWAPTION/RATE_NVOL/EUR/10Y/30Y/ATM";
513
515
518
519 QuantLib::ext::shared_ptr<ore::data::SwaptionQuote> swaptionVolDatum =
520 QuantLib::ext::dynamic_pointer_cast<ore::data::SwaptionQuote>(datum);
521
522 BOOST_CHECK(swaptionVolDatum->ccy() == "EUR");
523 BOOST_CHECK(swaptionVolDatum->expiry() == Period(10, Years));
524 BOOST_CHECK(swaptionVolDatum->term() == Period(30, Years));
525 BOOST_CHECK(swaptionVolDatum->dimension() == "ATM");
526 BOOST_CHECK_CLOSE(swaptionVolDatum->strike(), 0.0, 1e-12);
527 BOOST_CHECK(swaptionVolDatum->quoteTag() == "");
528 }
529
530 {
531 Date d(1, Jan, 1990);
533
534 string input = "SWAPTION/RATE_NVOL/EUR/EURIBOR/10Y/30Y/Smile/-0.0025";
535
537
540
541 QuantLib::ext::shared_ptr<ore::data::SwaptionQuote> swaptionVolDatum =
542 QuantLib::ext::dynamic_pointer_cast<ore::data::SwaptionQuote>(datum);
543
544 BOOST_CHECK(swaptionVolDatum->ccy() == "EUR");
545 BOOST_CHECK(swaptionVolDatum->expiry() == Period(10, Years));
546 BOOST_CHECK(swaptionVolDatum->term() == Period(30, Years));
547 BOOST_CHECK(swaptionVolDatum->dimension() == "Smile");
548 BOOST_CHECK_CLOSE(swaptionVolDatum->strike(), -0.0025, 1e-12);
549 BOOST_CHECK(swaptionVolDatum->quoteTag() == "EURIBOR");
550 }
551
552 {
553 Date d(1, Jan, 1990);
555
556 string input = "SWAPTION/RATE_SLNVOL/EUR/EURIBOR/10Y/30Y/Smile/-0.0025";
557
559
560 BOOST_CHECK(datum->asofDate() == d);
561 BOOST_CHECK(datum->quote()->value() ==
value);
564
565 QuantLib::ext::shared_ptr<ore::data::SwaptionQuote> swaptionVolDatum =
566 QuantLib::ext::dynamic_pointer_cast<ore::data::SwaptionQuote>(datum);
567
568 BOOST_CHECK(swaptionVolDatum->ccy() == "EUR");
569 BOOST_CHECK(swaptionVolDatum->expiry() == Period(10, Years));
570 BOOST_CHECK(swaptionVolDatum->term() == Period(30, Years));
571 BOOST_CHECK(swaptionVolDatum->dimension() == "Smile");
572 BOOST_CHECK_CLOSE(swaptionVolDatum->strike(), -0.0025, 1e-12);
573 BOOST_CHECK(swaptionVolDatum->quoteTag() == "EURIBOR");
574 }
575
576 {
577 Date d(1, Jan, 1990);
579
580 string input = "SWAPTION/SHIFT/EUR/EURIBOR/30Y";
581
583
586
587 QuantLib::ext::shared_ptr<ore::data::SwaptionShiftQuote> swaptionShiftDatum =
588 QuantLib::ext::dynamic_pointer_cast<ore::data::SwaptionShiftQuote>(datum);
589
590 BOOST_CHECK(swaptionShiftDatum->ccy() == "EUR");
591 BOOST_CHECK(swaptionShiftDatum->term() == Period(30, Years));
592 BOOST_CHECK(swaptionShiftDatum->quoteTag() == "EURIBOR");
593 }
594
595 {
596 Date d(1, Jan, 1990);
598
599 string input = "SWAPTION/PRICE/EUR/10Y/30Y/ATM/P";
600
602
605
606 QuantLib::ext::shared_ptr<ore::data::SwaptionQuote> swaptionPremiumDatum =
607 QuantLib::ext::dynamic_pointer_cast<ore::data::SwaptionQuote>(datum);
608
609 BOOST_CHECK(swaptionPremiumDatum->ccy() == "EUR");
610 BOOST_CHECK(swaptionPremiumDatum->expiry() == Period(10, Years));
611 BOOST_CHECK(swaptionPremiumDatum->term() == Period(30, Years));
612 BOOST_CHECK(swaptionPremiumDatum->dimension() == "ATM");
613 BOOST_CHECK_CLOSE(swaptionPremiumDatum->strike(), 0.0, 1e-12);
614 BOOST_CHECK(swaptionPremiumDatum->quoteTag() == "");
615 BOOST_CHECK(swaptionPremiumDatum->isPayer() == true);
616 }
617
618 {
619 Date d(1, Jan, 1990);
621
622 string input = "SWAPTION/PRICE/EUR/EURIBOR/10Y/30Y/Smile/-0.0025/R";
623
625
628
629 QuantLib::ext::shared_ptr<ore::data::SwaptionQuote> swaptionPremiumDatum =
630 QuantLib::ext::dynamic_pointer_cast<ore::data::SwaptionQuote>(datum);
631
632 BOOST_CHECK(swaptionPremiumDatum->ccy() == "EUR");
633 BOOST_CHECK(swaptionPremiumDatum->expiry() == Period(10, Years));
634 BOOST_CHECK(swaptionPremiumDatum->term() == Period(30, Years));
635 BOOST_CHECK(swaptionPremiumDatum->dimension() == "Smile");
636 BOOST_CHECK_CLOSE(swaptionPremiumDatum->strike(), -0.0025, 1e-12);
637 BOOST_CHECK(swaptionPremiumDatum->quoteTag() == "EURIBOR");
638 BOOST_CHECK(swaptionPremiumDatum->isPayer() == false);
640 QuantLib::Error);
641 BOOST_CHECK_THROW(
643 QuantLib::Error);
644 BOOST_CHECK_THROW(
646 QuantLib::Error);
647 BOOST_CHECK_THROW(
649 QuantLib::Error);
650 BOOST_CHECK_THROW(
652 QuantLib::Error);
653 BOOST_CHECK_THROW(
655 QuantLib::Error);
656 }
657
658 BOOST_TEST_MESSAGE("Testing correlation market datum parsing...");
659
660 {
661 Date d(1, Jan, 1990);
663
664 string input = "CORRELATION/RATE/INDEX1/INDEX2/1Y/ATM";
665
667
668 BOOST_CHECK(datum->asofDate() == d);
669 BOOST_CHECK(datum->quote()->value() ==
value);
672
673 QuantLib::ext::shared_ptr<ore::data::CorrelationQuote> spreadDatum =
674 QuantLib::ext::dynamic_pointer_cast<ore::data::CorrelationQuote>(datum);
675
676 BOOST_CHECK(spreadDatum->index1() == "INDEX1");
677 BOOST_CHECK(spreadDatum->index2() == "INDEX2");
678 BOOST_CHECK(spreadDatum->expiry() == "1Y");
679 BOOST_CHECK(spreadDatum->strike() == "ATM");
680 }
681
682 {
683 Date d(3, Mar, 2018);
685
686 string input = "CORRELATION/PRICE/INDEX1/INDEX2/1Y/0.1";
687
689
690 BOOST_CHECK(datum->asofDate() == d);
691 BOOST_CHECK(datum->quote()->value() ==
value);
694
695 QuantLib::ext::shared_ptr<ore::data::CorrelationQuote> spreadDatum =
696 QuantLib::ext::dynamic_pointer_cast<ore::data::CorrelationQuote>(datum);
697
698 BOOST_CHECK(spreadDatum->index1() == "INDEX1");
699 BOOST_CHECK(spreadDatum->index2() == "INDEX2");
700 BOOST_CHECK(spreadDatum->expiry() == "1Y");
701 BOOST_CHECK(spreadDatum->strike() == "0.1");
702 }
703
704 {
705 Date d(3, Mar, 2018);
707
709 QuantLib::Error);
711 QuantLib::Error);
712 }
713
714 BOOST_TEST_MESSAGE("Testing commodity spot market datum parsing...");
715
716
717 {
718 Date d(29, Jul, 2019);
720
721 string input = "COMMODITY/PRICE/PM:XAUUSD/USD";
722
724
725 BOOST_CHECK(datum->asofDate() == d);
726 BOOST_CHECK(datum->quote()->value() ==
value);
729
730 QuantLib::ext::shared_ptr<CommoditySpotQuote> q = QuantLib::ext::dynamic_pointer_cast<CommoditySpotQuote>(datum);
731
732 BOOST_CHECK(q->commodityName() == "PM:XAUUSD");
733 BOOST_CHECK(q->quoteCurrency() == "USD");
734 }
735
736
737 {
738 Date d(29, Jul, 2019);
740
744 }
745
746 BOOST_TEST_MESSAGE("Testing commodity forward market datum parsing...");
747
748
749 {
750 Date d(29, Jul, 2019);
751 Real
value = 300.16535;
752
753
754 string input = "COMMODITY_FWD/PRICE/PM:XAUUSD/USD/1M";
756
757 BOOST_CHECK(datum->asofDate() == d);
758 BOOST_CHECK(datum->quote()->value() ==
value);
761
762 QuantLib::ext::shared_ptr<CommodityForwardQuote> q = QuantLib::ext::dynamic_pointer_cast<CommodityForwardQuote>(datum);
763 BOOST_CHECK(q->commodityName() == "PM:XAUUSD");
764 BOOST_CHECK(q->quoteCurrency() == "USD");
765 BOOST_CHECK(q->tenorBased());
766 BOOST_CHECK(q->expiryDate() == Date());
767 BOOST_CHECK(q->tenor() == 1 * Months);
768 BOOST_CHECK(q->startTenor() == boost::none);
769
770
771 input = "COMMODITY_FWD/PRICE/PM:XAUUSD/USD/2019-08-30";
773 q = QuantLib::ext::dynamic_pointer_cast<CommodityForwardQuote>(datum);
774 BOOST_CHECK(q->commodityName() == "PM:XAUUSD");
775 BOOST_CHECK(q->quoteCurrency() == "USD");
776 BOOST_CHECK(!q->tenorBased());
777 BOOST_CHECK(q->expiryDate() == Date(30, Aug, 2019));
778 BOOST_CHECK(q->tenor() == Period());
779 BOOST_CHECK(q->startTenor() == boost::none);
780
781
782
783
784 input = "COMMODITY_FWD/PRICE/PM:XAUUSD/USD/ON";
786 q = QuantLib::ext::dynamic_pointer_cast<CommodityForwardQuote>(datum);
787 BOOST_CHECK(q->tenorBased());
788 BOOST_CHECK(q->expiryDate() == Date());
789 BOOST_CHECK(q->tenor() == 1 * Days);
790 BOOST_CHECK(q->startTenor() == 0 * Days);
791
792
793 input = "COMMODITY_FWD/PRICE/PM:XAUUSD/USD/TN";
795 q = QuantLib::ext::dynamic_pointer_cast<CommodityForwardQuote>(datum);
796 BOOST_CHECK(q->tenorBased());
797 BOOST_CHECK(q->expiryDate() == Date());
798 BOOST_CHECK(q->tenor() == 1 * Days);
799 BOOST_CHECK(q->startTenor() == 1 * Days);
800
801
802 input = "COMMODITY_FWD/PRICE/PM:XAUUSD/USD/SN";
804 q = QuantLib::ext::dynamic_pointer_cast<CommodityForwardQuote>(datum);
805 BOOST_CHECK(q->tenorBased());
806 BOOST_CHECK(q->expiryDate() == Date());
807 BOOST_CHECK(q->tenor() == 1 * Days);
808 BOOST_CHECK(q->startTenor() == boost::none);
809 }
810
811
812 {
813 Date d(29, Jul, 2019);
814 Real
value = 300.16535;
815
820 }
821
822 BOOST_TEST_MESSAGE("Testing fx option market datum parsing...");
823
824
825 {
826 Date d(29, Jul, 2019);
828
829
830 string input = "FX_OPTION/RATE_LNVOL/EUR/USD/1M/ATM";
832
833 BOOST_CHECK(datum->asofDate() == d);
834 BOOST_CHECK(datum->quote()->value() ==
value);
837
838 QuantLib::ext::shared_ptr<FXOptionQuote> q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
839 BOOST_CHECK(q->unitCcy() == "EUR");
840 BOOST_CHECK(q->ccy() == "USD");
841 BOOST_CHECK(q->expiry() == Period(1, Months));
842 BOOST_CHECK(q->strike() == "ATM");
843
844
845 input = "FX_OPTION/RATE_LNVOL/EUR/USD/2M/25BF";
847 q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
848 BOOST_CHECK(q->unitCcy() == "EUR");
849 BOOST_CHECK(q->ccy() == "USD");
850 BOOST_CHECK(q->expiry() == Period(2, Months));
851 BOOST_CHECK(q->strike() == "25BF");
852
853 input = "FX_OPTION/RATE_LNVOL/EUR/USD/2M/10BF";
855 q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
856 BOOST_CHECK(q->unitCcy() == "EUR");
857 BOOST_CHECK(q->ccy() == "USD");
858 BOOST_CHECK(q->expiry() == Period(2, Months));
859 BOOST_CHECK(q->strike() == "10BF");
860
861
862 input = "FX_OPTION/RATE_LNVOL/EUR/USD/2M/25RR";
864 q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
865 BOOST_CHECK(q->unitCcy() == "EUR");
866 BOOST_CHECK(q->ccy() == "USD");
867 BOOST_CHECK(q->expiry() == Period(2, Months));
868 BOOST_CHECK(q->strike() == "25RR");
869
870 input = "FX_OPTION/RATE_LNVOL/EUR/USD/2M/10RR";
872 q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
873 BOOST_CHECK(q->unitCcy() == "EUR");
874 BOOST_CHECK(q->ccy() == "USD");
875 BOOST_CHECK(q->expiry() == Period(2, Months));
876 BOOST_CHECK(q->strike() == "10RR");
877
878
879 input = "FX_OPTION/RATE_LNVOL/EUR/USD/2M/10C";
881 q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
882 BOOST_CHECK(q->unitCcy() == "EUR");
883 BOOST_CHECK(q->ccy() == "USD");
884 BOOST_CHECK(q->expiry() == Period(2, Months));
885 BOOST_CHECK(q->strike() == "10C");
886
887 input = "FX_OPTION/RATE_LNVOL/EUR/USD/2M/20P";
889 q = QuantLib::ext::dynamic_pointer_cast<FXOptionQuote>(datum);
890 BOOST_CHECK(q->unitCcy() == "EUR");
891 BOOST_CHECK(q->ccy() == "USD");
892 BOOST_CHECK(q->expiry() == Period(2, Months));
893 BOOST_CHECK(q->strike() == "20P");
894
895
896 {
897 Date d(29, Jul, 2019);
898 Real
value = 300.16535;
899
906 }
907 }
908}
SafeStack< ValueType > value
QuantLib::ext::shared_ptr< MarketDatum > parseMarketDatum(const Date &asof, const string &datumName, const Real &value)
Function to parse a market datum.