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

#include <orea/engine/varcalculator.hpp>

+ Inheritance diagram for VarReport:
+ Collaboration diagram for VarReport:

Public Member Functions

 VarReport (const std::string &baseCurrency, const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const std::string &portfolioFilter, const vector< Real > &p, boost::optional< ore::data::TimePeriod > period, const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hisScenGen=nullptr, std::unique_ptr< SensiRunArgs > sensiArgs=nullptr, std::unique_ptr< FullRevalArgs > fullRevalArgs=nullptr, const bool breakdown=false)
 
void createReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) override
 
const std::vector< Real > & p () const
 
- Public Member Functions inherited from MarketRiskReport
 MarketRiskReport (const std::string &calculationCurrency, const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const std::string &portfolioFilter, boost::optional< ore::data::TimePeriod > period, const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hisScenGen=nullptr, std::unique_ptr< SensiRunArgs > sensiArgs=nullptr, std::unique_ptr< FullRevalArgs > fullRevalArgs=nullptr, std::unique_ptr< MultiThreadArgs > multiThreadArgs=nullptr, const bool breakdown=false, const bool requireTradePnl=false)
 
virtual ~MarketRiskReport ()
 
virtual void initialise ()
 
void initSimMarket ()
 Method to init simMarket_ for multi-threaded ctors. More...
 
virtual void calculate (const QuantLib::ext::shared_ptr< Reports > &report)
 
void enableCubeWrite (const std::string &cubeDir, const std::string &cubeFilename)
 
- Public Member Functions inherited from ProgressReporter
 ProgressReporter ()
 
void registerProgressIndicator (const QuantLib::ext::shared_ptr< ProgressIndicator > &indicator)
 
void unregisterProgressIndicator (const QuantLib::ext::shared_ptr< ProgressIndicator > &indicator)
 
void unregisterAllProgressIndicators ()
 
void updateProgress (const unsigned long progress, const unsigned long total, const std::string &detail="")
 
void resetProgress ()
 
const std::set< QuantLib::ext::shared_ptr< ProgressIndicator > > & progressIndicators () const
 

Protected Member Functions

virtual void createVarCalculator ()=0
 
void writeReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &report, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) override
 
std::vector< ore::data::TimePeriodtimePeriods () override
 
- Protected Member Functions inherited from MarketRiskReport
virtual void initialiseRiskGroups ()
 Method for shared initialisation. More...
 
virtual void registerProgressIndicators ()
 
virtual void createReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)=0
 
virtual bool runTradeDetail (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)
 
virtual QuantLib::ext::shared_ptr< ScenarioFiltercreateScenarioFilter (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup)
 
virtual void reset (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup)
 
