30#include <ql/models/marketmodels/browniangenerators/mtbrowniangenerator.hpp>
31#include <ql/settings.hpp>
34#include <boost/algorithm/string.hpp>
52 std::vector<Date> result;
56 std::vector<std::pair<Period, Period>> grid;
57 std::vector<std::string> tokens;
58 boost::split(tokens, rule, boost::is_any_of(
","));
59 for (
auto const& t : tokens) {
60 std::vector<std::string> tmp;
61 boost::split(tmp, t, boost::is_any_of(
"()"));
62 QL_REQUIRE(tmp.size() == 3,
"coarsenGrid: invalid rule token '" << t <<
"', expected e.g. '10Y(1M)'");
68 auto d = dates.begin();
69 for (; d != dates.end() && *d <= refDate; ++d) {
76 for (
auto const& p : grid) {
77 Date end = refDate + p.first;
83 start = std::min(end, start + p.second);
86 if (
static_cast<double>(end - start) /
static_cast<double>(end - (end - p.second)) < 0.2)
91 std::vector<Date> candidates;
92 while (d != dates.end() && *d <= start)
93 candidates.push_back(*d++);
95 if (!candidates.empty())
96 result.push_back(candidates.back());
97 }
while (start < end);
107 const std::string& purpose,
108 const bool fallBackOnEmptyPurpose) {
110 DLOG(
"get script '" << scriptedTrade.
scriptName() <<
"' for purpose '" << purpose
111 <<
"' (fallBackOnEmptyPurpose=" << std::boolalpha << fallBackOnEmptyPurpose
112 <<
") from script library");
113 return scriptLibrary.
get(scriptedTrade.
scriptName(), purpose, fallBackOnEmptyPurpose);
115 DLOG(
"get script for purpose '" << purpose <<
"' (fallBackOnEmptyPurpose=" << std::boolalpha
116 << fallBackOnEmptyPurpose <<
") from inline script in scripted trade");
117 return std::make_pair(scriptedTrade.
productTag(), scriptedTrade.
script(purpose, fallBackOnEmptyPurpose));
123 DLOG(
"parsing script (size " << code.size() <<
")");
125 DLOG(
"successfully parsed the script");
127 ALOG(
"an error occured during script parsing:");
129 LOG(
"full script is:");
133 QL_FAIL(
"scripted trade could not be built due to parser errors, see log for more details.");
141 return std::make_pair(
"IR#" + info.
ir()->currency().code(), info.
ir()->tenor());
142 }
else if (info.
isInf()) {
143 return std::make_pair(
"INF#" + info.
infName(), 0 * Days);
144 }
else if (info.
isFx()) {
145 return std::make_pair(
"FX#" + info.
fx()->sourceCurrency().code() + info.
fx()->targetCurrency().code(),
147 }
else if (info.
isEq()) {
148 return std::make_pair(
"EQ#" + info.
eq()->name(), 0 * Days);
149 }
else if (info.
isComm()) {
150 return std::make_pair(
"COM#" + info.
commName(), 0 * Days);
152 QL_FAIL(
"convertIndextoCamCorrelationEntry(): index '" << i <<
"' not recognised");
157 auto scalar = context->scalars.find(
name);
158 auto array = context->arrays.find(
name);
159 QL_REQUIRE(scalar == context->scalars.end() && array == context->arrays.end(),
160 "variable '" <<
name <<
"' already declared.");
163QuantLib::ext::shared_ptr<Context>
makeContext(Size nPaths,
const std::string& gridCoarsening,
164 const std::vector<std::string>& schedulesEligibleForCoarsening,
165 const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceData,
166 const std::vector<ScriptedTradeEventData>& events,
167 const std::vector<ScriptedTradeValueTypeData>& numbers,
168 const std::vector<ScriptedTradeValueTypeData>& indices,
169 const std::vector<ScriptedTradeValueTypeData>& currencies,
170 const std::vector<ScriptedTradeValueTypeData>& daycounters) {
172 TLOG(
"make context");
174 auto context = QuantLib::ext::make_shared<Context>();
177 map<string, ScriptedTradeEventData> derivedSchedules;
178 for (
auto const& x : events) {
179 TLOG(
"adding event " << x.name());
183 context->scalars[x.name()] =
EventVec{nPaths, d};
186 QuantLib::Schedule s;
189 }
catch (
const std::exception& e) {
190 QL_FAIL(
"failed building schedule '" << x.name() <<
"': " << e.what());
193 if (std::find(schedulesEligibleForCoarsening.begin(), schedulesEligibleForCoarsening.end(), x.name()) !=
194 schedulesEligibleForCoarsening.end()) {
196 if (!gridCoarsening.empty()) {
197 TLOG(
"apply grid coarsening rule = " << gridCoarsening <<
" to '" << x.name()
198 <<
"', resulting grid:")
199 for (
auto const& d : c) {
206 std::vector<ValueType> tmp;
207 for (
auto const& d : c)
209 context->arrays[x.name()] = tmp;
210 QL_REQUIRE(!tmp.empty(),
"empty event array '" << x.name() <<
"' not allowed");
212 derivedSchedules[x.name()] = x;
214 QL_FAIL(
"unexpected ScriptedTradeEventData::Type");
216 context->constants.insert(x.name());
220 while (derivedSchedules.size() > 0) {
222 for (
auto& ds : derivedSchedules) {
223 auto base = context->arrays.find(ds.second.baseSchedule());
225 if (base != context->arrays.end()) {
230 std::vector<ValueType> tmp;
231 for (
auto const& d : base->second) {
233 "expected event in base schedule, got " << valueTypeLabels.at(d.which()));
234 EventVec e = QuantLib::ext::get<EventVec>(d);
235 tmp.push_back(
EventVec{nPaths, cal.advance(e.
value, shift, conv)});
237 context->arrays[ds.second.name()] = tmp;
238 derivedSchedules.erase(ds.second.name());
240 }
catch (
const std::exception& e) {
241 QL_FAIL(
"failed building derived schedule '" << ds.second.name() <<
"': " << e.what());
249 for (
const auto& ds : derivedSchedules) {
250 ALOG(
"Failed to build the derived schedule: " << ds.first);
252 QL_FAIL(
"Failed to build at least one derived schedule");
257 for (
auto const& x : numbers) {
258 TLOG(
"adding number " << x.name());
264 std::vector<ValueType> tmp;
265 for (
auto const& d : x.values())
267 context->arrays[x.name()] = tmp;
268 QL_REQUIRE(!tmp.empty(),
"empty number array '" << x.name() <<
"' not allowed");
270 context->constants.insert(x.name());
273 for (
auto const& x : indices) {
274 TLOG(
"adding index " << x.name());
279 std::vector<ValueType> tmp;
280 for (
auto const& d : x.values())
282 context->arrays[x.name()] = tmp;
283 QL_REQUIRE(!tmp.empty(),
"empty index array '" << x.name() <<
"' not allowed");
285 context->constants.insert(x.name());
288 for (
auto const& x : currencies) {
289 TLOG(
"adding currency " << x.name());
294 std::vector<ValueType> tmp;
295 for (
auto const& d : x.values())
297 context->arrays[x.name()] = tmp;
298 QL_REQUIRE(!tmp.empty(),
"empty currency array '" << x.name() <<
"' not allowed");
300 context->constants.insert(x.name());
303 for (
auto const& x : daycounters) {
304 TLOG(
"adding daycounter " << x.name());
309 std::vector<ValueType> tmp;
310 for (
auto const& d : x.values())
312 context->arrays[x.name()] = tmp;
313 QL_REQUIRE(!tmp.empty(),
"empty currency array '" << x.name() <<
"' not allowed");
315 context->constants.insert(x.name());
318 DLOG(
"context built with " << context->scalars.size() <<
" scalars and " << context->arrays.size() <<
" arrays.");
323 const std::vector<ScriptedTradeScriptData::NewScheduleData>& newSchedules) {
324 for (
auto const& x : newSchedules) {
325 DLOG(
"adding new schedule " << x.name());
327 std::vector<std::vector<ValueType>> sources;
328 for (
auto const& s : x.sourceSchedules()) {
329 auto d = context->arrays.find(s);
330 QL_REQUIRE(d != context->arrays.end(),
331 "ScriptedTradeGenericEngineBuilder::engineBuilder(): did not find source schedule '"
332 << s <<
"' when building new schedule '" << x.name() <<
"'");
333 sources.push_back(d->second);
335 std::vector<ValueType> result;
336 if (x.operation() ==
"Join") {
337 std::set<QuantLib::Date> tmp;
339 for (
auto const& s : sources) {
340 for (
auto const& d : s) {
341 tmp.insert(QuantLib::ext::get<EventVec>(d).
value);
342 n = QuantLib::ext::get<EventVec>(d).size;
345 for (
auto const& d : tmp) {
348 context->arrays[x.name()] = result;
349 context->constants.insert(x.name());
351 QL_FAIL(
"new schedule operation '" << x.operation() <<
"' not supported");
358struct SizeSetter :
public boost::static_visitor<void> {
359 explicit SizeSetter(
const Size newSize) :
newSize_(newSize) {}
361 QL_REQUIRE(v.
deterministic(),
"can only change size of determinstic random variables");
364 void operator()(
Filter& v)
const {
365 QL_REQUIRE(v.
deterministic(),
"can only change size of determinstic filters");
368 void operator()(EventVec& c)
const { c.size =
newSize_; }
369 void operator()(CurrencyVec& c)
const { c.size =
newSize_; }
370 void operator()(IndexVec& c)
const { c.size =
newSize_; }
371 void operator()(DaycounterVec& c)
const { c.size =
newSize_; }
380 SizeSetter setter(newSize);
381 for (
auto& x : context->scalars)
382 boost::apply_visitor(setter, x.second);
383 for (
auto& v : context->arrays)
384 for (
auto& x : v.second)
385 boost::apply_visitor(setter, x);
392 if (boost::starts_with(
name,
"COMM-")) {
395 std::vector<std::string> tokens;
396 boost::split(tokens,
name, boost::is_any_of(
"#!"));
397 QL_REQUIRE(!tokens.empty(),
"IndexInfo: no commodity name found for '" <<
name <<
"'");
399 }
else if (boost::starts_with(
name,
"FX-")) {
401 fx_ =
parseFxIndex(
name, Handle<Quote>(), Handle<YieldTermStructure>(), Handle<YieldTermStructure>(),
true);
403 }
else if (boost::starts_with(
name,
"EQ-")) {
412 }
else if (boost::starts_with(
name,
"GENERIC-")) {
444 QL_REQUIRE(done,
"Could not build index info for '"
446 <<
"', expected a valid COMM, FX, EQ, GENERIC, Ibor, Swap, Inflation index identifier.");
461 return comm(obsDate);
463 QL_FAIL(
"could not parse index '" <<
name_ <<
"'");
475 QL_REQUIRE(
isComm(),
"IndexInfo::commName(): commodity index required, got " << *
this);
480 QL_REQUIRE(
isInf(),
"IndexInfo::infName(): inflation index required, got " << *
this);
485 o <<
"index '" << i.
name() <<
"'";
487 o <<
", type FX, index name '" << i.
fx()->name() <<
"'";
489 o <<
", type EQ, index name '" << i.
eq()->name() <<
"'";
493 o <<
", type IR Ibor, index name '" << i.
irIbor()->name() <<
"'";
495 o <<
", type IR Swap, index name '" << i.
irSwap()->name() <<
"'";
497 o <<
", type Generic, index name '" << i.
generic()->name() <<
"'";
502 const Date& asof)
const {
506 auto on = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(
parseIborIndex(
data.rfrIndex));
507 QL_REQUIRE(on,
"IndexInfo::irIborFallback(): could not cast rfr index '"
508 <<
data.rfrIndex <<
"' for ibor fallback index '" <<
name_ <<
"' to an overnight index");
509 return QuantLib::ext::make_shared<FallbackIborIndex>(
irIbor_, on,
data.spread,
data.switchDate,
false);
515 const Date& asof)
const {
519 auto on = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(
parseIborIndex(
data.rfrIndex));
520 QL_REQUIRE(on,
"IndexInfo::irIborFallback(): could not cast rfr index '"
521 <<
data.rfrIndex <<
"' for ibor fallback index '" <<
name_ <<
"' to an overnight index");
522 if (
auto original = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(
irIbor_))
523 return QuantLib::ext::make_shared<FallbackOvernightIndex>(original, on,
data.spread,
data.switchDate,
false);
531 const QuantLib::Date& obsDate) {
533 QL_REQUIRE(!indexName.empty(),
"parseScriptedCommodityIndex(): empty index name");
534 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
535 std::vector<std::string> tokens;
536 boost::split(tokens, indexName, boost::is_any_of(
"#!"));
537 std::string plainIndexName = tokens.front();
540 QuantLib::ext::shared_ptr<CommodityFutureConvention> convention;
541 if (conventions->has(commName)) {
542 convention = QuantLib::ext::dynamic_pointer_cast<CommodityFutureConvention>(conventions->get(commName));
544 Calendar fixingCalendar = convention ? convention->calendar() : NullCalendar();
546 std::vector<std::string> tokens1;
547 boost::split(tokens1, indexName, boost::is_any_of(
"#"));
548 std::vector<std::string> tokens2;
549 boost::split(tokens2, indexName, boost::is_any_of(
"!"));
551 QuantLib::ext::shared_ptr<CommodityIndex> res;
552 if (tokens1.size() >= 2) {
554 QL_REQUIRE(tokens.size() <= 4,
555 "parseScriptedCommodityIndex(): expected COMM-Name#N, Comm-Name#N#D, Comm-Name#N#D#Cal, got '"
556 << indexName <<
"'");
557 QL_REQUIRE(convention,
558 "parseScriptedCommodityIndex(): commodity future convention required for '" << indexName <<
"'");
559 QL_REQUIRE(obsDate != Date(),
"parseScriptedCommodityIndex(): obsDate required for '" << indexName <<
"'");
560 int offset = std::stoi(tokens[1]);
561 int deliveryRollDays = 0;
562 if (tokens.size() >= 3)
564 Calendar rollCal = tokens.size() == 4 ?
parseCalendar(tokens[3]) : fixingCalendar;
566 Date adjustedObsDate = deliveryRollDays != 0 ? rollCal.advance(obsDate, deliveryRollDays * Days) : obsDate;
567 res =
parseCommodityIndex(commName,
false, Handle<PriceTermStructure>(), fixingCalendar,
true);
568 res = res->clone(expiryCalculator.
nextExpiry(
true, adjustedObsDate, offset));
569 }
else if (tokens2.size() >= 2) {
571 QL_REQUIRE(tokens.size() <= 2,
572 "parseScriptedCommodityIndex(): expected COMM-Name!N, got '" << indexName <<
"'");
573 QL_REQUIRE(convention,
574 "parseScriptedCommodityIndex(): commodity future convention required for '" << indexName <<
"'");
575 QL_REQUIRE(obsDate != Date(),
"parseScriptedCommodityIndex(): obsDate required for '" << indexName <<
"'");
576 int offset = std::stoi(tokens[1]);
578 res =
parseCommodityIndex(commName,
false, Handle<PriceTermStructure>(), fixingCalendar,
true);
579 res = res->clone(expiryCalculator.
expiryDate(obsDate, offset));
582 res =
parseCommodityIndex(indexName,
true, QuantLib::Handle<QuantExt::PriceTermStructure>(), fixingCalendar,
586 TLOG(
"parseScriptCommodityIndex(" << indexName <<
"," << QuantLib::io::iso_date(obsDate) <<
") = " << res->name());
590QL_DEPRECATED_DISABLE_WARNING
592std::pair<QuantLib::ext::shared_ptr<QuantLib::ZeroInflationIndex>, std::string>
594 QL_REQUIRE(!indexName.empty(),
"parseScriptedInflationIndex(): empty index name");
595 std::vector<std::string> tokens;
596 boost::split(tokens, indexName, boost::is_any_of(
"#"));
597 std::string plainIndexName = tokens.front();
598 bool interpolated =
false;
599 if (tokens.size() == 1) {
600 interpolated =
false;
601 }
else if (tokens.size() == 2) {
602 QL_REQUIRE(tokens[1] ==
"F" || tokens[1] ==
"L",
"parseScriptedInflationIndex(): expected ...#[L|F], got ...#"
603 << tokens[1] <<
" in '" << indexName <<
"'");
604 interpolated = tokens[1] ==
"L";
606 QL_FAIL(
"parseScriptedInflationIndex(): expected IndexName or IndexName#[F|L], got '" << indexName <<
"'");
608 return std::make_pair(
612QL_DEPRECATED_ENABLE_WARNING
615 if (underlying->type() ==
"Equity") {
616 return "EQ-" + underlying->name();
617 }
else if (underlying->type() ==
"FX") {
618 return "FX-" + underlying->name();
619 }
else if (underlying->type() ==
"Commodity") {
620 QuantLib::ext::shared_ptr<CommodityUnderlying> comUnderlying =
621 QuantLib::ext::dynamic_pointer_cast<CommodityUnderlying>(underlying);
622 std::string tmp =
"COMM-" + comUnderlying->name();
623 if (comUnderlying->priceType().empty() || comUnderlying->priceType() ==
"Spot") {
625 }
else if (comUnderlying->priceType() ==
"FutureSettlement") {
626 tmp +=
"#" + std::to_string(comUnderlying->futureMonthOffset() == Null<Size>()
628 : comUnderlying->futureMonthOffset());
629 if (comUnderlying->deliveryRollDays() != Null<Size>()) {
630 tmp +=
"#" + std::to_string(comUnderlying->deliveryRollDays());
631 if (!comUnderlying->deliveryRollCalendar().empty()) {
632 tmp +=
"#" + comUnderlying->deliveryRollCalendar();
637 QL_FAIL(
"underlying price type '" << comUnderlying->priceType() <<
"' for commodity underlying '"
638 << comUnderlying->name() <<
"' not handled.");
640 }
else if (underlying->type() ==
"InterestRate") {
641 return underlying->name();
642 }
else if (underlying->type() ==
"Inflation") {
643 QuantLib::ext::shared_ptr<InflationUnderlying> infUnderlying =
644 QuantLib::ext::dynamic_pointer_cast<InflationUnderlying>(underlying);
645 if (infUnderlying->interpolation() == QuantLib::CPI::InterpolationType::Linear)
646 return underlying->name() +
"#L";
647 else if (infUnderlying->interpolation() == QuantLib::CPI::InterpolationType::Flat)
648 return underlying->name() +
"#F";
650 QL_FAIL(
"observation interpolation " << infUnderlying->interpolation()
651 <<
" not covered in scripted inflation indexes");
653 }
else if (underlying->type() ==
"Basic") {
654 return underlying->name();
656 QL_FAIL(
"underlying type '" << underlying->type() <<
"' not handled.");
662 Date d1 = index->zeroInflationTermStructure()->baseDate();
663 Date d2 = index->zeroInflationTermStructure()->referenceDate();
664 QL_DEPRECATED_DISABLE_WARNING
665 if (!index->interpolated()) {
666 d2 = inflationPeriod(d2, index->frequency()).first;
668 QL_DEPRECATED_ENABLE_WARNING
672std::map<std::string, std::vector<Real>>
674 const QuantLib::ext::shared_ptr<Context>& context) {
675 std::map<std::string, std::vector<Real>> result;
676 for (
auto const& c : calibrationSpec) {
678 std::vector<std::string> indexNames;
680 auto index = context->scalars.find(c.index());
681 if (index != context->scalars.end()) {
683 "calibration index variable '" << c.index() <<
"' must evaluate to an index");
684 std::string indexName = QuantLib::ext::get<IndexVec>(index->second).value;
691 "FX-GENERIC-" + info.
fx()->sourceCurrency().code() +
"-" + info.
fx()->targetCurrency().code();
692 indexNames.push_back(indexName);
694 auto indexes = context->arrays.find(c.index());
695 if (indexes != context->arrays.end()) {
696 for (Size i = 0; i < indexes->second.size(); ++i) {
698 "calibration strike variable '" << c.index() <<
"[" << i
699 <<
"]' must evaluate to an index");
700 auto indexName = QuantLib::ext::get<IndexVec>(indexes->second[i]).value;
703 indexName =
"FX-GENERIC-" + info.
fx()->sourceCurrency().code() +
"-" +
704 info.
fx()->targetCurrency().code();
705 indexNames.push_back(indexName);
708 QL_FAIL(
"did not find calibration index variable '" << c.index()
709 <<
"' (as scalar or array) in context");
714 for (
auto const& strikeStr : c.strikes()) {
715 auto strike = context->scalars.find(strikeStr);
716 if (strike != context->scalars.end()) {
718 "calibration strike variable '" << strikeStr <<
"' must evaluate to a number");
719 auto strikeNum = QuantLib::ext::get<RandomVariable>(strike->second);
720 QL_REQUIRE(strikeNum.deterministic(),
"calibration strike variable '"
721 << strikeStr <<
"' must be deterministic, got "
723 QL_REQUIRE(indexNames.size() == 1,
"Can only have one index if one strike provided");
724 result[indexNames.at(0)].push_back(strikeNum.at(0));
725 DLOG(
"add calibration strike for index '" << indexNames.at(0) <<
"': " << strikeNum.at(0));
727 auto strikeVec = context->arrays.find(strikeStr);
728 if (strikeVec != context->arrays.end()) {
729 QL_REQUIRE(strikeVec->second.size() % indexNames.size() == 0,
730 "StrikeVec must contain the same number of strikes for each index");
731 auto strikeSize = strikeVec->second.size() / indexNames.size();
733 for (Size j = 0; j < indexNames.size(); j++) {
734 for (Size i = 0; i < strikeSize; ++i) {
736 "calibration strike variable '" << strikeStr <<
"[" << i
737 <<
"]' must evaluate to a number");
738 auto strikeNum = QuantLib::ext::get<RandomVariable>(strikeVec->second[ind]);
739 QL_REQUIRE(strikeNum.deterministic(),
"calibration strike variable '"
740 "calibration strike variable '"
741 << strikeStr <<
"[" << i
742 <<
"]' must be deterministic, got "
744 result[indexNames[j]].push_back(strikeNum.at(0));
745 DLOG(
"add calibration strike for index '" << indexNames[j] <<
"' from : '" << strikeStr
746 <<
"[" << i <<
"]' " << strikeNum.at(0));
751 WLOG(
"getCalibrationStrikes: did not find calibration strike variable '" << strikeStr
752 <<
"' (as scalar or array) in context forcalibration index variable '" << c.index());
Perform date calculations for future contracts based on conventions.
QuantLib::Date nextExpiry(bool includeExpiry=true, const QuantLib::Date &referenceDate=QuantLib::Date(), QuantLib::Natural offset=0, bool forOption=false) override
QuantLib::Date expiryDate(const QuantLib::Date &contractDate, QuantLib::Natural monthOffset=0, bool forOption=false) override
const FallbackData & fallbackData(const string &iborIndex) const
bool isIndexReplaced(const string &iborIndex, const QuantLib::Date &asof=QuantLib::Date::maxDate()) const
QuantLib::ext::shared_ptr< Index > index(const Date &obsDate=Date()) const
std::string infName() const
QuantLib::ext::shared_ptr< Market > market_
QuantLib::ext::shared_ptr< ZeroInflationIndex > inf_
QuantLib::ext::shared_ptr< Index > generic() const
QuantLib::ext::shared_ptr< IborIndex > irIbor_
QuantLib::ext::shared_ptr< SwapIndex > irSwap() const
QuantLib::ext::shared_ptr< FxIndex > fx_
IndexInfo(const std::string &name, const QuantLib::ext::shared_ptr< Market > &market=nullptr)
QuantLib::ext::shared_ptr< InterestRateIndex > ir_
QuantLib::ext::shared_ptr< EquityIndex2 > eq_
QuantLib::ext::shared_ptr< EquityIndex2 > eq() const
QuantLib::ext::shared_ptr< FallbackIborIndex > irIborFallback(const IborFallbackConfig &iborFallbackConfig, const Date &asof=QuantLib::Date::maxDate()) const
QuantLib::ext::shared_ptr< SwapIndex > irSwap_
QuantLib::ext::shared_ptr< InterestRateIndex > ir() const
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > comm(const Date &obsDate=Date()) const
QuantLib::ext::shared_ptr< IborIndex > irIbor() const
QuantLib::ext::shared_ptr< Index > generic_
QuantLib::ext::shared_ptr< FxIndex > fx() const
QuantLib::ext::shared_ptr< FallbackOvernightIndex > irOvernightFallback(const IborFallbackConfig &iborFallbackConfig, const Date &asof=QuantLib::Date::maxDate()) const
std::string commName() const
std::pair< std::string, ScriptedTradeScriptData > get(const std::string &scriptName, const std::string &purpose, const bool fallBackOnEmptyPurpose=true) const
const ParserError & error() const
const std::string & productTag() const
const std::map< std::string, ScriptedTradeScriptData > & script() const
const std::string & scriptName() const
SafeStack< ValueType > value
Base class for classes that perform date calculations for future contracts.
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex(const string &s, const Handle< ZeroInflationTermStructure > &h)
Convert std::string to QuantLib::ZeroInflationIndex.
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex(const string &s, const Handle< YieldTermStructure > &f, const Handle< YieldTermStructure > &d)
Convert std::string to QuantLib::SwapIndex.
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
Convert std::string to QuantLib::IborIndex.
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > parseEquityIndex(const string &s)
Convert std::string (e.g SP5) to QuantExt::EquityIndex.
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, const bool useConventions)
Convert std::string to QuantExt::FxIndex.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
QuantLib::ext::shared_ptr< QuantLib::Index > parseGenericIndex(const string &s)
Convert std::string (GENERIC-...) to QuantExt::Index.
Real parseReal(const string &s)
Convert text to Real.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Map text representations to QuantLib/QuantExt types.
Classes and functions for log message handling.
#define LOG(text)
Logging Macro (Level = Notice)
#define DLOG(text)
Logging Macro (Level = Debug)
#define ALOG(text)
Logging Macro (Level = Alert)
#define LOGGERSTREAM(text)
#define WLOG(text)
Logging Macro (Level = Warning)
#define TLOG(text)
Logging Macro (Level = Data)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
void amendContextVariablesSizes(QuantLib::ext::shared_ptr< Context > context, const Size newSize)
QL_DEPRECATED_ENABLE_WARNING std::string scriptedIndexName(const QuantLib::ext::shared_ptr< Underlying > &underlying)
std::vector< Date > coarsenDateGrid(const std::vector< Date > &dates, const std::string &rule, const Date &referenceDate)
ASTNodePtr parseScript(const std::string &code)
QL_DEPRECATED_DISABLE_WARNING std::pair< QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex >, std::string > parseScriptedInflationIndex(const std::string &indexName)
void addNewSchedulesToContext(QuantLib::ext::shared_ptr< Context > context, const std::vector< ScriptedTradeScriptData::NewScheduleData > &newSchedules)
std::string to_string(const LocationInfo &l)
std::map< std::string, std::vector< Real > > getCalibrationStrikes(const std::vector< ScriptedTradeScriptData::CalibrationData > &calibrationSpec, const QuantLib::ext::shared_ptr< Context > &context)
void checkDuplicateName(const QuantLib::ext::shared_ptr< Context > context, const std::string &name)
Size getInflationSimulationLag(const QuantLib::ext::shared_ptr< ZeroInflationIndex > &index)
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseCommodityIndex(const string &name, bool hasPrefix, const Handle< PriceTermStructure > &ts, const Calendar &cal, const bool enforceFutureIndex)
std::pair< std::string, ScriptedTradeScriptData > getScript(const ScriptedTrade &scriptedTrade, const ScriptLibraryData &scriptLibrary, const std::string &purpose, const bool fallBackOnEmptyPurpose)
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseScriptedCommodityIndex(const std::string &indexName, const QuantLib::Date &obsDate)
Schedule makeSchedule(const ScheduleDates &data)
std::pair< std::string, Period > convertIndexToCamCorrelationEntry(const std::string &i)
QuantLib::ext::shared_ptr< ASTNode > ASTNodePtr
QuantLib::ext::shared_ptr< Context > makeContext(Size nPaths, const std::string &gridCoarsening, const std::vector< std::string > &schedulesEligibleForCoarsening, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData, const std::vector< ScriptedTradeEventData > &events, const std::vector< ScriptedTradeValueTypeData > &numbers, const std::vector< ScriptedTradeValueTypeData > &indices, const std::vector< ScriptedTradeValueTypeData > ¤cies, const std::vector< ScriptedTradeValueTypeData > &daycounters)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
bool deterministic() const
bool at(const Size i) const
Real at(const Size i) const
bool deterministic() const
string conversion utilities