## Monday, November 25, 2013

### Screencast: my talk at the QuantLib User Meeting

Welcome back.

We're still collecting the material from the QuantLib User Meeting in Düsseldorf (see my previous post for a report). In the meantime, here is the screencast of my talk (there's a HD version if you want it; just click the Vimeo logo in the bottom right corner to go there). Thanks to Peter Caspers for recording the audio.

Next week, I'll probably go back to posting content from the book—thanks to a train trip that gave me a few hours for writing.

Follow me on Twitter if you want to be notified of new posts, or add me to your circles, or subscribe via RSS: the widgets for that are in the sidebar, at the top right of the page. Also, make sure to check my Training page.

## Monday, November 18, 2013

### Report from the QuantLib User Meeting

Welcome back.

I'm back from the QuantLib User Meeting in Düsseldorf, and it was great. There were about 30 participants from a number of banks and companies, discussing openly about the way they use QuantLib in their work. The intent of the organizers was to start a network of people that could promote the use of QuantLib and learn from each other. It was certainly a good beginning. Thanks to the organizers, the sponsors (IKB, Quaternion and d-fine), the speakers, and all the participants. They all contributed to a great couple of days.

My notes aren't going to do justice to all that was said, so I'll just write a brief summary here. I'll make the slides and/or the audio of the talks available on the QuantLib site as soon as we get the material (and the permission to publish it) from the several speakers. In the meantime, here's a taste of what was said. (The space given to each talk here is not due to its importance; only to the length of the notes I took.)

I had the honor of being asked for the opening keynote. I had a look at the evolution of QuantLib and pointed out a few flaws in the current architecture (not the only ones, of course): lack of support for multi-threading, some abstraction leak as some classes are used for more and more tasks, and a lack of a stand-alone functional core. I suggested a few direction that could be explored in order to fix some of those problems.

Michael von den Driesch spoke about the way QuantLib is used at IKB in the pricing and financial modeling group (part of the bank risk control group). The library is part of a number of applications for valuation, historical simulation, in-house consultancy and so on. Michael's group can use Murex curves seamlessly with QuantLib and compare them with their own. Also, he showed the use of IPython notebooks: a nice tool that I'll have to explore.

Roland Lichters presented the Quaternion Risk Engine, a cross-asset CVA application based on QuantLib plus a number of proprietary extensions. By choosing analytically tractable models and by applying some modification to the library, they were able to speed up calculations until it became feasible (with the help of a 96-core cluster) to obtain the billions of NPVs required by CVA simulation. The most interesting modification was to allow a user to momentarily bypass the Observer/Observable notification mechanism. If one knows what one's doing, it is possible to send a single notification for the simultaneous update of multiple rates, thus reducing the overhead of the pattern.

André Miemiec talked about his implementation of the Hunt-Kennedy model for pricing accreting swaptions. "Strangely enough, it works", in his own words. The implementation is available in the QuantLib patch tracker, and I hope to include it in the library shortly.

Concluding the first day of talks, Peter Caspers presented the Markov functional model he added to QuantLib 1.3 and showed a few results. Then we were off to dinner together.

The second day started with Sarp Kaya Acar and Henning Segger talking about two extensions to the library made by Quaternion: the implementation of the Jarrow-Yildirim model for inflation and the JCIR++ model for hazard rates, respectively.

After this, we had a bit of open discussion about new ideas for the library. Those included:
• treating a swap leg as an instrument in its own right, to allow using different pricing engines for each one;
• a generic mechanism for creating a composite instrument where different components have different currencies;
• a more useful implementation of currencies, which at this time are basically not used;
• alternative approaches to reducing the overhead of the Observer/Observable pattern.
Another idea floated, not directly related to the library: what if a number of small banks joined forces to implement pricing models, distributing the effort between them? The general consensus seemed to be that it would be very nice, but a very hard sell. The same could be said of starting an open-source financial library, though, so I'm not without hopes...

Next talk: Martin Dietrich explained how QuantLib is used at E.ON Global Commodities from Excel, LexiFi or even a web browser through a technology stack including a webserver written in Scala, WebSockets in .Net, and the open-source Excel-DNA. (I know it sounds like a Rube Goldberg machine, but it works fine.)

