Skip to content

Commit

Permalink
update code to accommodate deprecated code deleted from QuantLib
Browse files Browse the repository at this point in the history
  • Loading branch information
eehlers committed Jul 16, 2021
1 parent fe49a38 commit d84c22b
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 314 deletions.
2 changes: 1 addition & 1 deletion QuantLibAddin/gensrc/metadata/functions/calendar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<alias>QuantLib::Calendar::holidayList</alias>
<SupportedPlatforms>
<!--SupportedPlatform name='Excel' calcInWizard='false'/-->
<SupportedPlatform name='Excel'/>
<SupportedPlatform name='Excel' implementation='manual'/>
<SupportedPlatform name='Calc'/>
<!--SupportedPlatform name='Cpp'/-->
</SupportedPlatforms>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
</ReturnValue>
</Member>

<Member name='qlOneFactorAffineModelCalibrate' type='QuantLib::OneFactorAffineModel'>
<!--Member name='qlOneFactorAffineModelCalibrate' type='QuantLib::OneFactorAffineModel'>
<description>calibrate a model.</description>
<libraryFunction>calibrate</libraryFunction>
<SupportedPlatforms>
Expand Down Expand Up @@ -219,9 +219,9 @@
<type>void</type>
<tensorRank>scalar</tensorRank>
</ReturnValue>
</Member>
</Member-->

<Member name='qlModelG2Calibrate' type='QuantLib::G2'>
<!--Member name='qlModelG2Calibrate' type='QuantLib::G2'>
<description>calibrate a model.</description>
<libraryFunction>calibrate</libraryFunction>
<SupportedPlatforms>
Expand Down Expand Up @@ -271,7 +271,7 @@
<type>void</type>
<tensorRank>scalar</tensorRank>
</ReturnValue>
</Member>
</Member-->

</Functions>
</Category>
10 changes: 0 additions & 10 deletions QuantLibAddin/gensrc/metadata/functions/piecewiseyieldcurve.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@
<tensorRank>vector</tensorRank>
<description>Jump dates vector.</description>
</Parameter>
<Parameter name='Accuracy' default='1.0e-12'>
<type>QuantLib::Real</type>
<tensorRank>scalar</tensorRank>
<description>Bootstrapping accuracy.</description>
</Parameter>
<Parameter name='TraitsID' default='"Discount"'>
<type>string</type>
<tensorRank>scalar</tensorRank>
Expand Down Expand Up @@ -124,11 +119,6 @@
<tensorRank>vector</tensorRank>
<description>Jump dates vector.</description>
</Parameter>
<Parameter name='Accuracy' default='1.0e-12'>
<type>QuantLib::Real</type>
<tensorRank>scalar</tensorRank>
<description>Bootstrapping accuracy.</description>
</Parameter>
<Parameter name='TraitsID' default='"Discount"'>
<type>string</type>
<tensorRank>scalar</tensorRank>
Expand Down
240 changes: 60 additions & 180 deletions QuantLibAddin/qlo/enumerations/constructors/enumeratedpairs.cpp

Large diffs are not rendered by default.

156 changes: 48 additions & 108 deletions QuantLibAddin/qlo/enumerations/constructors/enumeratedpairs.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace ObjectHandler {
const QuantLib::DayCounter& dayCounter,
const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
const std::vector<QuantLib::Date>& jumpDates,
const QuantLib::Real accuracy,
const QuantLib::MixedInterpolation::Behavior behavior,
const QuantLib::Size n);

