
P1: JYS
c11 JWBK378-Fletcher April 24, 2009 8:17 Printer: Yet to come
11
Hybrid Python/C++ Pricing Systems
In Chapter 3, we saw how we may extend Python with modules written in C++. Specifically,
we studied case examples of reflecting types from the Boost.Date
Time library into Python.
Further, in section 3.1.1 we developed functionality in Python making use of those reflected
types to compute IMM dates. In this chapter we aim to show how we can exercise that
functionality from C++. What is the relevance of this? Well, it demonstrates the possibility of
‘hybrid pricing systems’. That is, systems formed from a mix of both C++ and Python. Such
potential will likely be of no small interest to those institutions that already have a considerable
investment in C++. By using the techniques about to be presented, organisations with pricing
frameworks in C++ can enjoy the many benefits Python offers while seamlessly integrating
these efforts with their existing C++ frameworks.
11.1 nth imm of year REVISITED
Our goal will be to exercise the Python code for IMM date computation functionality, presented
in section 3.1.1 from C++. As the first step in seeing how to achieve that, it is necessary for us
to review the implementation of the Python class nth
imm of year and examine in closer
detail its relationship with the C++ code on which it rests.
from ppf date time import \
weekdays \
, months
of year \
, nth
kday of