Bloomberg: 1000× Pricing Solver Speedup

How I made inference 1000× faster for reverse-pricing options portfolios during my placement at Bloomberg.

· Absolute numbers on this page have been changed; the relative improvements are unchanged.

Thought Process

What makes reverse pricing slow?

Every European options asset is priced with the Black-Scholes formula (Black & Scholes, 1973). Give it the spot price, the strike, the time to expiry, the interest rate and the volatility, and it returns the option's price in a single evaluation.

C
option price
S
spot price
K
strike
T
time to expiry
r
interest rate
σ
volatility
N
standard normal CDF
Black-Scholes price of a European call

Reverse pricing starts from a price and finds the strike (or other parameter) that produces it. Black-Scholes can't be rearranged into a closed-form expression for any variable that appears within the normal CDF, so the only way back is with numerical methods.

Searching with Brent's method

Originally, we ran that search with Brent's method (Brent, 1973). It keeps the answer trapped between two strikes, one priced above the target and one below the target, and narrows that bracket at every step. Where the price curve is well behaved it takes a fast interpolating step; where that step can't be trusted, it falls back to splitting the bracket in half, which guarantees it always converges.

  1. 1Bracket the target
  2. 2Inverse quadratic interpolation through three points
  3. 3Secant through two points
  4. 4Bisection if the interpolated guess can't be trusted
  5. 5Keep the bracket around the target, and stop when close enough
Step 0 of 9Starting bracket
K =150.0000000000000 of 12 decimal places correct
Solving for the strike that prices a call at 6.00 (S = 100, T = 1, r = 5%, σ = 20%)Step through it yourself

Newton's method usually gets there in fewer steps, but it divides by the slope of the price curve, and far out of the money that curve is almost flat. A near-zero slope throws the next guess far off, sometimes to a negative strike, so it was too unstable to trust across a whole portfolio.

Why it was too slow

Every step of the search is a full Black-Scholes evaluation, and reaching the 12 decimal places of accuracy we needed took many of them. For a single-asset portfolio that cost milliseconds, but for multi-asset portfolios it stretched to seconds.

The goal was a solver that reverse-prices to the required accuracy in a single evaluation, with no iterating.

Can off-the-shelf models learn Black-Scholes?

Machine learning was the natural candidate for a one-shot solver, a trained model answers with a single pass through the network, which is cheap and fast. The hard part was accuracy. While models are usually judged on their average error, and we needed every answer to be right to 12 decimal places, however, we did have access to unlimited training data.

Black-Scholes is quick to run forwards, so pricing randomly chosen strikes and recording the results gives as many exact examples of the reverse calculation as we could want. To decide where to sample, we worked with analysts and historical data to pin down the target domain of prices, spots, times to expiry, interest rates and volatilities the solver had to handle. For the less than 1% of other inputs we can fall back to Brent's method.

Baselines

We tried random forests, XGBoost, feed-forward neural networks and other standard architectures. The feed-forward networks did best, but even they only reached a maximum error of over the target domain, eight orders of magnitude short of what we needed.

Why scaling up wasn't the answer

Neural scaling laws describe error falling as a power law in model size, data and compute (Kaplan et al., 2020). Along a curve , closing an eight-order-of-magnitude gap means growing by a factor of . Even with a generous , that's a hundred million times more parameters, with data and training time growing alongside.

Theory points the same way. Allen-Zhu, Li and Song (2019) prove that gradient descent drives a deep network's training error below in iterations, for training samples, layers and -dimensional inputs at least apart, but only once every layer is wide enough: . Accuracy itself is cheap, entering only through . The cost is the width, which grows polynomially with and , and pinning a function down to 12 decimal places takes a huge number of samples packed closely together.

So scaling up an off-the-shelf model was out. We had to make the problem itself simpler, and find an architecture better suited to it.

Can we describe the function with fewer inputs?

The formula's five inputs don't act independently. They only appear in a few fixed combinations, so the formula can be rewritten in fewer variables, and every variable removed is one less dimension for the model to learn.