Expand All @@ -66,7 +65,6 @@ namespace ObjectHandler {
const QuantLib::DayCounter& dayCounter,
const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
const std::vector<QuantLib::Date>& jumpDates,
const QuantLib::Real accuracy,
const QuantLib::MixedInterpolation::Behavior behavior,
const QuantLib::Size n) {
KeyPair key(traitsID, interpolatorID);
Expand All @@ -75,7 +73,7 @@ namespace ObjectHandler {
return yieldTermStructureConstructor(nDays, calendar,
rh, dayCounter,
jumps, jumpDates,
accuracy, behavior, n);
behavior, n);
}
using RegistryManager<QuantLib::YieldTermStructure,
EnumPairRegistry>::registerType;
Expand Down
4 changes: 0 additions & 4 deletions QuantLibAddin/qlo/piecewiseyieldcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace QuantLibAddin {
const QuantLib::DayCounter& dayCounter,
const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
const std::vector<QuantLib::Date>& jumpDates,
QuantLib::Real accuracy,
const std::string& traitsID,
const std::string& interpolatorID,
const QuantLib::MixedInterpolation::Behavior behavior,
Expand All @@ -60,7 +59,6 @@ namespace QuantLibAddin {
dayCounter,
jumps,
jumpDates,
accuracy,
behavior,
n);

Expand All @@ -81,7 +79,6 @@ namespace QuantLibAddin {
const QuantLib::DayCounter& dayCounter,
const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
const std::vector<QuantLib::Date>& jumpDates,
QuantLib::Real accuracy,
const std::string& traitsID,
const std::string& interpolatorID,
bool permanent)
Expand All @@ -96,7 +93,6 @@ namespace QuantLibAddin {
dayCounter,
jumps,
jumpDates,
accuracy,
QuantLib::MixedInterpolation::ShareRanges,
0);

Expand Down
2 changes: 0 additions & 2 deletions QuantLibAddin/qlo/piecewiseyieldcurve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace QuantLibAddin {
const QuantLib::DayCounter& dayCounter,
const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
const std::vector<QuantLib::Date>& jumpDates,
QuantLib::Real accuracy,
const std::string& traitsID,
const std::string& interpolatorID,
const QuantLib::MixedInterpolation::Behavior behavior,
Expand All @@ -54,7 +53,6 @@ namespace QuantLibAddin {
const QuantLib::DayCounter& dayCounter,
const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
const std::vector<QuantLib::Date>& jumpDates,
QuantLib::Real accuracy,
const std::string& traitsID,
const std::string& interpolatorID,
bool permanent);
Expand Down
6 changes: 4 additions & 2 deletions QuantLibAddin/qlo/ratehelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ namespace QuantLibAddin {
const bool useCleanPrice,
bool permanent)
: RateHelper(properties, permanent) {
QuantLib::Bond::Price::Type priceType = useCleanPrice ? QuantLib::Bond::Price::Clean : QuantLib::Bond::Price::Dirty;
libraryObject_ = shared_ptr<QuantLib::BondHelper>(new
QuantLib::BondHelper(price, bond, useCleanPrice));
QuantLib::BondHelper(price, bond, priceType));
quoteName_ = f(properties->getSystemProperty("Price"));
}

Expand All @@ -316,6 +317,7 @@ namespace QuantLibAddin {
QuantLib::FixedRateBond(settlementDays, faceAmount, *schedule,
coupons, paymentDayCounter, paymentConvention,
redemption, issueDate)), useCleanPrice, permanent) {
QuantLib::Bond::Price::Type priceType = useCleanPrice ? QuantLib::Bond::Price::Clean : QuantLib::Bond::Price::Dirty;
libraryObject_ = shared_ptr<QuantLib::FixedRateBondHelper>(new
QuantLib::FixedRateBondHelper(price,
settlementDays,
Expand All @@ -331,7 +333,7 @@ namespace QuantLibAddin {
exCouponCalendar,
exCouponConvention,
exCouponEndOfMonth,
useCleanPrice));
priceType));
quoteName_ = f(properties->getSystemProperty("Price"));
}

Expand Down
87 changes: 87 additions & 0 deletions QuantLibXL/qlxl/functions/manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,90 @@ XLL_DEC long *qlFunctionCount() {
// #endif
// return &result;
//}


#include <qlo/qladdindefines.hpp>
#include <oh/enumerations/typefactory.hpp>
#include <qlo/enumerations/factories/calendarfactory.hpp>
#include <ql/time/date.hpp>
#include <ql/time/calendar.hpp>
#include <qlo/loop/loop_calendar.hpp>
#include <ohxl/loop.hpp>

#include <ohxl/callingrange.hpp>
#include <qlxl/session.hpp>
#include <qlxl/conversions/all.hpp>

XLL_DEC OPER* qlCalendarHolidayList(
char* Calendar,
OPER* FromDate,
OPER* ToDate,
OPER* IncludeWeekEnds,
OPER* Trigger) {

// declare a shared pointer to the Function Call object

boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

try {

// instantiate the Function Call object

functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
new ObjectHandler::FunctionCall("qlCalendarHolidayList"));

ObjectHandler::validateRange(Trigger, "Trigger");

// initialize the session ID (if enabled)

SET_SESSION_ID

// convert input datatypes to C++ datatypes

ObjectHandler::property_t FromDateCpp = ObjectHandler::convert2<ObjectHandler::property_t>(
ObjectHandler::ConvertOper(*FromDate));

ObjectHandler::property_t ToDateCpp = ObjectHandler::convert2<ObjectHandler::property_t>(
ObjectHandler::ConvertOper(*ToDate));

bool IncludeWeekEndsCpp = ObjectHandler::convert2<bool>(
ObjectHandler::ConvertOper(*IncludeWeekEnds), "IncludeWeekEnds", false);

// convert input datatypes to QuantLib datatypes

QuantLib::Date FromDateLib = ObjectHandler::convert2<QuantLib::Date>(
ObjectHandler::ConvertOper(*FromDate), "FromDate");

QuantLib::Date ToDateLib = ObjectHandler::convert2<QuantLib::Date>(
ObjectHandler::ConvertOper(*ToDate), "ToDate");

// convert input datatypes to QuantLib enumerated datatypes

QuantLib::Calendar CalendarEnum =
ObjectHandler::Create<QuantLib::Calendar>()(Calendar);

// invoke the utility function

std::vector<QuantLib::Date> returnValue = CalendarEnum.holidayList(
FromDateLib,
ToDateLib,
IncludeWeekEndsCpp);

// convert and return the return value

std::vector<long> returnValVec = QuantLibAddin::libraryToVector(returnValue);
static OPER xRet;
ObjectHandler::vectorToOper(returnValVec, xRet);
return &xRet;

}
catch (const std::exception& e) {
ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
return 0;
}
catch (...) {
ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
return 0;
}

}

0 comments on commit d84c22b

Please sign in to comment.