Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
PNLCalculator Class Reference

#include <orea/engine/historicalsensipnlcalculator.hpp>

+ Inheritance diagram for PNLCalculator:
+ Collaboration diagram for PNLCalculator:

Public Types

using TradePnLStore = std::vector< std::vector< QuantLib::Real > >
 

Public Member Functions

 PNLCalculator (ore::data::TimePeriod pnlPeriod)
 
virtual ~PNLCalculator ()
 
virtual void writePNL (QuantLib::Size scenarioIdx, bool isCall, const RiskFactorKey &key_1, QuantLib::Real shift_1, QuantLib::Real delta, QuantLib::Real gamma, QuantLib::Real deltaPnl, Real gammaPnl, const RiskFactorKey &key_2=RiskFactorKey(), QuantLib::Real shift_2=0.0, const std::string &tradeId="")
 
const bool isInTimePeriod (QuantLib::Date startDate, QuantLib::Date endDate)
 
void populatePNLs (const std::vector< QuantLib::Real > &allPnls, const std::vector< QuantLib::Real > &foPnls, const std::vector< QuantLib::Date > &startDates, const std::vector< QuantLib::Date > &endDates)
 
void populateTradePNLs (const TradePnLStore &allPnls, const TradePnLStore &foPnls)
 
const std::vector< QuantLib::Real > & pnls ()
 
const std::vector< QuantLib::Real > & foPnls ()
 
const TradePnLStoretradePnls ()
 
const TradePnLStorefoTradePnls ()
 
void clear ()
 

Protected Attributes

std::vector< QuantLib::Real > pnls_
 
std::vector< QuantLib::Real > foPnls_
 
ore::data::TimePeriod pnlPeriod_
 
TradePnLStore tradePnls_
 
TradePnLStore foTradePnls_
 

Detailed Description

Definition at line 49 of file historicalsensipnlcalculator.hpp.

Member Typedef Documentation

◆ TradePnLStore

using TradePnLStore = std::vector<std::vector<QuantLib::Real> >

Definition at line 63 of file historicalsensipnlcalculator.hpp.

Constructor & Destructor Documentation

◆ PNLCalculator()

Definition at line 51 of file historicalsensipnlcalculator.hpp.

51: pnlPeriod_(pnlPeriod) {}

◆ ~PNLCalculator()

virtual ~PNLCalculator ( )
virtual

Definition at line 52 of file historicalsensipnlcalculator.hpp.

52{}

Member Function Documentation

◆ writePNL()

virtual void writePNL ( QuantLib::Size  scenarioIdx,
bool  isCall,
const RiskFactorKey key_1,
QuantLib::Real  shift_1,
QuantLib::Real  delta,
QuantLib::Real  gamma,
QuantLib::Real  deltaPnl,
Real  gammaPnl,
const RiskFactorKey key_2 = RiskFactorKey(),
QuantLib::Real  shift_2 = 0.0,
const std::string &  tradeId = "" 
)
virtual

Definition at line 53 of file historicalsensipnlcalculator.hpp.

57 {}

◆ isInTimePeriod()

const bool isInTimePeriod ( QuantLib::Date  startDate,
QuantLib::Date  endDate 
)

Definition at line 155 of file historicalsensipnlcalculator.cpp.

155 {
156 return pnlPeriod_.contains(startDate) && pnlPeriod_.contains(endDate);
157}
bool contains(const Date &d) const
+ Here is the call graph for this function:

◆ populatePNLs()

void populatePNLs ( const std::vector< QuantLib::Real > &  allPnls,
const std::vector< QuantLib::Real > &  foPnls,
const std::vector< QuantLib::Date > &  startDates,
const std::vector< QuantLib::Date > &  endDates 
)

Definition at line 130 of file historicalsensipnlcalculator.cpp.

133 {
134 QL_REQUIRE(allPnls.size() == allFoPnls.size(), "PNLs and first order PNLs must be the same size");
135
136 pnls_.reserve(allPnls.size());
137 foPnls_.reserve(allPnls.size());
138
139 for (Size i = 0; i < allPnls.size(); i++) {
140 // Backtesting P&L vectors
141 if (pnlPeriod_.contains(startDates[i]) && pnlPeriod_.contains(endDates[i])) {
142 pnls_.push_back(allPnls[i]);
143 foPnls_.push_back(allFoPnls[i]);
144 }
145 }
146 pnls_.shrink_to_fit();
147 foPnls_.shrink_to_fit();
148}
std::vector< QuantLib::Real > foPnls_
+ Here is the call graph for this function:

◆ populateTradePNLs()

void populateTradePNLs ( const TradePnLStore allPnls,
const TradePnLStore foPnls 
)

Definition at line 150 of file historicalsensipnlcalculator.cpp.

150 {
151 tradePnls_ = allPnls;
153}
const std::vector< QuantLib::Real > & foPnls()
+ Here is the call graph for this function:

◆ pnls()

const std::vector< QuantLib::Real > & pnls ( )

Definition at line 66 of file historicalsensipnlcalculator.hpp.

66{ return pnls_; };

◆ foPnls()

const std::vector< QuantLib::Real > & foPnls ( )

Definition at line 67 of file historicalsensipnlcalculator.hpp.

67{ return foPnls_; };
+ Here is the caller graph for this function:

◆ tradePnls()

const TradePnLStore & tradePnls ( )

Definition at line 69 of file historicalsensipnlcalculator.hpp.

69{ return tradePnls_; }

◆ foTradePnls()

const TradePnLStore & foTradePnls ( )

Definition at line 70 of file historicalsensipnlcalculator.hpp.

70{ return foTradePnls_; }

◆ clear()

void clear ( )

Definition at line 72 of file historicalsensipnlcalculator.hpp.

72 {
73 pnls_.clear();
74 foPnls_.clear();
75 tradePnls_.clear();
76 foTradePnls_.clear();
77 }

Member Data Documentation

◆ pnls_

std::vector<QuantLib::Real> pnls_
protected

Definition at line 80 of file historicalsensipnlcalculator.hpp.

◆ foPnls_

std::vector<QuantLib::Real> foPnls_
protected

Definition at line 81 of file historicalsensipnlcalculator.hpp.

◆ pnlPeriod_

ore::data::TimePeriod pnlPeriod_
protected

Definition at line 82 of file historicalsensipnlcalculator.hpp.

◆ tradePnls_

TradePnLStore tradePnls_
protected

Definition at line 83 of file historicalsensipnlcalculator.hpp.

◆ foTradePnls_

TradePnLStore foTradePnls_
protected

Definition at line 83 of file historicalsensipnlcalculator.hpp.