Skip to content

Commit c22aac7

Browse files
author
jenkins
committed
git subrepo pull (merge) ore
subrepo: subdir: "ore" merged: "66740acd65" upstream: origin: "git@gitlab.acadiasoft.net:qs/ore.git" branch: "master" commit: "d094edfc70" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb"
2 parents 229d424 + d094edf commit c22aac7

7 files changed

Lines changed: 4463 additions & 4450 deletions

File tree

Examples/Example_15/ExpectedOutput/scenario.csv

Lines changed: 4423 additions & 4423 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#TradeId,TradeType,Maturity,MaturityTime,NPV,NpvCurrency,NPV(Base),BaseCurrency,Notional,NotionalCurrency,Notional(Base),NettingSet,CounterParty
2-
CommodityForward_Gold_1Y,CommodityForward,2017-02-05,1.000262,1398.707538,USD,1398.707538,USD,1160593.33,USD,1160593.33,CPTY_A,CPTY_A
2+
CommodityForward_Gold_1Y,CommodityForward,2017-02-05,1.000262,1398.707538,USD,1398.707538,USD,1162000.0,USD,1162000.0,CPTY_A,CPTY_A
33
CommodityForward_Gold_Apr_17,CommodityForward,2017-04-28,1.224920,0.000000,USD,0.000000,USD,580900.00,USD,580900.00,CPTY_A,CPTY_A
4-
CommodityForward_WTI_2Y,CommodityForward,2018-02-05,2.000262,-1669620.658788,USD,-1669620.658788,USD,44308571.43,USD,44308571.43,CPTY_A,CPTY_A
4+
CommodityForward_WTI_2Y,CommodityForward,2018-02-05,2.000262,-1669620.658788,USD,-1669620.658788,USD,46000000.0,USD,46000000.0,CPTY_A,CPTY_A
55
CommodityForward_WTI_Oct_21,CommodityForward,2021-10-31,5.734509,0.000000,USD,0.000000,USD,24875000.00,USD,24875000.00,CPTY_A,CPTY_A
66
CommodityOption_WTI_Oct_21,CommodityOption,2021-10-31,5.734509,2399271.748696,USD,2399271.748696,USD,24875000.00,USD,24875000.00,CPTY_A,CPTY_A
77
CommodityOption_Gold_Apr_17,CommodityOption,2017-04-28,1.224920,-23531.459416,USD,-23531.459416,USD,580900.00,USD,580900.00,CPTY_A,CPTY_A