Start from the call price and its five inputs:

  1. Group volatility and time. Expanding shows that and only ever appear together as , the total volatility over the option's life. Call it :
  2. Group the rate with moneyness. The rate only appears as , always added to . Together they make the forward log-moneyness , which measures how far the forward price sits above or below the strike.
  3. Normalise the price. Dividing the price by the discounted strike turns the in front of into and leaves a dimensionless price :

Five inputs collapse to two. The normalised price depends only on the forward log-moneyness and the total volatility:

Cd
normalised price
m
forward log-moneyness
v
total volatility
N
standard normal CDF
Black-Scholes call in dimensionless form

Dimensional analysis alone gets most of the way there. Prices and strikes share units, so only their ratios can matter, and time only enters through and , so the Buckingham π theorem (Buckingham, 1914) leaves three dimensionless groups. The formula takes it to two, because and only appear as a sum.

Recovering the strike

In reverse pricing the strike is unknown, and it appears in both and . This combination of them doesn't depend on it:

So the reverse problem has two known inputs, the price as a fraction of spot and the total volatility . A model only has to learn the map , and the strike follows from the definition of :

The model now learns a function of two inputs instead of five, both dimensionless and bounded. For a call, always lies between 0 and 1.

The shape of the function

Plotting over and shows the relationship the model learns to invert. It is a single surface, bent upwards by moneyness and volatility and held between two limits. stays between 0 and 1, so it's easier to picture than , which grows like and runs off the top of any plot.

Price as a fraction of spot over forward log-moneyness m and total volatility vDrag to rotate

Its edges follow from the formula:

  • No volatility, . With nothing uncertain, the option is worth exactly its intrinsic value, so the surface folds onto , the bold curve along the front edge.
  • Deep out of the money, . Both terms vanish and , falling away faster than any exponential.
  • Deep in the money, . , the intrinsic value again, and the option behaves like a forward contract.
  • Unlimited volatility, . and , so , so the call is worth the spot price itself. The back of the surface reaches the dashed ceiling.
  • At the money, . , a nearly straight ramp in volatility.

These are the no-arbitrage bounds on a call. Every point on the surface lies between the intrinsic floor and the ceiling, and the second line gives the same bounds for .

The difficult region is the front of the surface, around . As shrinks, the surface folds into the kink of the intrinsic floor, and its curvature there grows like . Everywhere else it's smooth, but a sharp fold like this is hard to fit to 12 decimal places.

How well do MLPs fit the reduced function?

With the problem down to two inputs, we went back to neural networks and tried residual networks, whose skip connections make deeper models easier to train (He et al., 2016), and SIRENs, which swap the usual activations for sines (Sitzmann et al., 2020).

Fitting the residual

The biggest gain came from splitting the work across several networks. Take a well-trained model and the true function . Their difference is tiny but isn't noise. It's a smooth function that oscillates around zero.

Networks with sine activations are good at fitting oscillations. Fitting a SIREN to the residual gives , and subtracting it from the model leaves a much smaller error, . That new residual oscillates too, so we fit it, subtract it, and repeat.

Stage 0 of 10A trained model against the true function

At this scale the model f sits exactly on the true function g.

Illustrative: residual shapes are synthetic, the final 10⁻⁹ is realStep through it yourself

Each stage removes most of the remaining error, but never all of it. The network is built from sums of its activations and Black-Scholes from exponentials and the normal CDF, and no finite stack of one basis reproduces the other exactly. There's always a residual, just a smaller one each time. It still reached a maximum error of over the target domain.

Why SIRENs are fragile

SIRENs are fragile. Each layer computes , and the frequency scale is fixed at initialisation. If it doesn't match the frequencies in the residual, training collapses and leaves the residual barely touched, so every stage needed its own .

Even so, these models stopped at , three orders of magnitude short of the we needed.

Are feedforward networks the right tool at all?

Closing the last three orders of magnitude with a neural network looked like a losing fight against scaling. But the dimensionless rewrite had changed the problem. The solver only needs a function of two inputs, and over the target domain that function is a smooth, mostly continuous surface. Add unlimited training data, and splines, a much older tool, fit the job better than a network (de Boor, 1978).