Klaus Spanderen presented ways to introduce some parallelism in QuantLib; from the easiest (multi-processing, which turns out to be ok in most use cases) to more complex such as OpenMP, multi-threaded calibrations, thread-local objects, or Boost.MPI. He also described his experimental redesign of the Observer/Observable pattern that makes it safe to use QuantLib in languages such as Java or C#, that run garbage collection in a separate thread.

Finally, Sebastian Schlenkrich of d-fine talked about algorithmic differentiation and the proof of concept he coded to calculate Bermudan-swaption vegas; and Johannes Göttker-Schnetmann described how QuantLib is used at Helaba for pricing equity derivatives.

As I said, two great days, full of varied and interesting talks. I hope there will be other editions of the user meeting. For my part, I'll surely try to encourage events of this kind happening in other countries.

Follow me on Twitter if you want to be notified of new posts, or add me to your circles, or subscribe via RSS: the widgets for that are in the sidebar, at the top right of the page. Also, make sure to check my Training page.

## Monday, November 11, 2013

### Intermission

Greetings.

No new content this week, on account of (a) my having to prepare my talk at the QuantLib workshop in Düsseldorf and (b) days having just 24 hours. Stay tuned for next week's post, where I'll report from the workshop. I think it's going to be an interesting one.

In the meantime, you can catch up on previous posts. The links are in the archive section in the sidebar on the right.

Follow me on Twitter if you want to be notified of new posts, or add me to your circles, or subscribe via RSS: the widgets for that are in the sidebar, at the top right of the page. Also, make sure to check my Training page.

## Monday, November 4, 2013

### Interlude: code archaeology

Welcome back.

No book content this week; instead, I though I'd share some curiosities I'd rediscovered recently.

As I mentioned, I'll be speaking at the QuantLib workshop in Düsseldorf in a couple of weeks. As part of preparing my talk, I had to do some research on the way the architecture of QuantLib evolved in its early years; so I put on my Indiana Jones hat and dug into the repository for a couple of nights.

Man, it was a blast.

It was like stepping into another era. Well, it was another era, in a way. We're talking about the early 2000s. C++ had become a standard for just a few years, and the various compilers were scrambling to implement it; thus, we had macros and #ifdefs all over the place to check whether we could use a given language feature, or in the worst cases, to select the syntax to use. Not surprisingly, it was especially bad with templates; but it was needed even with simple features.

One example? Since day one, we have tried to write warning-free code, because (as you all know) both disabling warnings and leaving too many warnings around can lead to disregard the one that, once in a while, we should really heed. However, if we wrote something like:
if (some_condition) {
return 42;
} else {
return 13;
}

a particular compiler would warn that the function might not return a value (because, being particularly dumb, it wouldn't detect that the execution path would hit one of the two return statements in any case). If we tried to silence the warning by writing:
if (some_condition) {
return 42;
} else {
return 13;
}
return 0;

another computer, somewhat smarter that the first, would warn us that the last line would never be executed. The solution? Write
if (some_condition) {
return 42;
} else {
return 13;
}
QL_DUMMY_RETURN(0);

and define the macro as return 0 for the first compiler and as empty for the second.

Kids these days have it easy, I say!

On top of this, sometimes we did our part to confuse the code. There was some class which was incredibly bad designed (*cough* Instrument *cough*), but I'm not talking about that. We had things like different code trees for headers and source files, or namespaces nested two or three levels. We had the strange convention that private data members had a "the" prepended instead of the trailing underscore we use now; as in, say, theSettlementDate. We hadn't begun using the pimpl idiom for classes such as Calendar or DayCounter, so we had to wrap them into smart pointers to pass them around (and we weren't using Boost, of course, so we wrote and used our own vastly inferior smart pointer).

In short: you know the particular "flavor" of QuantLib source code? The set of familiar conventions that we use and that help you recognize the parts of the code, like the particular voice of a writer? They were nowhere to be found. As I said, it looked like another era. Or another code base.

If you want to have some fun looking around the old QuantLib, just clone our git repository, run
git log --until 2001-12-31

to get a log of the revisions in 2000 or 2001, and switch to any one of them that strikes your fancy; for instance, run
git checkout eae05182

to get the very first revision we committed (at that time, it was into cvs).

That's all for this week, I guess. Follow me on Twitter if you want to be notified of new posts, or add me to your circles, or subscribe via RSS: the widgets for that are in the sidebar, at the top right of the page. Also, make sure to check my Training page.