99 under the terms of the Modified BSD License. You should have received a
1010 copy of the license along with this program.
1111 The license is also available online at <http://opensourcerisk.org>
12-
12+
1313 This program is distributed on the basis that it will form a useful
1414 contribution to risk analytics and model standardisation, but WITHOUT
1515 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1616 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
1717 */
1818
19- #include < ored/portfolio/builder /fxeuropeanbarrieroption.hpp>
19+ #include < ored/portfolio/builders /fxeuropeanbarrieroption.hpp>
2020#include < ored/portfolio/fxeuropeanbarrieroption.hpp>
2121#include < ored/portfolio/genericbarrieroption.hpp>
2222#include < ored/portfolio/underlying.hpp>
@@ -25,26 +25,27 @@ namespace ore {
2525namespace data {
2626
2727QuantLib::ext::shared_ptr<ore::data::Trade>
28- FxEuropeanBarrierOptionEngineBuilder::build (const Trade* trade, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) {
28+ FxEuropeanBarrierOptionEngineBuilder::build (const Trade* trade,
29+ const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) {
2930
3031 auto fxEuropeanBarrierOption = dynamic_cast <const ore::data::FxEuropeanBarrierOption*>(trade);
3132
32- QL_REQUIRE (
33- fxEuropeanBarrierOption != nullptr ,
34- " FxEuropeanBarrierOptionEngineBuilder: internal error, could not cast to ore::data::FxEuropeanBarrierOption. Contact dev." );
33+ QL_REQUIRE (fxEuropeanBarrierOption != nullptr , " FxEuropeanBarrierOptionEngineBuilder: internal error, could not "
34+ " cast to ore::data::FxEuropeanBarrierOption. Contact dev." );
35+
36+ QuantLib::ext::shared_ptr<Underlying> underlying =
37+ QuantLib::ext::make_shared<FXUnderlying>(" FX" , fxEuropeanBarrierOption->fxIndex (), 1.0 );
3538
36- auto underlying = Quantib::ext::make_shared<FXUnderlying>(" FX" , fxEuropeanBarrierOption->fxIndex (), 1.0 );
37-
38- auto optionData = fxEuropeanBarrierOption->optionData ();
39+ const auto & optionData = fxEuropeanBarrierOption->option ();
3940
40- std::string exerciseDate = optionData-> exerciseDates ().begin ();
41- ScheduleDates monitoringDates (" NullCalendar" , " " , " 0D" , {exerciseDate} );
41+ std::string exerciseDate = optionData. exerciseDates ().front ();
42+ ScheduleDates monitoringDates (" NullCalendar" , " " , " 0D" , {exerciseDate});
4243 ScheduleData barrierMonitoringDates (monitoringDates);
4344
4445 // ! Empty transatlantic barrier
4546 auto transatlanticBarrier = BarrierData ();
4647 // ! Observation date for schedule monitoring dates only at the end
47-
48+
4849 std::string domesticCurrency = fxEuropeanBarrierOption->soldCurrency ();
4950
5051 Date expiryDate = parseDate (exerciseDate);
@@ -64,14 +65,14 @@ FxEuropeanBarrierOptionEngineBuilder::build(const Trade* trade, const QuantLib::
6465 }
6566 auto qty = fxEuropeanBarrierOption->boughtAmount ();
6667 auto strike = fxEuropeanBarrierOption->strike ();
67-
68+ std::vector<BarrierData> barriers = {fxEuropeanBarrierOption-> barrier ()};
6869 auto barrierOption = QuantLib::ext::make_shared<GenericBarrierOption>(
69- underlying, optionData, {fxEuropeanBarrierOption-> barrierData ()} , barrierMonitoringDates, transatlanticBarrier,
70- domesticCurrency, to_string (paymentDate), to_string (qty), to_string (strike), " " , " " );
70+ underlying, optionData, barriers , barrierMonitoringDates, transatlanticBarrier, domesticCurrency ,
71+ to_string (paymentDate), to_string (qty), to_string (strike), " " , " " );
7172
7273 barrierOption->build (engineFactory);
7374 return barrierOption;
7475}
7576
7677} // namespace data
77- } // namespace oreplus
78+ } // namespace ore
0 commit comments