Skip to content

Commit

Permalink
Rename convenience function
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Feb 19, 2024
1 parent 22dc911 commit 30d6eb5
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Examples/CDS/CDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void example01() {
std::vector<ext::shared_ptr<DefaultProbabilityHelper>> instruments;
for (Size i = 0; i < 4; i++) {
instruments.push_back(ext::make_shared<SpreadCdsHelper>(
handle(quoted_spreads[i]),
makeQuoteHandle(quoted_spreads[i]),
tenors[i], settlementDays, calendar, Quarterly, Following,
DateGeneration::TwentiethIMM, Actual365Fixed(),
recovery_rate, tsCurve));
Expand Down
2 changes: 1 addition & 1 deletion Examples/CVAIRS/CVAIRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int, char* []) {
vector<ext::shared_ptr<RateHelper>> swapHelpers;
for(Size i=0; i<sizeof(tenorsSwapMkt)/sizeof(Size); i++)
swapHelpers.push_back(ext::make_shared<SwapRateHelper>(
handle(ratesSwapmkt[i]),
makeQuoteHandle(ratesSwapmkt[i]),
tenorsSwapMkt[i] * Years,
TARGET(),
Quarterly,
Expand Down
4 changes: 2 additions & 2 deletions Examples/ConvertibleBonds/ConvertibleBonds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int main(int, char* []) {
auto exercise = ext::make_shared<EuropeanExercise>(exerciseDate);
auto amExercise = ext::make_shared<AmericanExercise>(settlementDate, exerciseDate);

auto underlyingH = handle(underlying);
auto underlyingH = makeQuoteHandle(underlying);

Handle<YieldTermStructure> flatTermStructure(
ext::make_shared<FlatForward>(settlementDate, riskFreeRate, dayCounter));
Expand All @@ -160,7 +160,7 @@ int main(int, char* []) {

Size timeSteps = 801;

auto creditSpread = handle(spreadRate);
auto creditSpread = makeQuoteHandle(spreadRate);

auto rate = ext::make_shared<SimpleQuote>(riskFreeRate);

Expand Down
2 changes: 1 addition & 1 deletion Examples/DiscreteHedging/DiscreteHedging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void ReplicationError::compute(Size nTimeSteps, Size nSamples)
Calendar calendar = TARGET();
Date today = Date::todaysDate();
DayCounter dayCount = Actual365Fixed();
auto stateVariable = handle(s0_);
auto stateVariable = makeQuoteHandle(s0_);
Handle<YieldTermStructure> riskFreeRate(
ext::make_shared<FlatForward>(today, r_, dayCount));
Handle<YieldTermStructure> dividendYield(
Expand Down
2 changes: 1 addition & 1 deletion Examples/EquityOption/EquityOption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int main(int, char* []) {

auto americanExercise = ext::make_shared<AmericanExercise>(settlementDate, maturity);

auto underlyingH = handle(underlying);
auto underlyingH = makeQuoteHandle(underlying);

// bootstrap the yield/dividend/vol curves
Handle<YieldTermStructure> flatTermStructure(
Expand Down
10 changes: 5 additions & 5 deletions Examples/Gaussian1dModels/Gaussian1dModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void printModelCalibration(

// here the main part of the code starts

int main(int argc, char *argv[]) {
int main(int, char *[]) {

try {

Expand All @@ -137,8 +137,8 @@ int main(int argc, char *argv[]) {
Real forward6mLevel = 0.025;
Real oisLevel = 0.02;

auto forward6mQuote = handle(forward6mLevel);
auto oisQuote = handle(oisLevel);
auto forward6mQuote = makeQuoteHandle(forward6mLevel);
auto oisQuote = makeQuoteHandle(oisLevel);

Handle<YieldTermStructure> yts6m(ext::make_shared<FlatForward>(
0, TARGET(), forward6mQuote, Actual365Fixed()));
Expand All @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
<< "\nat a level of " << forward6mLevel << std::endl;

Real volLevel = 0.20;
auto volQuote = handle(volLevel);
auto volQuote = makeQuoteHandle(volLevel);
Handle<SwaptionVolatilityStructure> swaptionVol(
ext::make_shared<ConstantSwaptionVolatility>(
0, TARGET(), ModifiedFollowing, volQuote, Actual365Fixed()));
Expand Down Expand Up @@ -482,7 +482,7 @@ int main(int argc, char *argv[]) {
"\npricing this using the LinearTsrPricer for CMS coupon "
"estimation" << std::endl;

auto reversionQuote = handle(reversion);
auto reversionQuote = makeQuoteHandle(reversion);

const Leg &leg0 = underlying4->leg(0);
const Leg &leg1 = underlying4->leg(1);
Expand Down
4 changes: 2 additions & 2 deletions ql/quotes/simplequote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ namespace QuantLib {
Real value_;
};

RelinkableHandle<Quote> handle(Real value);
RelinkableHandle<Quote> makeQuoteHandle(Real value);


// inline definitions

inline RelinkableHandle<Quote> handle(Real value) {
inline RelinkableHandle<Quote> makeQuoteHandle(Real value) {
return RelinkableHandle<Quote>(ext::make_shared<SimpleQuote>(value));
}

Expand Down
2 changes: 1 addition & 1 deletion ql/termstructures/bootstraphelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace QuantLib {

template <class TS>
BootstrapHelper<TS>::BootstrapHelper(Real quote)
: quote_(handle(quote)), termStructure_(nullptr) {}
: quote_(makeQuoteHandle(quote)), termStructure_(nullptr) {}

template <class TS>
void BootstrapHelper<TS>::setTermStructure(TS* t) {
Expand Down
28 changes: 14 additions & 14 deletions ql/termstructures/yield/ratehelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ namespace QuantLib {
const DayCounter& dayCounter,
Rate convAdj,
Futures::Type type)
: FuturesRateHelper(handle(price), iborStartDate, lengthInMonths, calendar,
convention, endOfMonth, dayCounter, handle(convAdj), type) {}
: FuturesRateHelper(makeQuoteHandle(price), iborStartDate, lengthInMonths, calendar,
convention, endOfMonth, dayCounter, makeQuoteHandle(convAdj), type) {}

FuturesRateHelper::FuturesRateHelper(const Handle<Quote>& price,
const Date& iborStartDate,
Expand Down Expand Up @@ -148,8 +148,8 @@ namespace QuantLib {
const DayCounter& dayCounter,
Rate convAdj,
Futures::Type type)
: FuturesRateHelper(handle(price), iborStartDate, iborEndDate, dayCounter,
handle(convAdj), type) {}
: FuturesRateHelper(makeQuoteHandle(price), iborStartDate, iborEndDate, dayCounter,
makeQuoteHandle(convAdj), type) {}

FuturesRateHelper::FuturesRateHelper(const Handle<Quote>& price,
const Date& iborStartDate,
Expand All @@ -174,7 +174,7 @@ namespace QuantLib {
const ext::shared_ptr<IborIndex>& index,
Rate convAdj,
Futures::Type type)
: FuturesRateHelper(handle(price), iborStartDate, index, handle(convAdj), type) {}
: FuturesRateHelper(makeQuoteHandle(price), iborStartDate, index, makeQuoteHandle(convAdj), type) {}

Real FuturesRateHelper::impliedQuote() const {
QL_REQUIRE(termStructure_ != nullptr, "term structure not set");
Expand Down Expand Up @@ -222,7 +222,7 @@ namespace QuantLib {
BusinessDayConvention convention,
bool endOfMonth,
const DayCounter& dayCounter)
: DepositRateHelper(handle(rate), tenor, fixingDays, calendar, convention,
: DepositRateHelper(makeQuoteHandle(rate), tenor, fixingDays, calendar, convention,
endOfMonth, dayCounter) {}

DepositRateHelper::DepositRateHelper(const Handle<Quote>& rate,
Expand All @@ -234,7 +234,7 @@ namespace QuantLib {

DepositRateHelper::DepositRateHelper(Rate rate,
const ext::shared_ptr<IborIndex>& i)
: DepositRateHelper(handle(rate), i) {}
: DepositRateHelper(makeQuoteHandle(rate), i) {}

Real DepositRateHelper::impliedQuote() const {
QL_REQUIRE(termStructure_ != nullptr, "term structure not set");
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace QuantLib {
Pillar::Choice pillarChoice,
Date customPillarDate,
bool useIndexedCoupon)
: FraRateHelper(handle(rate), monthsToStart, monthsToEnd, fixingDays, calendar,
: FraRateHelper(makeQuoteHandle(rate), monthsToStart, monthsToEnd, fixingDays, calendar,
convention, endOfMonth, dayCounter, pillarChoice, customPillarDate, useIndexedCoupon) {}

FraRateHelper::FraRateHelper(const Handle<Quote>& rate,
Expand All @@ -322,7 +322,7 @@ namespace QuantLib {
Pillar::Choice pillarChoice,
Date customPillarDate,
bool useIndexedCoupon)
: FraRateHelper(handle(rate), monthsToStart, i, pillarChoice, customPillarDate, useIndexedCoupon) {}
: FraRateHelper(makeQuoteHandle(rate), monthsToStart, i, pillarChoice, customPillarDate, useIndexedCoupon) {}

FraRateHelper::FraRateHelper(const Handle<Quote>& rate,
Period periodToStart,
Expand Down Expand Up @@ -359,7 +359,7 @@ namespace QuantLib {
Pillar::Choice pillarChoice,
Date customPillarDate,
bool useIndexedCoupon)
: FraRateHelper(handle(rate), periodToStart, lengthInMonths, fixingDays, calendar,
: FraRateHelper(makeQuoteHandle(rate), periodToStart, lengthInMonths, fixingDays, calendar,
convention, endOfMonth, dayCounter, pillarChoice, customPillarDate, useIndexedCoupon) {}

FraRateHelper::FraRateHelper(const Handle<Quote>& rate,
Expand Down Expand Up @@ -387,7 +387,7 @@ namespace QuantLib {
Pillar::Choice pillarChoice,
Date customPillarDate,
bool useIndexedCoupon)
: FraRateHelper(handle(rate), periodToStart, i, pillarChoice, customPillarDate, useIndexedCoupon) {}
: FraRateHelper(makeQuoteHandle(rate), periodToStart, i, pillarChoice, customPillarDate, useIndexedCoupon) {}

FraRateHelper::FraRateHelper(const Handle<Quote>& rate,
Natural immOffsetStart,
Expand All @@ -414,7 +414,7 @@ namespace QuantLib {
Pillar::Choice pillarChoice,
Date customPillarDate,
bool useIndexedCoupon)
: FraRateHelper(handle(rate), immOffsetStart, immOffsetEnd, i, pillarChoice,
: FraRateHelper(makeQuoteHandle(rate), immOffsetStart, immOffsetEnd, i, pillarChoice,
customPillarDate, useIndexedCoupon) {}

Real FraRateHelper::impliedQuote() const {
Expand Down Expand Up @@ -577,7 +577,7 @@ namespace QuantLib {
Date customPillarDate,
bool endOfMonth,
const ext::optional<bool>& useIndexedCoupons)
: SwapRateHelper(handle(rate), swapIndex, std::move(spread), fwdStart,
: SwapRateHelper(makeQuoteHandle(rate), swapIndex, std::move(spread), fwdStart,
std::move(discount), pillarChoice, customPillarDate, endOfMonth, useIndexedCoupons) {}

SwapRateHelper::SwapRateHelper(Rate rate,
Expand All @@ -595,7 +595,7 @@ namespace QuantLib {
Date customPillarDate,
bool endOfMonth,
const ext::optional<bool>& useIndexedCoupons)
: SwapRateHelper(handle(rate), tenor, calendar, fixedFrequency, fixedConvention,
: SwapRateHelper(makeQuoteHandle(rate), tenor, calendar, fixedFrequency, fixedConvention,
fixedDayCount, iborIndex, std::move(spread), fwdStart, std::move(discount), settlementDays,
pillarChoice, customPillarDate, endOfMonth, useIndexedCoupons) {}

Expand Down

0 comments on commit 30d6eb5

Please sign in to comment.