Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
collateralaccount.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file orea/aggregation/collateralaccount.hpp
20 \brief Collateral Account Balance (stored in base currency)
21 \ingroup analytics
22*/
23
24#pragma once
25
28
29#include <ql/time/date.hpp>
30
31#include <ql/shared_ptr.hpp>
32
33namespace ore {
34namespace analytics {
35using namespace QuantLib;
36using namespace data;
37
38//! Collateral Account
39/*!
40 This class holds information corresponding to collateral cash accounts.
41 It stores a balance as well as an asof date for the balance. The class
42 also includes "margin" information relating to the most recent margin
43 call (e.g. call amount, status, expected pay date.
44
45 The idea is that this class can be updated on-the-run with new margin
46 requirements and collateral balances, and the timestamps updated
47 accordingly.
48
49 For further information refer to the detailed ORE documentation.
50
51 \ingroup analytics
52*/
54public:
55 //! Default constructor
57 //! Constructor assuming initial collateral account balance is zero
58 CollateralAccount( //! CSA details including threshold, minimum transfer amount, margining frequency etc
59 const QuantLib::ext::shared_ptr<NettingSetDefinition>& csaDef,
60 //! Today's date
61 const Date& date_t0);
62 //! Constructor taking an initial collateral account balance
63 CollateralAccount( //! CSA details including threshold, minimum transfer amount, margining frequency etc
64 const QuantLib::ext::shared_ptr<NettingSetDefinition>& csaDef,
65 //! Initial collateral account balance
66 const Real& balance_t0,
67 //! Today's date
68 const Date& date_t0);
69
70 //! Margin Call
71 /*!
72 This class is essentially a container for open margin call details
73
74 \ingroup analytics
75 */
76 class MarginCall {
77 public:
78 MarginCall(const Real& marginFlowAmount, const Date& marginPayDate, const Date& marginRequestDate,
79 const bool& openMarginRequest = true)
82
83 //! Inspectors
84 //@{
85 /*! check if there is an outstanding margin call awaiting agreement/settlement */
86 bool openMarginRequest() const { return openMarginRequest_; }
87 /*! open margin request amount (+ -> call, - -> post) */
88 Real marginAmount() const { return marginFlowAmount_; }
89 /*! expected payment date of outstanding collateral margin */
90 Date marginPayDate() const { return marginPayDate_; }
91 /*! The date at which the outstanding margin was requested */
92 Date marginRequestDate() const { return marginRequestDate_; }
93 //@}
94
95 private:
100 };
101
102 //! Inspectors
103 //@{
104 /*! csa (netting set) definition */
105 QuantLib::ext::shared_ptr<NettingSetDefinition> csaDef() const { return csaDef_; }
106 /*! account balance at start date */
107 Real balance_t0() const { return balance_t0_; }
108 /*! most up-to-date account balance */
109 Real accountBalance() const { return accountBalances_.back(); }
110 /*! account balance as of requested date */
111 Real accountBalance(const Date& date) const;
112 /*! most recent account balance reset date */
113 Date balanceDate() const { return accountDates_.back(); }
114 //@}
115
116 /*!
117 Returns the sum of all outstanding margin call amounts
118 */
119 Real outstandingMarginAmount(const Date& simulationDate) const;
120
121 /*!
122 Updates the account balance, does this by checking if
123 any outstanding margin calls are due for settlement.
124
125 \note The accrual rate is assumed to be compounded daily
126 */
127 void updateAccountBalance(const Date& simulationDate, const Real& annualisedZeroRate = 0.0);
128 /*!
129 Updates the margin call details for this account
130 */
131 void updateMarginCall(const MarginCall& newMarginCall);
132 void updateMarginCall(const Real& marginFlowAmount, const Date& marginPayDate, const Date& marginRequestDate);
133 /*!
134 Closes the account as of a given date (i.e. sets the balance to zero)
135 */
136 void closeAccount(const Date& closeDate);
137
138private:
139 QuantLib::ext::shared_ptr<NettingSetDefinition> csaDef_;
141 vector<Real> accountBalances_;
142 vector<Date> accountDates_;
143 vector<MarginCall> marginCalls_;
144};
145} // namespace analytics
146} // namespace ore
MarginCall(const Real &marginFlowAmount, const Date &marginPayDate, const Date &marginRequestDate, const bool &openMarginRequest=true)
void updateMarginCall(const MarginCall &newMarginCall)
Real outstandingMarginAmount(const Date &simulationDate) const
void updateAccountBalance(const Date &simulationDate, const Real &annualisedZeroRate=0.0)
QuantLib::ext::shared_ptr< NettingSetDefinition > csaDef_
CollateralAccount()
Default constructor.
QuantLib::ext::shared_ptr< NettingSetDefinition > csaDef() const
Inspectors.
void closeAccount(const Date &closeDate)
data