Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equityasianoption.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Skandinaviska Enskilda Banken AB (publ)
3 All rights reserved.
4 This file is part of ORE, a free-software/open-source library
5 for transparent pricing and risk analysis - http://opensourcerisk.org
6 ORE is free software: you can redistribute it and/or modify it
7 under the terms of the Modified BSD License. You should have received a
8 copy of the license along with this program.
9 The license is also available online at <http://opensourcerisk.org>
10 This program is distributed on the basis that it will form a useful
11 contribution to risk analytics and model standardisation, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
14 */
15
16 #include <boost/test/unit_test.hpp>
17 #include <oret/toplevelfixture.hpp>
18
19 #include <boost/make_shared.hpp>
20
21 #include <ql/currencies/america.hpp>
22 #include <ql/instruments/asianoption.hpp>
23 #include <ql/math/interpolations/linearinterpolation.hpp>
24 #include <ql/termstructures/yield/flatforward.hpp>
25 #include <ql/time/daycounters/actual360.hpp>
26
34
35 using namespace std;
36 using namespace boost::unit_test_framework;
37 using namespace boost::algorithm;
38 using namespace QuantLib;
39 using namespace QuantExt;
40 using namespace ore::data;
41
42 namespace {
43
44 class TestMarket : public MarketImpl {
45 public:
46 TestMarket(const Real spot, const Date& expiry, const Rate riskFreeRate, const Rate dividendYield,
47 const Volatility flatVolatility)
48 : MarketImpl(false) {
49 // Reference date and common day counter
50 asof_ = Date(01, Feb, 2021);
51 // Actual365Fixed dayCounter;
52 DayCounter dayCounter = Actual360();
53
54 // Add USD discount curve
55 Handle<YieldTermStructure> discount(QuantLib::ext::make_shared<FlatForward>(asof_, riskFreeRate, dayCounter));
56 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "USD")] = discount;
57 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Yield, "COMPANY")] = discount;
58
59 // Add COMPANY dividend yield
60 Handle<YieldTermStructure> dividendYTS(QuantLib::ext::make_shared<FlatForward>(asof_, dividendYield, dayCounter));
61 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::EquityDividend, "COMPANY")] = dividendYTS;
62
63 // Add equity spots
64 equitySpots_[make_pair(Market::defaultConfiguration, "COMPANY")] =
65 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(spot));
66
67 // Add COMPANY equity curve
68 equityCurves_[make_pair(Market::defaultConfiguration, "COMPANY")] = Handle<EquityIndex2>(
69 QuantLib::ext::make_shared<EquityIndex2>("COMPANY", TARGET(), parseCurrency("USD"), equitySpot("COMPANY"),
70 yieldCurve(YieldCurveType::Discount, "USD"),
71 yieldCurve(YieldCurveType::EquityDividend, "COMPANY")));
72
73 // Add COMPANY volatilities
74 Handle<BlackVolTermStructure> volatility(
75 QuantLib::ext::make_shared<BlackConstantVol>(asof_, TARGET(), flatVolatility, dayCounter));
76 equityVols_[make_pair(Market::defaultConfiguration, "COMPANY")] = volatility;
77 }
78 };
79
80 struct DiscreteAsianTestData {
81 Option::Type type;
82 Real spot;
83 Real strike;
84 Rate dividendYield;
85 Rate riskFreeRate;
86 Time firstFixing;
87 Time length;
88 Size fixings;
89 Volatility volatility;
90 Real expectedNPV;
91 };
92
93 } // namespace
94
95 BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
96
97 BOOST_AUTO_TEST_SUITE(EquityAsianOptionTests)
98
99 BOOST_AUTO_TEST_CASE(testEquityAsianOptionTradeBuilding) {
100
101 BOOST_TEST_MESSAGE("Testing equity Asian option trade building with constant vol term structure");
102
103 // Data from "Asian Option", Levy, 1997 in "Exotic Options: The State of the Art",
104 // edited by Clewlow, Strickland
105 // Tests with > 100 fixings are skipped here for speed, QL already tests these
106 std::vector<DiscreteAsianTestData> asians = {
107 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 2, 0.13, 1.3942835683},
108 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 4, 0.13, 1.5852442983},
109 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 8, 0.13, 1.66970673},
110 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 12, 0.13, 1.6980019214},
111 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 26, 0.13, 1.7255070456},
112 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 52, 0.13, 1.7401553533},
113 {Option::Put, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 100, 0.13, 1.7478303712},
114 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 2, 0.13, 1.8496053697},
115 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 4, 0.13, 2.0111495205},
116 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 8, 0.13, 2.0852138818},
117 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 12, 0.13, 2.1105094397},
118 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 26, 0.13, 2.1346526695},
119 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 52, 0.13, 2.147489651},
120 {Option::Put, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 100, 0.13, 2.154728109},
121 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 2, 0.13, 2.63315092584},
122 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 4, 0.13, 2.76723962361},
123 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 8, 0.13, 2.83124836881},
124 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 12, 0.13, 2.84290301412},
125 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 26, 0.13, 2.88179560417},
126 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 52, 0.13, 2.88447044543},
127 {Option::Put, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 100, 0.13, 2.89985329603}};
128
129 Date asof = Date(01, Feb, 2021);
130 Envelope env("CP1");
131 QuantLib::ext::shared_ptr<EngineFactory> engineFactory;
132 QuantLib::ext::shared_ptr<Market> market;
133
134 for (const auto& a : asians) {
135 Time deltaT = a.length / (a.fixings - 1);
136 Date expiry;
137 vector<Date> fixingDates(a.fixings);
138 vector<std::string> strFixingDates(a.fixings);
139 for (Size i = 0; i < a.fixings; ++i) {
140 fixingDates[i] = (asof + static_cast<Integer>((a.firstFixing + i * deltaT) * 360 + 0.5));
141 strFixingDates[i] = to_string(fixingDates[i]);
142 }
143 expiry = fixingDates[a.fixings - 1];
144
145 ScheduleDates scheduleDates("NullCalendar", "", "", strFixingDates);
146 ScheduleData scheduleData(scheduleDates);
147
148 market = QuantLib::ext::make_shared<TestMarket>(a.spot, expiry, a.riskFreeRate, a.dividendYield, a.volatility);
149 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
150 std::string productName = "EquityAsianOptionArithmeticPrice";
151 engineData->model(productName) = "BlackScholesMerton";
152 engineData->engine(productName) = "MCDiscreteArithmeticAPEngine";
153 engineData->engineParameters(productName) = {{"ProcessType", "Discrete"}, {"BrownianBridge", "True"},
154 {"AntitheticVariate", "False"}, {"ControlVariate", "True"},
155 {"RequiredSamples", "2047"}, {"Seed", "0"}};
156 engineFactory = QuantLib::ext::make_shared<EngineFactory>(engineData, market);
157
158 // Set evaluation date
159 Settings::instance().evaluationDate() = market->asofDate();
160
161 // Test the building of a equity Asian option doesn't throw
162 PremiumData premiumData;
163 OptionData optionData("Long", to_string(a.type), "European", true, {to_string(expiry)}, "Cash", "",
164 premiumData, vector<Real>(), vector<Real>(), "", "", "", vector<string>(),
165 vector<string>(), "", "", "", "Asian", "Arithmetic", boost::none, boost::none,
166 boost::none);
167
168 QuantLib::ext::shared_ptr<EquityAsianOption> asianOption = QuantLib::ext::make_shared<EquityAsianOption>(
169 env, "EquityAsianOption", 1.0, TradeStrike(a.strike, "USD"), optionData, scheduleData,
170 QuantLib::ext::make_shared<EquityUnderlying>("COMPANY"), Date(), "USD");
171 BOOST_CHECK_NO_THROW(asianOption->build(engineFactory));
172
173 // Check the underlying instrument was built as expected
174 QuantLib::ext::shared_ptr<Instrument> qlInstrument = asianOption->instrument()->qlInstrument();
175
176 QuantLib::ext::shared_ptr<DiscreteAveragingAsianOption> discreteAsian =
177 QuantLib::ext::dynamic_pointer_cast<DiscreteAveragingAsianOption>(qlInstrument);
178
179 BOOST_CHECK(discreteAsian);
180 BOOST_CHECK_EQUAL(discreteAsian->exercise()->type(), Exercise::Type::European);
181 BOOST_CHECK_EQUAL(discreteAsian->exercise()->dates().size(), 1);
182 BOOST_CHECK_EQUAL(discreteAsian->exercise()->dates()[0], expiry);
183
184 QuantLib::ext::shared_ptr<TypePayoff> payoff = QuantLib::ext::dynamic_pointer_cast<TypePayoff>(discreteAsian->payoff());
185 BOOST_CHECK(payoff);
186 BOOST_CHECK_EQUAL(payoff->optionType(), a.type);
187
188 Real expectedPrice = a.expectedNPV;
189
190 // Check the price
191 BOOST_CHECK_SMALL(asianOption->instrument()->NPV() - expectedPrice, 2e-2);
192 }
193 }
194
195 BOOST_AUTO_TEST_CASE(testEquityAsianOptionAverageStrikeTradeBuilding) {
196
197 BOOST_TEST_MESSAGE(
198 "Testing equity Asian option trade building with constant vol term structure with average-strike");
199
200 // Data from "Asian Option", Levy, 1997 in "Exotic Options: The State of the Art",
201 // edited by Clewlow, Strickland
202 // Tests with > 100 fixings are skipped here for speed, QL already tests these
203 std::vector<DiscreteAsianTestData> asians = {
204 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 2, 0.13, 1.51917595129},
205 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 4, 0.13, 1.67940165674},
206 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 8, 0.13, 1.75371215251},
207 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 12, 0.13, 1.77595318693},
208 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 26, 0.13, 1.81430536630},
209 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 52, 0.13, 1.82269246898},
210 {Option::Call, 90.0, 87.0, 0.06, 0.025, 0.0, 11.0 / 12.0, 100, 0.13, 1.83822402464},
211 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 2, 0.13, 1.51154400089},
212 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 4, 0.13, 1.67103508506},
213 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 8, 0.13, 1.74529684070},
214 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 12, 0.13, 1.76667074564},
215 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 26, 0.13, 1.80528400613},
216 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 52, 0.13, 1.81400883891},
217 {Option::Call, 90.0, 87.0, 0.06, 0.025, 1.0 / 12.0, 11.0 / 12.0, 100, 0.13, 1.82922901451},
218 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 2, 0.13, 1.49648170891},
219 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 4, 0.13, 1.65443100462},
220 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 8, 0.13, 1.72817806731},
221 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 12, 0.13, 1.74877367895},
222 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 26, 0.13, 1.78733801988},
223 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 52, 0.13, 1.79624826757},
224 {Option::Call, 90.0, 87.0, 0.06, 0.025, 3.0 / 12.0, 11.0 / 12.0, 100, 0.13, 1.81114186876}};
225
226 Date asof = Date(01, Feb, 2021);
227 Envelope env("CP1");
228 QuantLib::ext::shared_ptr<EngineFactory> engineFactory;
229 QuantLib::ext::shared_ptr<Market> market;
230
231 for (const auto& a : asians) {
232 Time deltaT = a.length / (a.fixings - 1);
233 Date expiry;
234 vector<Date> fixingDates(a.fixings);
235 vector<std::string> strFixingDates(a.fixings);
236 for (Size i = 0; i < a.fixings; ++i) {
237 fixingDates[i] = (asof + static_cast<Integer>((a.firstFixing + i * deltaT) * 360 + 0.5));
238 strFixingDates[i] = to_string(fixingDates[i]);
239 }
240 expiry = fixingDates[a.fixings - 1];
241
242 ScheduleDates scheduleDates("NullCalendar", "", "", strFixingDates);
243 ScheduleData scheduleData(scheduleDates);
244
245 market = QuantLib::ext::make_shared<TestMarket>(a.spot, expiry, a.riskFreeRate, a.dividendYield, a.volatility);
246 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
247 std::string productName = "EquityAsianOptionArithmeticStrike";
248 engineData->model(productName) = "BlackScholesMerton";
249 engineData->engine(productName) = "MCDiscreteArithmeticASEngine";
250 engineData->engineParameters(productName) = {{"ProcessType", "Discrete"},
251 {"BrownianBridge", "True"},
252 {"AntitheticVariate", "False"},
253 {"RequiredSamples", "1000"},
254 {"Seed", "3456789"}};
255 engineFactory = QuantLib::ext::make_shared<EngineFactory>(engineData, market);
256
257 // Set evaluation date
258 Settings::instance().evaluationDate() = market->asofDate();
259
260 // Test the building of a equity Asian option doesn't throw
261 PremiumData premiumData;
262 OptionData optionData("Long", to_string(a.type), "European", true, {to_string(expiry)}, "Cash", "",
263 premiumData, vector<Real>(), vector<Real>(), "", "", "", vector<string>(),
264 vector<string>(), "", "", "", "AverageStrike", "Arithmetic", boost::none, boost::none,
265 boost::none);
266
267 QuantLib::ext::shared_ptr<EquityAsianOption> asianOption = QuantLib::ext::make_shared<EquityAsianOption>(
268 env, "EquityAsianOption", 1.0, TradeStrike(a.strike, "USD"), optionData, scheduleData,
269 QuantLib::ext::make_shared<EquityUnderlying>("COMPANY"), Date(), "USD");
270 BOOST_CHECK_NO_THROW(asianOption->build(engineFactory));
271
272 // Check the underlying instrument was built as expected
273 QuantLib::ext::shared_ptr<Instrument> qlInstrument = asianOption->instrument()->qlInstrument();
274
275 QuantLib::ext::shared_ptr<DiscreteAveragingAsianOption> discreteAsian =
276 QuantLib::ext::dynamic_pointer_cast<DiscreteAveragingAsianOption>(qlInstrument);
277
278 BOOST_CHECK(discreteAsian);
279 BOOST_CHECK_EQUAL(discreteAsian->exercise()->type(), Exercise::Type::European);
280 BOOST_CHECK_EQUAL(discreteAsian->exercise()->dates().size(), 1);
281 BOOST_CHECK_EQUAL(discreteAsian->exercise()->dates()[0], expiry);
282
283 QuantLib::ext::shared_ptr<TypePayoff> payoff = QuantLib::ext::dynamic_pointer_cast<TypePayoff>(discreteAsian->payoff());
284 BOOST_CHECK(payoff);
285 BOOST_CHECK_EQUAL(payoff->optionType(), a.type);
286
287 Real expectedPrice = a.expectedNPV;
288
289 // Check the price
290 BOOST_CHECK_SMALL(asianOption->instrument()->NPV() - expectedPrice, 2e-2);
291 }
292 }
293
294 BOOST_AUTO_TEST_CASE(testEquityAsianOptionFromXml) {
295
296 BOOST_TEST_MESSAGE("Testing parsing of equity Asian option trade from XML");
297
298 // Create an XML string representation of the trade
299 string tradeXml;
300 tradeXml.append("<Portfolio>");
301 tradeXml.append(" <Trade id=\"EquityAsianOption_Company\">");
302 tradeXml.append(" <TradeType>EquityAsianOption</TradeType>");
303 tradeXml.append(" <Envelope>");
304 tradeXml.append(" <CounterParty>CPTY_A</CounterParty>");
305 tradeXml.append(" <NettingSetId>CPTY_A</NettingSetId>");
306 tradeXml.append(" <AdditionalFields/>");
307 tradeXml.append(" </Envelope>");
308 tradeXml.append(" <EquityAsianOptionData>");
309 tradeXml.append(" <OptionData>");
310 tradeXml.append(" <LongShort>Long</LongShort>");
311 tradeXml.append(" <OptionType>Call</OptionType>");
312 tradeXml.append(" <Style>European</Style>");
313 tradeXml.append(" <Settlement>Cash</Settlement>");
314 tradeXml.append(" <PayOffAtExpiry>false</PayOffAtExpiry>");
315 tradeXml.append(" <PayoffType>Asian</PayoffType>");
316 tradeXml.append(" <PayoffType2>Arithmetic</PayoffType2>");
317 tradeXml.append(" <ExerciseDates>");
318 tradeXml.append(" <ExerciseDate>2021-02-26</ExerciseDate>");
319 tradeXml.append(" </ExerciseDates>");
320 tradeXml.append(" </OptionData>");
321 tradeXml.append(" <ObservationDates>");
322 tradeXml.append(" <Dates>");
323 tradeXml.append(" <Dates>");
324 tradeXml.append(" <Date>2021-02-01</Date>");
325 tradeXml.append(" <Date>2021-02-02</Date>");
326 tradeXml.append(" <Date>2021-02-03</Date>");
327 tradeXml.append(" <Date>2021-02-04</Date>");
328 tradeXml.append(" <Date>2021-02-05</Date>");
329 tradeXml.append(" <Date>2021-02-08</Date>");
330 tradeXml.append(" <Date>2021-02-09</Date>");
331 tradeXml.append(" <Date>2021-02-10</Date>");
332 tradeXml.append(" <Date>2021-02-11</Date>");
333 tradeXml.append(" <Date>2021-02-12</Date>");
334 tradeXml.append(" <Date>2021-02-15</Date>");
335 tradeXml.append(" <Date>2021-02-16</Date>");
336 tradeXml.append(" <Date>2021-02-17</Date>");
337 tradeXml.append(" <Date>2021-02-18</Date>");
338 tradeXml.append(" <Date>2021-02-19</Date>");
339 tradeXml.append(" <Date>2021-02-22</Date>");
340 tradeXml.append(" <Date>2021-02-23</Date>");
341 tradeXml.append(" <Date>2021-02-24</Date>");
342 tradeXml.append(" <Date>2021-02-25</Date>");
343 tradeXml.append(" <Date>2021-02-26</Date>");
344 tradeXml.append(" </Dates>");
345 tradeXml.append(" </Dates>");
346 tradeXml.append(" </ObservationDates>");
347 tradeXml.append(" <Underlying>");
348 tradeXml.append(" <Type>Equity</Type>");
349 tradeXml.append(" <Name>COMPANY</Name>");
350 tradeXml.append(" </Underlying>");
351 tradeXml.append(" <Currency>USD</Currency>");
352 tradeXml.append(" <Strike>2270</Strike>");
353 tradeXml.append(" <Quantity>1</Quantity>");
354 tradeXml.append(" </EquityAsianOptionData>");
355 tradeXml.append(" </Trade>");
356 tradeXml.append("</Portfolio>");
357
358 // Load portfolio from XML string
359 Portfolio portfolio;
360 portfolio.fromXMLString(tradeXml);
361
362 // Extract EquityAsianOption trade from portfolio
363 QuantLib::ext::shared_ptr<Trade> trade = portfolio.trades().begin()->second;
364 QuantLib::ext::shared_ptr<EquityAsianOption> option = QuantLib::ext::dynamic_pointer_cast<ore::data::EquityAsianOption>(trade);
365 BOOST_CHECK(option != nullptr);
366
367 // Check fields after checking that the cast was successful
368 BOOST_CHECK(option);
369 BOOST_CHECK_EQUAL(option->tradeType(), "EquityAsianOption");
370 BOOST_CHECK_EQUAL(option->id(), "EquityAsianOption_Company");
371 // BOOST_CHECK_EQUAL(option->asset(), "COMPANY"); // only available after build
372 BOOST_CHECK_EQUAL(option->payCurrency(), "USD");
373 BOOST_CHECK_EQUAL(option->strike().value(), 2270);
374 BOOST_CHECK_EQUAL(option->quantity(), 1);
375 BOOST_CHECK_EQUAL(option->option().longShort(), "Long");
376 BOOST_CHECK_EQUAL(option->option().callPut(), "Call");
377 BOOST_CHECK_EQUAL(option->option().style(), "European");
378 BOOST_CHECK_EQUAL(option->option().exerciseDates().size(), 1);
379 BOOST_CHECK_EQUAL(option->option().exerciseDates()[0], "2021-02-26");
380 BOOST_CHECK(option->observationDates().hasData());
381
382 BOOST_CHECK_EQUAL(option->option().payoffType(), "Asian");
383 BOOST_CHECK_EQUAL(option->option().payoffType2(), "Arithmetic");
384 }
385
386 BOOST_AUTO_TEST_SUITE_END()
387
388 BOOST_AUTO_TEST_SUITE_END()
Asian option representation.
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
Market Implementation.
Definition: marketimpl.hpp:53
map< pair< string, string >, QuantLib::Handle< QuantExt::EquityIndex2 > > equityCurves_
Definition: marketimpl.hpp:232
map< tuple< string, YieldCurveType, string >, Handle< YieldTermStructure > > yieldCurves_
Definition: marketimpl.hpp:208
map< pair< string, string >, Handle< Quote > > equitySpots_
Definition: marketimpl.hpp:225
Handle< Quote > equitySpot(const string &eqName, const string &configuration=Market::defaultConfiguration) const override
Equity curves.
Definition: marketimpl.cpp:359
map< pair< string, string >, Handle< BlackVolTermStructure > > equityVols_
Definition: marketimpl.hpp:226
Handle< YieldTermStructure > yieldCurve(const YieldCurveType &type, const string &ccy, const string &configuration=Market::defaultConfiguration) const override
Yield Curves.
Definition: marketimpl.cpp:74
Serializable object holding option data.
Definition: optiondata.hpp:42
Serializable portfolio.
Definition: portfolio.hpp:43
const std::map< std::string, QuantLib::ext::shared_ptr< Trade > > & trades() const
Return the map tradeId -> trade.
Definition: portfolio.cpp:162
Serializable object holding premium data.
Definition: premiumdata.hpp:37
Serializable schedule data.
Definition: schedule.hpp:202
Serializable object holding schedule Dates data.
Definition: schedule.hpp:110
void fromXMLString(const std::string &xml)
Parse from XML string.
Definition: xmlutils.cpp:162
Engine builder for equity Asian options.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
An implementation of the Market class that stores the required objects in maps.
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
trade option data model and serialization
Portfolio class.
trade schedule data model and serialization
BOOST_AUTO_TEST_CASE(testEquityAsianOptionTradeBuilding)
string conversion utilities