Skip to content

Commit

Permalink
Github issue [lballabio#1215] Use QL_DEPRECATE to deprecate averaging…
Browse files Browse the repository at this point in the history
…Method for SofrFutureRateHelper
  • Loading branch information
azsrz committed Nov 17, 2021
1 parent b780ed7 commit db29cf9
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 14 deletions.
55 changes: 49 additions & 6 deletions ql/termstructures/yield/overnightindexfutureratehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,21 @@ namespace QuantLib {
return future_->convexityAdjustment();
}

QL_DEPRECATED
SofrFutureRateHelper::SofrFutureRateHelper(
const Handle<Quote>& price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
const Handle<Quote>& convexityAdjustment,
[[deprecated("infer averaging method from frequency")]]
RateAveraging::Type averagingMethod)
: OvernightIndexFutureRateHelper(price,
getValidSofrStart(referenceMonth, referenceYear, referenceFreq),
getValidSofrEnd(referenceMonth, referenceYear, referenceFreq),
overnightIndex,
convexityAdjustment,
//averagingMethod
referenceFreq == Quarterly? RateAveraging::Compound : RateAveraging::Simple) {
averagingMethod) {
QL_REQUIRE(referenceFreq == Quarterly || referenceFreq == Monthly,
"only monthly and quarterly SOFR futures accepted");
if (referenceFreq == Quarterly) {
Expand All @@ -116,24 +115,45 @@ namespace QuantLib {
"quarterly SOFR futures can only start in Mar,Jun,Sep,Dec");
}
}

SofrFutureRateHelper::SofrFutureRateHelper(
const Handle<Quote>& price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
const Handle<Quote>& convexityAdjustment)
: OvernightIndexFutureRateHelper(price,
getValidSofrStart(referenceMonth, referenceYear, referenceFreq),
getValidSofrEnd(referenceMonth, referenceYear, referenceFreq),
overnightIndex,
convexityAdjustment,
referenceFreq == Quarterly ? RateAveraging::Compound : RateAveraging::Simple) {
QL_REQUIRE(referenceFreq == Quarterly || referenceFreq == Monthly,
"only monthly and quarterly SOFR futures accepted");
if (referenceFreq == Quarterly) {
QL_REQUIRE(referenceMonth == Mar || referenceMonth == Jun || referenceMonth == Sep ||
referenceMonth == Dec,
"quarterly SOFR futures can only start in Mar,Jun,Sep,Dec");
}
}

QL_DEPRECATED
SofrFutureRateHelper::SofrFutureRateHelper(
Real price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Real convexityAdjustment,
[[deprecated("infer averaging method from frequency")]]
RateAveraging::Type averagingMethod)
: OvernightIndexFutureRateHelper(
Handle<Quote>(ext::make_shared<SimpleQuote>(price)),
getValidSofrStart(referenceMonth, referenceYear, referenceFreq),
getValidSofrEnd(referenceMonth, referenceYear, referenceFreq),
overnightIndex,
Handle<Quote>(ext::make_shared<SimpleQuote>(convexityAdjustment)),
//averagingMethod
referenceFreq == Quarterly ? RateAveraging::Compound : RateAveraging::Simple) {
averagingMethod) {
QL_REQUIRE(referenceFreq == Quarterly || referenceFreq == Monthly,
"only monthly and quarterly SOFR futures accepted");
if (referenceFreq == Quarterly) {
Expand All @@ -143,4 +163,27 @@ namespace QuantLib {
}
}

SofrFutureRateHelper::SofrFutureRateHelper(
Real price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Real convexityAdjustment)
: OvernightIndexFutureRateHelper(
Handle<Quote>(ext::make_shared<SimpleQuote>(price)),
getValidSofrStart(referenceMonth, referenceYear, referenceFreq),
getValidSofrEnd(referenceMonth, referenceYear, referenceFreq),
overnightIndex,
Handle<Quote>(ext::make_shared<SimpleQuote>(convexityAdjustment)),
referenceFreq == Quarterly ? RateAveraging::Compound : RateAveraging::Simple) {
QL_REQUIRE(referenceFreq == Quarterly || referenceFreq == Monthly,
"only monthly and quarterly SOFR futures accepted");
if (referenceFreq == Quarterly) {
QL_REQUIRE(referenceMonth == Mar || referenceMonth == Jun || referenceMonth == Sep ||
referenceMonth == Dec,
"quarterly SOFR futures can only start in Mar,Jun,Sep,Dec");
}
}

}
24 changes: 18 additions & 6 deletions ql/termstructures/yield/overnightindexfutureratehelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,34 @@ namespace QuantLib {
*/
class SofrFutureRateHelper : public OvernightIndexFutureRateHelper {
public:
QL_DEPRECATED
SofrFutureRateHelper(const Handle<Quote>& price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
const Handle<Quote>& convexityAdjustment = Handle<Quote>(),
[[deprecated("infer averaging method from frequency")]]
RateAveraging::Type averagingMethod = RateAveraging::Compound);
const Handle<Quote>& convexityAdjustment,
RateAveraging::Type averagingMethod);
QL_DEPRECATED
SofrFutureRateHelper(Real price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Real convexityAdjustment = 0,
[[deprecated("infer averaging method from frequency")]]
RateAveraging::Type averagingMethod = RateAveraging::Compound);
Real convexityAdjustment,
RateAveraging::Type averagingMethod);
SofrFutureRateHelper(const Handle<Quote>& price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
const Handle<Quote>& convexityAdjustment = Handle<Quote>());
SofrFutureRateHelper(Real price,
Month referenceMonth,
Year referenceYear,
Frequency referenceFreq,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Real convexityAdjustment = 0);
};

}
Expand Down
2 changes: 1 addition & 1 deletion test-suite/sofrfutures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void SofrFuturesTest::testBootstrap() {
for (const auto& sofrQuote : sofrQuotes) {
helpers.push_back(ext::make_shared<SofrFutureRateHelper>(
sofrQuote.price, sofrQuote.month, sofrQuote.year, sofrQuote.freq,
index, 0.0, sofrQuote.averagingMethod));
index, 0.0));
}

ext::shared_ptr<PiecewiseYieldCurve<Discount, Linear> > curve =
Expand Down
22 changes: 21 additions & 1 deletion test-suite/testsuite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug (static runtime)|Win32'">QuantLib-test-suite-mt-sgd</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug (static runtime)|x64'">QuantLib-test-suite-x64-mt-sgd</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\Program Files\boost\boost_1_77_0</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\Program Files\boost\boost_1_77_0\stage\lib</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug (static runtime)|x64'">
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\Program Files\boost\boost_1_77_0</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\Program Files\boost\boost_1_77_0\stage\lib</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\Program Files\boost\boost_1_77_0</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\Program Files\boost\boost_1_77_0\stage\lib</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release (static runtime)|x64'">
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\Program Files\boost\boost_1_77_0</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\Program Files\boost\boost_1_77_0\stage\lib</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug (static runtime)|Win32'">
<Midl>
<TypeLibraryName>.\build\$(PlatformToolset)\$(Platform)\$(Configuration)\testsuite.tlb</TypeLibraryName>
Expand Down Expand Up @@ -975,4 +995,4 @@
<Import Project="..\Build.props" Condition="Exists('..\Build.props')" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

0 comments on commit db29cf9

Please sign in to comment.