Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I am thinking of writing a VaR framework for my existing system, using quantlib to do the bulk of the calculations.

Despite several searches, I have not as yet come across a quantlib VaR implementation. Is anyone aware of a quantlib based VaR implementation that I may be able to use a s a starting point (to prevent reinventing the wheel)?

Assuming that such a library/framework does not exist - could someone please outline the main steps involved in putting together such a system - so I can make sure that I am not missing anything obvious/ I am on the right track.

For instance, I will have to map my current rate curves and instruments to the Quantlib objects. I will write adaptors to doing the mapping between the classes so assuming that is out of the way, it would be useful to get an outline of the steps required to put a VaR system together using quantlib (assuming there is no such library/framework to build from).

share|improve this question
1  
There's no public QuantLib-based implementation as far as I know. What kind of VaR methodology will you be using? And on what kind of system would you bolt it? –  Luigi Ballabio May 3 '12 at 10:35
    
@LuigiBallabio: re type of VaR: historical simulation VaR. The system is a proprietary (internally developed) one we use for trading. HTH. –  Homunculus Reticulli May 4 '12 at 15:08
    
My impression was that quantlib is mostly bare pricing code. I think an good VaR framework comes from efficiently managing the dependency graph of instruments and risk factors to avoid computing anything twice or having to load data too often. And this is facilitated by exposing the pricing code to some sort of modelling language more suitable for VaR simulation. I'd be interested to know if you find anything out about the Quantlib framework as a VaR tool. I had a look about a year ago and did not find anyone writing about it. –  mathtick May 8 '12 at 12:56
add comment

3 Answers 3

up vote 3 down vote accepted

I'm guessing you're simulating rate curves etc. inside your system, and you want to reprice your instruments over the simulated curves using QuantLib. In this case, most of the logic is in your system already, and you have to plug pricing functionality in.

If so, I don't think there's many steps involved besides, well, pricing the instrument on the simulated scenarios. My suggestion for doing that is to use the facilities provided by QuantLib (like quotes and the observer/observable pattern) to avoid repeat all the mapping work on each scenario. For instance, you can instantiate a given instrument just once; for each scenario, you can then relink the relevant handles to the simulated curves and ask the instrument for its new price. The machinery is already in place; you can look at the test suite (say, to testGreeks in the europeanoption.cpp file, where we perturb market quotes to trigger changes in price) to see it in action. For a description of the framework, you can see http://sites.google.com/site/luigiballabio/qlbook.

For what is worth, the library provides the basic VaR functionality in its Statistics class; it's just the stats calculation given a set of numbers, but still it's one less small wheel to reinvent.

If you think that QuantLib might help somehow in simulating the curves, please comment here and I'll try to extend the answer. But since you already have a trading system, you already have a curve builder, so I guess you want to keep using that.

share|improve this answer
    
We already have a curves defined within our system, so as much as possible, I would like to reuse that. My initial thought is to use quantlib for the pricing. I'll take a look at the link you posted and see if it generates any further ideas. Thanks for your input. –  Homunculus Reticulli May 7 '12 at 20:40
add comment

There is experimental code available under https://sourceforge.net/tracker/?func=detail&atid=312740&aid=3413982&group_id=12740

Basically I tried to answer the question if you should do the riskfactor shifts on the level of the pricing engine or on the level of the market data. For me the answer is that one has to do it on the level of the market data. The code implements the shift on the level of the pricing engine. Its very experimental. Nevertheless I've checked the results with the output of some commerical software and found agreement. So it might be a starting point.

share|improve this answer
    
+1 for the link. I'll download it and take a look at it for some ideas. As an aside, our portfolios are largely non-linear, we trade options almost exclusively, but I hope your codebase could be a useful starting point. Thanks –  Homunculus Reticulli May 10 '12 at 15:56
add comment

Why don't you try to contact them

http://quantlib.org/mailinglists.shtml

I've worked with them in the past, they're very nice people and will help you for sure if they can.

share|improve this answer
1  
If you want to reach out, the QuantLib mailing list is a better option. If you use the StatPro contacts listed on their page you're going through sales. It might be what you want; just be aware of the difference between QuantLib (the open source project) and StatPro (the for-profit company). –  Luigi Ballabio May 3 '12 at 10:34
    
Apologies for the mistake –  mepuzza May 3 '12 at 12:34
    
@LuigiBallabio: Which list do you recommend - 'users 'or 'dev' for VaR implementation related questions? –  Homunculus Reticulli May 4 '12 at 15:10
    
I'd say 'users', to reach more people. In hindsight, having two lists was probably not much of an idea. The traffic is not nearly large enough for specialized forums... –  Luigi Ballabio May 7 '12 at 14:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.