← Back to Blog
Case Study

ORE LiveRisk: 1 Million FX Trades Priced in 0.4 Seconds

A case study in accelerating Open Risk Engine without understanding its C++ codebase. The black-box approach: record QuantLib/ORE through operator overloading, compile, replay 245× faster.

Dmitri Goloubentsev
Dmitri Goloubentsev
· 3 min read
ORE QuantLib live risk FX case study AAD black box

Open Risk Engine (ORE) is built on QuantLib, one of the largest open-source C++ libraries in finance. It has thousands of classes, deep inheritance hierarchies, and decades of accumulated complexity. Nobody fully understands all of it.

The question: can you accelerate ORE without understanding its internals?

The black-box approach

Instead of refactoring QuantLib’s C++ code, we record it:

  1. Hook inputs: Replace the market data entry points (yield curves, FX spots) with active types.
  2. Hook outputs: Capture the NPV calculation result.
  3. Record: Run ORE’s existing pricing path once. Every operation (curve interpolation, discount factor calculation, cashflow projection) is captured on the tape.
  4. Compile: JIT-compile the tape to a native kernel.
  5. Replay: Feed new market data, get prices and Greeks in microseconds.

Zero modifications to QuantLib’s internal C++ code. Zero understanding of the class hierarchy required.

Results: FX linear products

MetricORE (original)Compiled Kernel
1M FX trades — NPV98 seconds0.4 seconds (245×)
Full delta riskHours (bump-and-revalue)<1 second (adjoint)
Recording time350 seconds (one-time, pre-market)
Active-to-passive conversions0 (clean recording)

The 350-second recording is a one-time cost at start of day. After that, every market data update triggers a kernel replay at sub-second latency.

Control flow handling

ORE/QuantLib uses dynamic dispatch, virtual functions, and runtime branching throughout. The recording captures the specific execution path taken for the given trade population. This means:

  • Adding a new trade type that exercises a different code path requires re-recording.
  • Changing market data does NOT require re-recording (market data are kernel inputs).
  • The kernel is specific to the trade population’s structure, not its parameters.

Production workflow

  1. Pre-market (6:00 AM): Load trade population, record all kernels (~350s). Cache to disk.
  2. Market open: Load cached kernels. Set market data inputs. Replay for NPV + Greeks.
  3. Intraday: On each market data tick, replay the kernel. Sub-second full portfolio risk.
  4. End of day: Archive kernels for audit trail.

What this means

ORE has 500,000+ lines of C++ code. A traditional optimization project would take years and require deep QuantLib expertise. The black-box approach took weeks and required understanding only the input/output boundaries.

The same pattern applies to any pricing library: in-house C++ code, vendor libraries, even legacy Fortran. If it runs on a CPU with double arithmetic, it can be recorded.


Implemented using AADC, a commercial adjoint AD compiler (matlogica.com).

Want to see these results on your own portfolio?

Get in Touch

Interested in these opportunities?

Let's arrange a free demo for you and your team.

Book a Demo