Real-Time Financial Risk Measurement of Dynamic Complex Portfolios with Python and PyOpenCL

Risk measures, such as value-at-risk and expected shortfall, are widely used to keep track of the risk at which a financial portfolio is exposed. This analysis is not only a key part of the daily operation of financial institutions worldwide, but it is also strictly enforced by regulators. While nested Monte Carlo simulations are the most flexible approach that can even deal with portfolios containing complicated derivatives, they traditionally suffer from a high computational complexity. This limits their application at certain intervals of time, mostly daily, by temporarily keeping the composition of the portfolio static. In this work, we bring together for the first time nested Monte Carlo simulations with the real-time continuous risk measurement of complex portfolios that dynamically change their composition during intraday operation. By combining the development productivity offered by Python, state-of-the-art mathematical optimizations, and the high performance capabilities offered by PyOpenCL targeting heterogeneous computing systems, our new approach reaches a throughput between 16 and 191 trading orders per second per computing node, which corresponds to the worst-case and best-case scenarios respectively. We have also made use of the Jupyter Notebook, as an interactive interface in an interdisciplinary research environment.

[1]  Barbara Chapman,et al.  Using OpenMP: Portable Shared Memory Parallel Programming (Scientific and Engineering Computation) , 2007 .

[2]  Attilio Meucci,et al.  Factors on Demand: Building a Platform for Portfolio Managers, Risk Managers and Traders , 2010 .

[3]  Aaftab Munshi,et al.  The OpenCL specification , 2009, 2009 IEEE Hot Chips 21 Symposium (HCS).

[4]  Freddie D. Witherden,et al.  Towards Green Aviation with Python at Petascale , 2016, SC16: International Conference for High Performance Computing, Networking, Storage and Analysis.

[5]  Kurt Keutzer,et al.  Monte Carlo–Based Financial Market Value-at-Risk Estimation on GPUs , 2012 .

[6]  Christine M. Anderson-Cook,et al.  Book review: quantitative risk management: concepts, techniques and tools, revised edition, by A.F. McNeil, R. Frey and P. Embrechts. Princeton University Press, 2015, ISBN 978-0-691-16627-8, xix + 700 pp. , 2017, Extremes.

[7]  Norbert Wehn,et al.  Nested MC-Based Risk Measurement of Complex Portfolios: Acceleration and Energy Efficiency , 2016 .

[8]  Achim Basermann,et al.  Performance and productivity of parallel python programming: a study with a CFD test case , 2015, PyHPC '15.

[9]  Adriaan Joubert,et al.  Numerical Methods in Finance: Fast, Accurate and Inelegant Valuation of American Options , 1997 .

[10]  Nicolas Pinto,et al.  PyCUDA and PyOpenCL: A scripting-based approach to GPU run-time code generation , 2009, Parallel Comput..

[11]  Norbert Wehn,et al.  Near Real-Time Risk Simulation of Complex Portfolios on Heterogeneous Computing Systems with OpenCL , 2017, IWOCL.

[12]  A. Meucci Risk and asset allocation , 2005 .

[13]  Shayne Fletcher,et al.  Financial Modelling in Python , 2009 .