OREAnalytics/orea/app/reportwriter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,8 +1075,8 @@ void ReportWriter::writeScenarioReport(ore::data::Report& report,
10751075
report.addColumn("Factor", string());
10761076
report.addColumn("Up/Down", string());
10771077
report.addColumn("Base NPV", double(), 2);
1078-
// report.addColumn("ShiftSize_1", double(), 6);
1079-
// report.addColumn("ShiftSize_2", double(), 6);
1078+
report.addColumn("ShiftSize_1", double(), 6);
1079+
report.addColumn("ShiftSize_2", double(), 6);
10801080
report.addColumn("Scenario NPV", double(), 2);
10811081
report.addColumn("Difference", double(), 2);
10821082

@@ -1092,20 +1092,20 @@ void ReportWriter::writeScenarioReport(ore::data::Report& report,
10921092
for (const auto& [j, scenarioNpv] : npvCube->getTradeNPVs(i)) {
10931093
auto scenarioDescription = scenarioDescriptions[j];
10941094
Real difference = scenarioNpv - baseNpv;
1095-
// Real shift1 = scenarioDescription.key1().keytype == RiskFactorKey::KeyType::None
1096-
// ? Null<Real>()
1097-
// : sensitivityCube->actualShiftSize(scenarioDescription.key1());
1098-
// Real shift2 = scenarioDescription.key2().keytype == RiskFactorKey::KeyType::None
1099-
// ? Null<Real>()
1100-
// : sensitivityCube->actualShiftSize(scenarioDescription.key2());
1095+
Real shift1 = scenarioDescription.key1().keytype == RiskFactorKey::KeyType::None
1096+
? Null<Real>()
1097+
: sensitivityCube->actualShiftSize(scenarioDescription.key1());
1098+
Real shift2 = scenarioDescription.key2().keytype == RiskFactorKey::KeyType::None
1099+
? Null<Real>()
1100+
: sensitivityCube->actualShiftSize(scenarioDescription.key2());
11011101
if (fabs(difference) > outputThreshold) {
11021102
report.next();
11031103
report.add(tradeId);
11041104
report.add(prettyPrintInternalCurveName(scenarioDescription.factors()));
11051105
report.add(scenarioDescription.typeString());
11061106
report.add(baseNpv);
1107-
// report.add(shift1);
1108-
// report.add(shift2);
1107+
report.add(shift1);
1108+
report.add(shift2);
11091109
report.add(scenarioNpv);
11101110
report.add(difference);
11111111
} else if (!std::isfinite(difference)) {

OREData/ored/portfolio/commodityforward.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void CommodityForward::build(const boost::shared_ptr<EngineFactory>& engineFacto
148148
npvCurrency_ = fixingDate_==Date() ? currency_ : payCcy_;
149149

150150
// notional_ = strike_ * quantity_;
151-
notional_ = Null<Real>(); // is handled by override of notional()
151+
notional_ = strike_ * quantity_;
152152
notionalCurrency_ = currency_;
153153

154154
additionalData_["quantity"] = quantity_;
@@ -168,17 +168,7 @@ void CommodityForward::build(const boost::shared_ptr<EngineFactory>& engineFacto
168168
additionalData_["isdaTransaction"] = string("");
169169
}
170170

171-
Real CommodityForward::notional() const {
172-
// try to get the notional from the additional results of the instrument
173-
try {
174-
return instrument_->qlInstrument(true)->result<Real>("currentNotional");
175-
} catch (const std::exception& e) {
176-
if (strcmp(e.what(), "currentNotional not provided"))
177-
ALOG("error when retrieving notional: " << e.what());
178-
}
179-
// if not provided, return null
180-
return Null<Real>();
181-
}
171+
Real CommodityForward::notional() const { return notional_; }
182172

183173
std::map<AssetClass, std::set<std::string>>
184174
CommodityForward::underlyingIndices(const boost::shared_ptr<ReferenceDataManager>& referenceDataManager) const {

Tools/PythonTools/Readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Each object under a given key, `file_name`, has the following format (note that
2222
"optional_cols": [
2323
"col4"
2424
]
25+
"require_equal_optional_cols": false,
2526
"rename_cols": {
2627
"A": "a",
2728
"B": "b",
@@ -84,6 +85,7 @@ For `csv_settings`:
8485
- The `keys` specify which columns will be used as keys for the comparison. The comparison fails if all of these keys are not in both files to be compared.
8586
- The `use_cols` specifies on which columns the actual comparisons are evaluated.
8687
- The `optional_cols`, as with `use_cols` above, specifies columns on which comparisons are evaluated, but these columns are only included if they are present in both files. If they are not present in either file or if present in one file nad not the other, the corresponding comparison defined in `column_settings` below will not be evaluated for the missing column/s.
88+
- The 'require_equal_optional_cols' specifies whether the test is failed if the optional columns are not all present in both files or not all absent in both files. It defaults to true if not given. In this case it is not allowed that an optional column is present in one file but not the other.
8789
- The `rename_cols` object specifies columns that should be renamed before the comparison is performed. In the example above, `A` would be renamed to `a` etc.
8890
- The `col_types` object allows you to explicitly specify the type of a given set of columns if necessary.
8991
- The `drop_rows` object allows you to specify a threshold for the values in a given set of columns. If the absolute value for a given row, in one of the specified columns, is below the threshold, the row is dropped from the comparison.

Tools/PythonTools/compare_files.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,23 @@ def compare_files_df(name, file_1, file_2, config):
401401
optional_cols = copy.deepcopy(config['optional_cols'])
402402
logger.debug('Optional columns found: %s', str (optional_cols))
403403

404-
# Check that each optional col either exists in both DataFrames, or is missing in both. Otherwise, we fail the test.
404+
# Check that each optional col either exists in both DataFrames, or is missing in both. Otherwise, we fail the test
405+
# if require_equal_optional_cols is true (or not given)
405406
missing_ocols = []
406407
for col in optional_cols:
407408
if (col in df_1.columns and col not in df_2.columns) or (col not in df_1.columns and col in df_2.columns):
408409
missing_ocols.append(col)
409410
if missing_ocols:
410411
logger.warning('The columns, %s, are in one Dataframe but not the other.', str(missing_ocols))
411-
return False
412+
if 'require_equal_optional_cols' in config:
413+
if config['require_equal_optional_cols']:
414+
logger.warning('Failing test, because require_equal_optional_cols is true')
415+
return False
416+
else:
417+
logger.warning('Ignore unequal optional cols, because because require_equal_optional_cols is false')
418+
else:
419+
logger.warning('Failing test, because require_equal_optional_cols is not given, defaults to true')
420+
return False
412421

413422
# For each optional col, check whether it is found in each DataFrame. If so, add it.
414423
for col in optional_cols:

Tools/PythonTools/comparison_config.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,24 @@
912912
"Factor",
913913
"Up/Down"
914914
],
915+
"use_cols": [
916+
"Base NPV",
917+
"Scenario NPV",
918+
"Difference"
919+
],
920+
"optional_cols": [
921+
"ShiftSize_1",
922+
"ShiftSize_2"
923+
],
924+
"require_equal_optional_cols": false,
915925
"column_settings": [
916926
{
917927
"names": [
918928
"Base NPV",
919929
"Scenario NPV",
920-
"Difference"
930+
"Difference",
931+
"ShiftSize_1",
932+
"ShiftSize_2"
921933
],
922934
"abs_tol": 1e-2,
923935
"rel_tol": 1e-12

0 commit comments

Comments
 (0)