PerformanceΒΆ

With numba, py_vollib_vectorized provides a speed boost to the Black/Black-Scholes/Black-Scholes-Merton models when compared to traditional for-loops, and even to other iterative and vectorized implementation. The calculation scales well with the number of option contracts. You can price millions of option contracts in a matter of milliseconds.

The figure below shows the time to calculate the option prices and implied volatilities for a fixed number of contracts. We capped the runtime at 60 seconds. While this performance grah was done with option prices and IVs, all functions in this library benefit from this speed boost. As such, a similar comparison would be obtained with other py_vollib_vectorized functions.

10

100

1000

10000

100000

1000000

10000000

apply

0.0365742

0.0686916

0.652094

6.61839

60.2815

60.2695

60.2486

forloop

0.0228089

0.225833

2.32173

23.3495

60.0936

60.0896

60.0883

iterrows

0.00818448

0.0782769

0.79669

8.18628

60.2422

60.2447

60.2403

listcomp

0.0226992

0.225014

2.29132

23.1457

60.0904

60.0893

60.0897

vectorized (this library)

0.00372455

0.00176468

0.00280967

0.0110767

0.0947469

0.0951369

0.0940527

_images/benchmark.png