JuliaCon 2020 (times are in UTC)

When compiler technology meets Market Risk Management
07-29, 12:30–13:00 (UTC), Green Track

This talk will show a Julia based solution that can automatically create a price function and map the risk factors of a given Financial Contract defined in a domain-specific language. This project applies compiler algorithms to take advantage of context in the pricing formulas so that it is possible to handle big portfolios with a wide variety of financial contracts.


This talk tackles the main issue regarding the development of solutions for market risk management: given a financial contract, one must know how to price it, but it is also required to understand how the pricing formula reacts to changes in the market prices.

This project was heavily inspired by Julia Computing's Miletus.jl, but goes one step further: given a financial contract, it is now possible to automatically map its risk factors. A general solution is based on ForwardDiff.jl. Alternative methods can be included in the system by making use of Julia's multiple-dispatch.

Compiler algorithms were used on top of Julia's JIT compiler to generate pricing formulas. Using a customized IR defined in OptimizingIR.jl it is possible to represent a pricing function that would require a billion nodes on an AST with just a few thousand instructions in the optimized IR. With this setting, this solution provides:

  • Scalability: compile millions of pricing functions without breaking Julia.

  • Automated Auditing: automatically generate documentation on how the calculation is performed, as often required by market regulators and auditing firms.

  • Cashflow projection: given that functions are not restricted to return a single number, it is possible to compile pricing functions that also return intermediate results.

  • Take advantage of context: compile a whole portfolio to a single pricing function, and all repeated intermediate steps in the calculation are done only once, without losing detail on pricing results for each contract in the portfolio.

Market Risk Manager at the Brazilian Development Bank.

Computer Nerd