Tagged: covariances.csv, Equity risk, Value at risk, VaR
 This topic has 6 replies, 3 voices, and was last updated 3 years, 1 month ago by Peter Caspers.

AuthorPosts

January 2, 2018 at 1:02 pm #6236AnonymousInactive
At first, I would like to say thank you for the great work, which of course also goes out to the Quantlib team. I really appreciate it!
I have several years of professional experience in capital markets and risk management and in my opinion both tools can easily keep up with many commercial applications and pricing libraries I have encountered in banks so far.
However, after waiting excitedly for the new release, I am still struggling to get started with Open Source Risk Engine. Even with solid knowhow about financial products and pricing/ risk models the sheer number of parameters and config files is overwhelming.
The provided examples are great to show the extensive power and the possibilities of the software in a complex pricing environment, but it is really challenging to identify the essential building blocks and parameters in the config files to run some simple test calculations.
The documentation is already pretty good for an open source project, but a small „getting started“ tutorial would be helpful. I have something like this in my mind:
– Single currency portfolio
– No multicurve framework
– No counterparty credit risk, no collateral etc.
– Only basic set of market parameters: flat vol surface, flat interest rate curves etc.
Maybe just pricing and sensitivity calculation of a plain vanilla equity option or a plain bond. I think it would be easier to start with a basic configuration and then add more features one after the other.
I started with the configuration in example 16 and by reducing the input files to a bare minimum I finally succeeded in pricing an plain vanilla option – but so far, I even failed in calculating the respective sensitivities…
My final goal is to run some market risk calculations like VaR of equity portfolios for training purposes, mainly by Monte Carlo Simulation.
I hope my feedback is helpful for you !Cheers
FiveEights
January 2, 2018 at 1:45 pm #6237AnonymousInactiveHi FiveEights,
Example 14 has a minimal market data setup for exactly this kind of simple test, I think it’s a 2 currency setup but a single one should work too, it’s easy to set it to single curve pricing (just change he specs in todaysmarket.txt)
I agree on your earlier points about the complexity of the configuration, allot of the time it’s necessary to step into the code to see what is going on.
Regards,
Niall.January 4, 2018 at 3:12 pm #6239AnonymousInactiveHi Niall
Thanks for the quick reply ! I checked out the setup in example 14 and this seems to be much more adequate for my test calculations.
I will now slim down my config files todaysmarket.xml etc. according to example 14 and I hope this will simplify my first steps with Open Source Risk Engine.Cheers
FiveEights
February 15, 2018 at 4:49 pm #6273AnonymousInactiveHi
In the meantime I succeeded in setting up a simple market environment and I am now able to price plain vanilla equity options and calculate their sensitivities.
Currently I am moving on to run some VaR calculations for single underlying portfolio.
From my first test runs I suppose that I always have to provide the covariance input file “covariance.csv”, even if I only have one single underlying – right ?How exactly do I calculate the covariance parameter in this file ?
Since I am looking at a single underlying case, the correlation coefficient will be 1 but I don’t understand how I have to scale the respective value.The userguide says “Also note that covariances are expected to include the desired holding period, i.e. no scaling with square root of time etc is performed in ORE”
Maybe I am missing something obvious but I simply can’t find the correct formula for covariance input. I guess Spot and Volatility also have to be included somehow ?Could you please provide an example for calculating the correct covariance parameter ? Thanks for your help !
Cheers
Five Eights
February 18, 2018 at 3:57 pm #6276Peter CaspersKeymasterHi,
let’s look at Example_15, which provides a VaR calculation of a portfolio of trades. Furthermore let’s focus on EQ_CALL_SP5 which is an equity option corresponding to the case you are looking at. This trade has sensitivities to
– the USD discount curve
– the SP5 equity forecast curve
– the SP5 equity spot
– the SP5 equity volatility surface
– and finally the USDEUR FX Spot rate, since the reporting currency is EURTo compute a parametric VaR you can provide a covariance matrix for all of these risk factors that influence the trade’s NPV. Notice that the covariance matrix contains the variances of the single risk factors on the diagonal, so even if we only consider one single risk factor it makes sense to provide a (1×1) covariance matrix, the only entry being the variance of this factor. You do not need to provide each cell of the covariance matrix, missing values are assumed to be zero. In case of zero variances (diagonal elements of the matrix) for a risk factor with a nonzero sensitivity, a warning is logged though indicating that the covariance matrix specification is incomplete.
As an example let’s take the equity spot sensitivity (from the output file sensitvitiy.csv)
EQ_CALL_SP5,EquitySpot/SP5/0/spot,21.475600,179736.37,7599.69,156.28
for which in covariance.csv we have the variance
EquitySpot/SP5/0/spot EquitySpot/SP5/0/spot 100
which has the following interpretation: Since we are computing equity spot sensitivities by applying a 1% relative shift, as can be seen in the input file sensitivity.xml
<! Equity spot shifts > ... <EquitySpot equity="SP5"> <ShiftType>Relative</ShiftType> <ShiftSize>0.01</ShiftSize> </EquitySpot>
the variance is expected to be consistent with this shift type, i.e. the variance of relative movements of the equity spot expressed in percent. In other words you could estimate the variance on a historical time series by computing the sample variance of daily percentage relative changes 100.0 * (Spot(t+1) – Spot(t)) / Spot(t) of the equity spot. If you plug this value into covariance.csv the resulting value at risk will be a 1day value at risk w.r.t. the given confidence level.
If you instead want to compute a say 10day value at risk, you could for example
– estimate the variance of 10d changes 100.0 * (Spot(t+10)Spot(t)) / Spot(t) directly on your time series, with an overlapping or nonoverlapping 10 day window, or
– use your 1d estimate for the variance and scale (multiply) this by 10, following the squareroot of time rule (notice we scale a variance here, not a standard deviation, so no square root shows up)or use another method to arrive at an estimate for the 10 day variance. This is what is meant by “no scaling is applied” in the user guide. i.e. you directly provide the variance consistent with the horizon of the value at risk calculation. In the example covariance.csv we have
EquitySpot/SP5/0/spot EquitySpot/SP5/0/spot 100
which means that the variance of the equity spot risk factor key is 100, i.e. the standard deviation of relative equity spot moves is 10%. If we wanted to specify a correlation with another equity “Lufthansa” assume first we have a variance of the Lufthansa spot of 200, i.e.
EquitySpot/Lufthansa/0/spot EquitySpot/Lufthansa/0/spot 200
Then if the correlation between the two spots’ relative movements is 30% we would add a line
EquitySpot/SP5/0/spot EquitySpot/Lufthansa/0/spot 42.4264
because the covariance is the correlation times the standard deviation of SP5 and Lufthansa respectively, i.e. 0.3 * sqrt(100) * sqrt(200). Notice that in the covariance file of Example_15 no nonzero correlations are specified.
Does that make sense to you?
Best Regards
Peter This reply was modified 3 years, 1 month ago by Peter Caspers.
 This reply was modified 3 years, 1 month ago by Peter Caspers.
 This reply was modified 3 years, 1 month ago by Peter Caspers.
 This reply was modified 3 years, 1 month ago by Peter Caspers.
 This reply was modified 3 years, 1 month ago by Peter Caspers.
 This reply was modified 3 years, 1 month ago by Peter Caspers.
 This reply was modified 3 years, 1 month ago by Peter Caspers.
February 26, 2018 at 9:25 am #6286AnonymousInactiveHi Peter,
Thanks for the detailed and wellwritten explanation, appreciate it !!
I was finally able to work through everything carefully and now I get plausible VaR results.The most important clue was that you pointed me to the specification of the sensitivities in sensitivity.xml.
Somehow I had changed the relative shift size for Delta from 1% to 0.1% and obviously this didn’t match my parameters in covariance.csv.May I suggest that you include your answer in the official userguide ?
I am convinced that this explanation will be very helpful for other users as well to give more information about VaR calculation and covariance.csv.By the way: I saw no product type for stocks in portfolio.xml, right ? At the moment, I use equity forwards as a workaround, but I am not sure if this is the best approach.
Kind regards
FiveEights
February 26, 2018 at 3:39 pm #6287Peter CaspersKeymasterHi FiveEights,
thank you. I agree we should add a section to the user guide explaining all this in more detail and with examples.
It is correct that we do not have stocks in ORE. For the purpose of valuation, sensitivity and VaR calculation it seems sensible though to use forwards (with maturity = reference date) instead.
Best Regards
Peter 
AuthorPosts
 You must be logged in to reply to this topic.