24#include <boost/accumulators/accumulators.hpp>
25#include <boost/accumulators/statistics.hpp>
26#include <boost/accumulators/statistics/tail_quantile.hpp>
28using namespace boost::accumulators;
36 const std::string& baseCurrency,
const QuantLib::ext::shared_ptr<Portfolio>& portfolio,
37 const string& portfolioFilter,
const vector<Real>& p, boost::optional<TimePeriod> period,
38 const ext::shared_ptr<HistoricalScenarioGenerator>& hisScenGen, std::unique_ptr<FullRevalArgs> fullRevalArgs,
40 :
VarReport(baseCurrency, portfolio, portfolioFilter, p, period, hisScenGen, nullptr, std::move(fullRevalArgs)) {
49 const ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
50 const ext::shared_ptr<TradeGroupBase>& tradeGroup) {
55 const set<pair<string, Size>>& tradeIds) {
58 Size c =
static_cast<Size
>(std::floor(
pnls_.size() * (1.0 - confidence) + 0.5)) + 2;
59 typedef accumulator_set<double, stats<boost::accumulators::tag::tail_quantile<boost::accumulators::right>>>
61 accumulator acc(boost::accumulators::tag::tail<boost::accumulators::right>::cache_size = c);
63 for (
const auto& pnl :
pnls_) {
64 acc(isCall ? pnl : -pnl);
67 return quantile(acc, quantile_probability = confidence);
QuantLib::Real var(QuantLib::Real confidence, const bool isCall=true, const std::set< std::pair< std::string, QuantLib::Size > > &tradeIds={}) override
const std::vector< QuantLib::Real > & pnls_
std::vector< QuantLib::Real > pnls_
void createVarCalculator() override
HistoricalSimulationVarReport(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< FullRevalArgs > fullRevalArgs=nullptr, const bool breakdown=false)
void handleFullRevalResults(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) override
boost::optional< ore::data::TimePeriod > period_
std::set< std::pair< std::string, QuantLib::Size > > tradeIdIdxPairs_
QuantLib::ext::shared_ptr< ore::analytics::HistoricalPnlGenerator > histPnlGen_
QuantLib::ext::shared_ptr< VarCalculator > varCalculator_
Class for generating portfolio P&Ls based on historical scenarios.
Perform historical simulation var calculation for a given portfolio.
A cube implementation that stores the cube in memory.