virtual bool runTradeRiskGroup (const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
 
virtual bool disablesAll (const QuantLib::ext::shared_ptr< ScenarioFilter > &filter) const
 
virtual void updateFilter (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< ScenarioFilter > &filter)
 update any filters required More...
 
virtual std::string portfolioId (const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) const
 
virtual std::string tradeGroupKey (const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) const
 
virtual ore::data::TimePeriod covariancePeriod () const
 
virtual void addPnlCalculators (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)
 
virtual void handleSensiResults (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &report, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)
 
virtual void handleFullRevalResults (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)
 
virtual bool includeDeltaMargin (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
 
virtual bool includeGammaMargin (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
 
virtual bool runFullReval (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
 
virtual bool generateCube (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
 
virtual std::string cubeFilePath (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
 
virtual std::vector< ore::data::TimePeriodtimePeriods ()
 
virtual void writeReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)
 
virtual void closeReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)
 

Protected Attributes

QuantLib::ext::shared_ptr< VarCalculatorvarCalculator_
 
- Protected Attributes inherited from MarketRiskReport
bool sensiBased_ = false
 
bool fullReval_ = false
 
std::string calculationCurrency_
 
QuantLib::ext::shared_ptr< Portfolioportfolio_
 
std::string portfolioFilter_
 
boost::optional< ore::data::TimePeriodperiod_
 
QuantLib::ext::shared_ptr< HistoricalScenarioGeneratorhisScenGen_
 
std::unique_ptr< SensiRunArgssensiArgs_
 
std::unique_ptr< FullRevalArgsfullRevalArgs_
 
std::unique_ptr< MultiThreadArgsmultiThreadArgs_
 
bool breakdown_ = false
 
bool requireTradePnl_ = false
 
QuantLib::ext::shared_ptr< MarketRiskGroupBaseContainerriskGroups_
 
QuantLib::ext::shared_ptr< TradeGroupBaseContainertradeGroups_
 
std::map< std::string, std::set< std::pair< std::string, QuantLib::Size > > > tradeIdGroups_
 
std::set< std::pair< std::string, QuantLib::Size > > tradeIdIdxPairs_
 
std::vector< std::string > tradeIds_
 
std::map< RiskFactorKey, QuantLib::Real > deltas_
 
std::map< std::pair< RiskFactorKey, RiskFactorKey >, QuantLib::Real > gammas_
 
QuantLib::Matrix covarianceMatrix_
 
bool writePnl_ = false
 
std::vector< QuantLib::ext::shared_ptr< PNLCalculator > > pnlCalculators_
 
QuantLib::ext::shared_ptr< QuantExt::CovarianceSalvagesalvage_
 
bool includeDeltaMargin_ = true
 
bool includeGammaMargin_ = true
 
QuantLib::ext::shared_ptr< ore::data::EngineFactoryfactory_
 
QuantLib::ext::shared_ptr< ore::analytics::HistoricalPnlGeneratorhistPnlGen_
 
QuantLib::ext::shared_ptr< HistoricalSensiPnlCalculatorsensiPnlCalculator_
 

Private Attributes

std::vector< Real > p_
 

Detailed Description

Definition at line 42 of file varcalculator.hpp.

Constructor & Destructor Documentation

◆ VarReport()

VarReport ( const std::string &  baseCurrency,
const QuantLib::ext::shared_ptr< Portfolio > &  portfolio,
const std::string &  portfolioFilter,
const vector< Real > &  p,
boost::optional< ore::data::TimePeriod period,
const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &  hisScenGen = nullptr,
std::unique_ptr< SensiRunArgs sensiArgs = nullptr,
std::unique_ptr< FullRevalArgs fullRevalArgs = nullptr,
const bool  breakdown = false 
)

Definition at line 25 of file varcalculator.cpp.

29 : MarketRiskReport(baseCurrency, portfolio, portfolioFilter, period, hisScenGen, std::move(sensiArgs), std::move(fullRevalArgs), nullptr, breakdown), p_(p) {
30}
MarketRiskReport(const std::string &calculationCurrency, const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const std::string &portfolioFilter, boost::optional< ore::data::TimePeriod > period, const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hisScenGen=nullptr, std::unique_ptr< SensiRunArgs > sensiArgs=nullptr, std::unique_ptr< FullRevalArgs > fullRevalArgs=nullptr, std::unique_ptr< MultiThreadArgs > multiThreadArgs=nullptr, const bool breakdown=false, const bool requireTradePnl=false)
std::vector< Real > p_
const std::vector< Real > & p() const

Member Function Documentation

◆ createReports()

void createReports ( const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &  reports)
overridevirtual

Implements MarketRiskReport.

Definition at line 32 of file varcalculator.cpp.

32 {
33 QL_REQUIRE(reports->reports().size() == 1, "We should only report for VAR report");
34 QuantLib::ext::shared_ptr<Report> report = reports->reports().at(0);
35 // prepare report
36 report->addColumn("Portfolio", string()).addColumn("RiskClass", string()).addColumn("RiskType", string());
37 for (Size i = 0; i < p_.size(); ++i)
38 report->addColumn("Quantile_" + std::to_string(p_[i]), double(), 6);
39
41}
virtual void createVarCalculator()=0
+ Here is the call graph for this function:

◆ p()

const std::vector< Real > & p ( ) const

Definition at line 54 of file varcalculator.hpp.

54{ return p_; }
+ Here is the caller graph for this function:

◆ createVarCalculator()

virtual void createVarCalculator ( )
protectedpure virtual

Implemented in HistoricalSimulationVarReport, and ParametricVarReport.

+ Here is the caller graph for this function:

◆ writeReports()

void writeReports ( const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &  report,
const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &  riskGroup,
const QuantLib::ext::shared_ptr< TradeGroupBase > &  tradeGroup 
)
overrideprotectedvirtual

Reimplemented from MarketRiskReport.

Definition at line 43 of file varcalculator.cpp.

45 {
46
47 QL_REQUIRE(reports->reports().size() == 1, "We should only report for VAR report");
48 QuantLib::ext::shared_ptr<Report> report = reports->reports().at(0);
49
50 auto rg = ext::dynamic_pointer_cast<MarketRiskGroup>(riskGroup);
51 auto tg = ext::dynamic_pointer_cast<TradeGroup>(tradeGroup);
52
53 std::vector<Real> var;
54 auto quantiles = p();
55 for (auto q : quantiles)
56 var.push_back(varCalculator_->var(q));
57
58 if (!close_enough(QuantExt::detail::absMax(var), 0.0)) {
59 report->next();
60 report->add(tg->portfolioId());
61 report->add(to_string(rg->riskClass()));
62 report->add(to_string(rg->riskType()));
63 for (auto const& v : var)
64 report->add(v);
65 }
66}
QuantLib::ext::shared_ptr< VarCalculator > varCalculator_
Real absMax(const A &a)
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
std::string to_string(const LocationInfo &l)
+ Here is the call graph for this function:

◆ timePeriods()

std::vector< ore::data::TimePeriod > timePeriods ( )
overrideprotectedvirtual

Reimplemented from MarketRiskReport.

Definition at line 64 of file varcalculator.hpp.

64{ return {period_.get()}; }
boost::optional< ore::data::TimePeriod > period_

Member Data Documentation

◆ varCalculator_

QuantLib::ext::shared_ptr<VarCalculator> varCalculator_
protected

Definition at line 57 of file varcalculator.hpp.

◆ p_

std::vector<Real> p_
private

Definition at line 67 of file varcalculator.hpp.