Skip to content

Commit 9b65ab3

Browse files
author
francis.duffy@lseg.com
committed
Merge branch 'feature/no_std_format' into 'master'
Merge branch 'feature/ACADIAQPR-14061' into 'master' Closes ACADIAQPR-14061 See merge request app/app-51172/qs/ore-github!2
2 parents 09dd969 + d1f7d60 commit 9b65ab3

4 files changed

Lines changed: 53 additions & 28 deletions

File tree

OREData/ored/configuration/cdsvolcurveconfig.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <ored/utilities/parsers.hpp>
2323
#include <ored/utilities/to_string.hpp>
2424
#include <ql/errors.hpp>
25-
#include <format>
2625

2726
using ore::data::XMLUtils;
2827
using namespace QuantLib;
@@ -337,7 +336,7 @@ void CDSVolatilityCurveConfig::populateRequiredIds() const {
337336
string CDSVolatilityCurveConfig::quoteStem(MarketDatum::QuoteType quoteType) const
338337
{
339338
string name = !quoteName_.empty() ? quoteName_ : curveID_;
340-
return std::format("INDEX_CDS_OPTION/{}/{}/", to_string(quoteType), name);
339+
return "INDEX_CDS_OPTION/" + to_string(quoteType) + "/" + name + "/";
341340
}
342341

343342
void CDSVolatilityCurveConfig::validate(const string& checkSite) const

QuantExt/test/averageonindexedcoupon.cpp

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
// clang-format on
2424
#include <qle/cashflows/averageonindexedcoupon.hpp>
2525
#include <qle/cashflows/averageonindexedcouponpricer.hpp>
26-
#include <format>
2726
#include <oret/util/datapaths.hpp>
2827
#include <string>
28+
#include <sstream>
29+
#include <iomanip>
2930

3031
using namespace QuantLib;
3132
using namespace QuantExt;
@@ -71,10 +72,15 @@ BOOST_DATA_TEST_CASE(testCpnAccruals, idxCpnVariants, lb, os, ts, useApprox, rco
7172
#endif
7273
{
7374
// Create the coupon ID for output file.
74-
string strOs = os ? "os" : "nos";
75-
string strTs = ts ? "ts" : "nts";
76-
string strApprox = useApprox ? "approx" : "napprox";
77-
string cpnName = format("acc_{:02d}_lb-{}_{}_rco-{}_{}_{}", idx, lb, strOs, rco, strTs, strApprox);
75+
ostringstream oss;
76+
oss << "acc_"
77+
<< std::setw(2) << std::setfill('0') << idx
78+
<< "_lb-" << lb
79+
<< "_" << (os ? "os" : "nos")
80+
<< "_rco-" << rco
81+
<< "_" << (ts ? "ts" : "nts")
82+
<< "_" << (useApprox ? "approx" : "napprox");
83+
string cpnName = oss.str();
7884

7985
// Create the coupon.
8086
TestCouponData tcd;
@@ -110,12 +116,17 @@ BOOST_DATA_TEST_CASE(testCpnAccrualsGearingSpread, idxGsCpnVariants, gearing, sp
110116
#endif
111117
{
112118
// Create the coupon ID for output file, maintaining format of previous tests with additional fields.
113-
string strTs = ts ? "ts" : "nts";
114-
string strSibd = sibd ? "sibd" : "sih";
115-
string strEibd = eibd ? "eibd" : "eih";
116-
string strApprox = useApprox ? "approx" : "napprox";
117-
string cpnName = format("gs_{:02d}_lb-0_nos_rco-0_{}_g-{:g}_s-{:g}_{}_{}_{}",
118-
idx, strTs, gearing, spread, strSibd, strEibd, strApprox);
119+
ostringstream oss;
120+
oss << "gs_"
121+
<< std::setw(2) << std::setfill('0') << idx
122+
<< "_lb-0_nos_rco-0_"
123+
<< (ts ? "ts" : "nts")
124+
<< "_g-" << gearing
125+
<< "_s-" << spread
126+
<< "_" << (sibd ? "sibd" : "sih")
127+
<< "_" << (eibd ? "eibd" : "eih")
128+
<< "_" << (useApprox ? "approx" : "napprox");
129+
string cpnName = oss.str();
119130

120131
// Create the coupon.
121132
TestCouponData tcd;
@@ -143,8 +154,13 @@ BOOST_DATA_TEST_CASE(testCpnAccrualsAll, bdata::make({true, false}) ^ bdata::xra
143154
{
144155
// Create the coupon ID for output file, maintaining format of previous tests with additional fields.
145156
// fl-1 indicates fixing lag of 1 BD.
146-
string strApprox = useApprox ? "approx" : "napprox";
147-
string cpnName = format("all_{:02d}_lb-2_os_rco-3_nts_g-1p5_s-10_{}_sibd_eibd_fl-1", idx, strApprox);
157+
ostringstream oss;
158+
oss << "all_"
159+
<< std::setw(2) << std::setfill('0') << idx
160+
<< "_lb-2_os_rco-3_nts_g-1p5_s-10_"
161+
<< (useApprox ? "approx" : "napprox")
162+
<< "_sibd_eibd_fl-1";
163+
string cpnName = oss.str();
148164

149165
// Create the coupon.
150166
TestCouponData tcd;

QuantExt/test/onindexcouponutils.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <oret/util/fileutilities.hpp>
2121
#include <ql/quotes/simplequote.hpp>
2222
#include <qle/termstructures/interpolateddiscountcurve2.hpp>
23-
#include <format>
23+
#include <iomanip>
2424
#include <fstream>
2525

2626
namespace QuantExt {
@@ -114,6 +114,7 @@ void runCpnAccrualTest(const OvernightIndexedCouponBase& cpn, const path& outFil
114114
outFile << endl;
115115

116116
// Calculate and write the test results.
117+
outFile << std::fixed << std::setprecision(4);
117118
for (Date evalDate = startEvalDate; evalDate <= stopDate; ++evalDate) {
118119
Settings::instance().evaluationDate() = evalDate;
119120
outFile << io::iso_date(evalDate);
@@ -126,11 +127,11 @@ void runCpnAccrualTest(const OvernightIndexedCouponBase& cpn, const path& outFil
126127
loadFixingsUpToDate(evalDate, cpn.overnightIndex());
127128

128129
for (Date accDate = startAccDate; accDate <= stopDate; ++accDate) {
129-
outFile << "," << format("{:.4f}", cpn.accruedAmount(accDate));
130+
outFile << "," << cpn.accruedAmount(accDate);
130131
}
131132

132133
// Tag on the coupon amount as well.
133-
outFile << "," << format("{:.4f}", cpn.amount());
134+
outFile << "," << cpn.amount();
134135

135136
outFile << endl;
136137
}

QuantExt/test/overnightindexedcoupon.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#include <ql/time/calendars/unitedstates.hpp>
2525
#include <qle/cashflows/overnightindexedcoupon.hpp>
2626
#include <map>
27-
#include <format>
2827
#include <oret/util/datapaths.hpp>
2928
#include <string>
29+
#include <sstream>
30+
#include <iomanip>
3031

3132
using namespace QuantLib;
3233
using namespace QuantExt;
@@ -1957,9 +1958,13 @@ BOOST_DATA_TEST_CASE(testCpnAccruals, idxCpnVariants, lb, os, ts, rco, idx)
19571958
#endif
19581959
{
19591960
// Create the coupon ID for output file.
1960-
string strOs = os ? "os" : "nos";
1961-
string strTs = ts ? "ts" : "nts";
1962-
string cpnName = format("{:02d}_lb-{}_{}_rco-{}_{}", idx, lb, strOs, rco, strTs);
1961+
ostringstream oss;
1962+
oss << std::setw(2) << std::setfill('0') << idx
1963+
<< "_lb-" << lb
1964+
<< "_" << (os ? "os" : "nos")
1965+
<< "_rco-" << rco
1966+
<< "_" << (ts ? "ts" : "nts");
1967+
string cpnName = oss.str();
19631968

19641969
// Create the coupon.
19651970
TestCouponData tcd;
@@ -1988,12 +1993,16 @@ BOOST_DATA_TEST_CASE(testCpnAccrualsGearingSpread, idxGsCpnVariants, gearing, sp
19881993
#endif
19891994
{
19901995
// Create the coupon ID for output file, maintaining format of previous tests with additional fields.
1991-
string strTs = ts ? "ts" : "nts";
1992-
string strIncSpr = incSpr ? "inc-spr" : "exc-spr";
1993-
string strSibd = sibd ? "sibd" : "sih";
1994-
string strEibd = eibd ? "eibd" : "eih";
1995-
string cpnName = format("{:02d}_lb-0_nos_rco-0_{}_g-{:g}_s-{:g}_{}_{}_{}",
1996-
idx, strTs, gearing, spread, strIncSpr, strSibd, strEibd);
1996+
ostringstream oss;
1997+
oss << std::setw(2) << std::setfill('0') << idx
1998+
<< "_lb-0_nos_rco-0_"
1999+
<< (ts ? "ts" : "nts")
2000+
<< "_g-" << gearing
2001+
<< "_s-" << spread
2002+
<< "_" << (incSpr ? "inc-spr" : "exc-spr")
2003+
<< "_" << (sibd ? "sibd" : "sih")
2004+
<< "_" << (eibd ? "eibd" : "eih");
2005+
string cpnName = oss.str();
19972006

19982007
// Create the coupon.
19992008
TestCouponData tcd;

0 commit comments

Comments
 (0)