Jaime López

Data Science Systems Developer

Optimizations in Computing for Finance

Feb. 05, 2026

As financial data scales up, computational efficiency becomes critical. Starting from first principles, we know there are two fundamental paths to better performance: better algorithms and better use of available hardware. This article focuses on the latter, exploring optimization techniques through parallelism and vectorization.

For small data volumes, the performance gap between optimized and non-optimized code is often negligible. In these cases, code simplicity and clarity typically outweigh any optimization gains. At the other extreme, when dealing with very large datasets, optimizations become essential for obtaining results within reasonable timeframes.

That said, we must be cautious about one-size-fits-all recipes. Most optimization problems are highly dependent on data characteristics, usage requirements, and problem context. There's no universal solution. This is where experimentation—even basic methodologies—becomes critical for determining which optimizations to apply.

To illustrate with a concrete example, I present the results of a simple experiment. The problem involves generating interest rate simulations using the Vasicek (1977) model. This describes interest rate movements through a mean-reverting stochastic process. It uses three parameters: the mean reversion speed, the long-term interest rate, and volatility. The stochastic differential equation that defines the model is:

$$dr_t = a(b - r_t)dt + \sigma dW_t$$

where $r_t$ is the interest rate at time $t$, $a$ is the mean reversion speed, $b$ is the long-term interest rate, $\sigma$ is the volatility, and $W_t$ is a Wiener process.

The experiment involved implementing three versions of the same algorithm:

  • Serial: a basic implementation with no optimizations. Two nested loops generate a matrix with $M$ simulations of $N$ time steps each.
  • OpenMP: parallelization of the outer loop using OpenMP directives to leverage multiple CPU cores.
  • Vectorized: use of vectorized operations to process multiple data points in parallel, taking advantage of the CPU's SIMD capabilities. For this, we used the C library ndarray.

The simulation ran for different matrix sizes, measuring execution time in milliseconds. The hardware used was an Intel Core i5-12400 processor with 12 cores and 64 GB of RAM.

Size            Serial  OpenMP     Vec Vec/Ser OpenMP/Ser
---------------------------------------------------------
  100 x   100     0.26    0.56    0.41 0.64x   0.47x
  250 x   500     3.51    5.89    4.10 0.86x   0.59x
  500 x  1000    12.41   16.22    3.84 3.23x   0.77x
  100 x  2000    48.84   40.14   13.22 3.69x   1.22x
 2500 x  5000   315.08  266.89   80.01 3.94x   1.18x
 5000 x 10000  1237.61 1071.26  332.48 3.72x   1.16x
10000 x 20000  5034.15 4266.39 1459.24 3.45x   1.18x

The results show that the vectorized version outperforms the other two once the dataset reaches a certain size. OpenMP parallelization improves performance relative to the serial version, but doesn't match the efficiency of vectorization—likely due to the sequential nature of the algorithm. For small datasets, the serial version is the best choice, since the overhead of parallelization or vectorization isn't justified.

Through a simple experiment like this, you can evaluate which strategy works best for your specific case. The experiment could be improved by running multiple iterations to capture the statistical distribution of execution times, testing different hardware configurations, exploring additional optimization techniques, and trying other algorithms applicable to the same problem.

My final takeaway is that while general optimization principles are fundamental, hands-on experimentation is essential for identifying the best strategies in each case. In my view, the most important thing is to have a clear understanding of the problem, the nature of your data, and the opportunities and constraints of your context.

Resources:

References:

  • Vasicek, O. (1977). An equilibrium characterization of the term structure. Journal of Financial Economics, 5(2), 177-188.

Spanish