What a spline is

A spline is a curve built from polynomial pieces laid end to end. Each piece is shaped by a few nearby control points, and neighbouring pieces meet at knots. In a cubic spline the value, slope and curvature all match at every knot, so the curve stays smooth. Moving a control point only reshapes the pieces around it, so a spline can follow a complicated shape closely while each piece stays cheap to evaluate.

A cubic splineDrag the control points

From curves to surfaces

The same idea extends to two inputs. A grid of control points over and defines a surface of patches, one per grid cell, each cubic in both directions and joined smoothly to its neighbours. Its height is the moneyness . To evaluate a point, we find its patch with a single division on the uniform grid, then solve one cubic along and one across .

Step 0 of 3A surface tiled by spline patches

Each tile is one patch, cubic in both directions and joined smoothly to its neighbours. This grid is 6 × 6; the real one is 1000 × 1000.

Spline patches over the moneyness surface, and one lookupStep through it yourself

Every lookup is a fixed amount of arithmetic with no iterating. It finds the tile, evaluates its cubics for , and recovers the strike as . Brent's method needed a whole sequence of full Black-Scholes evaluations for the same answer.

Choosing the degree and the grid

A spline can use pieces of any degree and any number of control points. Higher degrees are smoother but cost more to evaluate, and more control points capture finer detail but use more memory. For our domain, cubic pieces on a 1000 × 1000 grid of control points were a good fit.

How does spline-based modelling perform?

Portfolios of several assets

A portfolio's price is the sum of its assets' prices. With each asset's volatility fixed, each asset contributes one slice of its surface, and the portfolio's price is the sum of those slices:

The sum is still a single smooth curve that falls steadily as the strike rises, so there's exactly one strike for any target price.

Illustrative: three assets' prices summing to the portfolio'sDrag the target price

Puts, and other unknowns

None of this is specific to calls or to the strike. By put–call parity, the put surface is a shift of the call surface:

The same construction also works with the strike known and as the unknown, a surface over and , which gives the implied volatility as .

Tuning the control points

A spline fitted the usual way minimises its average error, but our requirement was on the worst case. We treated the control points as trainable parameters and used PyTorch (Paszke et al., 2019) to tune their positions to minimise the maximum error over the target domain.

The tuned spline reached in a thousandth of the original solver's inference time.

Best baseline10−4
Residual SIRENs10−9
Tuned splines10−12
Maximum error over the target domain, by approach (log scale)

References

  1. Allen-Zhu, Z., Li, Y. and Song, Z. (2019). A Convergence Theory for Deep Learning via Over-Parameterization. International Conference on Machine Learning (ICML). arxiv.org/abs/1811.03962
  2. Black, F. and Scholes, M. (1973). The Pricing of Options and Corporate Liabilities. Journal of Political Economy, 81(3), 637–654.
  3. Brent, R. P. (1973). Algorithms for Minimization without Derivatives. Prentice-Hall.
  4. Buckingham, E. (1914). On Physically Similar Systems; Illustrations of the Use of Dimensional Equations. Physical Review, 4(4), 345–376.
  5. de Boor, C. (1978). A Practical Guide to Splines. Springer-Verlag.
  6. He, K., Zhang, X., Ren, S. and Sun, J. (2016). Deep Residual Learning for Image Recognition. IEEE Conference on Computer Vision and Pattern Recognition (CVPR). arxiv.org/abs/1512.03385
  7. Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J. and Amodei, D. (2020). Scaling Laws for Neural Language Models. arXiv preprint. arxiv.org/abs/2001.08361
  8. Paszke, A., Gross, S., Massa, F., et al. (2019). PyTorch: An Imperative Style, High-Performance Deep Learning Library. Advances in Neural Information Processing Systems (NeurIPS). arxiv.org/abs/1912.01703
  9. Sitzmann, V., Martel, J. N. P., Bergman, A. W., Lindell, D. B. and Wetzstein, G. (2020). Implicit Neural Representations with Periodic Activation Functions. Advances in Neural Information Processing Systems (NeurIPS). arxiv.org/abs/2006.09661