Скачать книгу

which I joined in 2008 and left in 2018, the scripting language is called Jive. Jive is used for everything traded at Danske Bank: from vanilla swaps to mortgage bonds to equity exotics to regulatory capital. Jive is even used in the yield curve calibration. This is the only bank that I know of that uses a scripting language so consistently. Developments have mainly concentrated on aggregation, compression, and decoration used for xVA and regulatory calculations. Here, we have heavily leveraged on the visitor pattern technology. But we have also done significant work on Automatic Adjoint Differentiation (AAD), multi‐threading, branching simulations, and fuzzy logic to stabilize risk calculations. Antoine joined Danske in 2013, and since then he has played a key role in these developments. In 2015, we received Risk Magazine's In‐House Risk System of the Year award for our xVA system. The AAD and the speed of the calculations achieved by the xVA system have received a lot of attention in the quant community, but the scripting and visitor pattern technologies are actually the unsung heroes that have made all of this possible.

      To document how we did xVA on an iPad Mini without thoroughly describing our approach to scripting would be wrong and not give the reader the full picture. I was therefore very happy when Antoine told me he was going to write a book on scripting. This would give us the opportunity to finally get our work on scripting languages documented and pave the way for fully documenting our xVA system.

      There are a number of reasons why the story of scripting has not been told before. Among these:

      1 – It's not mathematics, but software design, which is actually something that we do every day but not something that we usually write about.

      2 – It's a complex and relatively long and winding story that cannot easily be summoned in a few punchlines. On top of this it contains subjects that most people haven't even heard about, such as visitors and pre‐processors.

      3 – It's a hard sell to change conventional wisdom that scripting is only for exotics and has no relevance in post‐crisis finance. Actually, scripting is more relevant now than ever, because banks are under tough regulatory and cost pressures.

      4 – It's very C++ and as such not following the current trend of lighter languages such as Matlab and Python backed by GPUs running parallel instructions in C.

      5 – The subject is still very much alive: whenever we start documenting our efforts, we always get new ideas that we can do with scripting, which in turn tends to take away focus from documenting past glories.

      My next employer is Saxo Bank and the scripting language there will be Jife.

       Jesper Andreasen, June 2018

PART I A Scripting Library in C++

      This part leads readers through the development steps of the scripting library provided in our source repository.

01Jun2020 vRef=spot() vAlive=1
01Jun2021 if spot() > vRef then prd=110 vAlive=0 endIf
01Jun2022 if spot() > vRef then if vAlive=1 then prd=120 endIf vAlive=0 endIf
01Jun2023 if vAlive=1 then if spot() > vRef then prd=130 else prd=50 endIf endIf

      We have four events on four event dates:

      1 Today, we set the reference to the current spot level and initialize the alive status to 1.

      2 Year 1, we check whether the spot increased, in which case we pay redemption + 10% and die.

      3 Year 2, we check that the spot overall increased over two years. In this case, provided we survived year 1, we pay redemption + 20% and die.

      4 Year 3, provided we survived the first two, we check if the spot overall increased. In this case we pay redemption + 30%. If not, we repay 50% of the notional.

      The language considers as a variable anything that starts with a letter and is not otherwise a keyword. We used the variables images, images, and images in our example. Evidently, ancillary variable names don't have to start with the letter V; this is only for clarity.

      Products are variables. The language makes no difference between products and ancillary variables; only users do. Our example actually scripts three products: images obviously; images, which pays the spot fixing today and is worth today's underlying asset price; and images, which is worth 1 at maturity if the product survived the first two years, 0 otherwise. Its value is the (risk‐neutral) probability of surviving to year 3. All variables may be seen as products, although, in general, the values of ancillary variables are disregarded in the end. In chapter5, we will

Скачать книгу