Back to Projects
Parallel Portfolio Optimization

Parallel Portfolio Optimization

By Dheeraj Kumar Bhaskar โ€ข March 29, 2026


The Parallel Portfolio Optimization System is a high-performance computing (HPC) project that implements Modern Portfolio Theory (MPT) using Monte Carlo simulation to find optimal asset allocation.

The system leverages OpenMP, MPI, and hybrid parallel computing to significantly accelerate financial computations and improve scalability.


๐Ÿ“Œ Introduction

This project is based on the Markowitz Portfolio Optimization Model, which aims to construct a portfolio that minimizes risk for a given expected return.

The portfolio variance is computed as:

\sigma^2 = w^T \Sigma w

Where:

  • w โ†’ asset weights
  • ฮฃ (Sigma) โ†’ covariance matrix

Due to heavy matrix computations and large simulations, the problem is ideal for parallelization.


๐ŸŽฏ Objectives

  • Build a correct sequential implementation

  • Identify performance bottlenecks

  • Apply parallel computing techniques

  • Compare:

    • Sequential
    • OpenMP
    • MPI
    • Hybrid (MPI + OpenMP)

โš™๏ธ Features

  • Monte Carlo Simulation for portfolio generation

  • Sharpe Ratio Optimization

  • Parallel Execution Models:

    • OpenMP (multi-threading)
    • MPI (multi-process)
    • Hybrid (multi-node + multi-core)
  • Efficient Data Pipeline:

    • CSV parsing
    • Return computation
    • Covariance matrix generation

๐Ÿง  Methodology

1. Data Preprocessing

  • Input: historical stock prices (prices.csv)

  • Compute:

    • Log returns
    • Mean returns
    • Covariance matrix

2. Monte Carlo Simulation

  • Generate random weights (sum = 1)

  • Compute:

    • Expected return
    • Risk (standard deviation)
    • Sharpe ratio
  • Select optimal portfolio


3. Parallelization Strategy

OpenMP

  • Parallelizes Monte Carlo loop
  • Uses guided scheduling for load balancing

MPI

  • Distributes iterations across processes
  • Each process computes local best
  • Root aggregates global best

Hybrid (MPI + OpenMP)

  • MPI distributes workload across nodes
  • OpenMP parallelizes within nodes
  • Achieves maximum performance

๐Ÿงฎ Core Formulas

r_t = \ln(P_t / P_{t-1})
R = \sum w_i \mu_i
\sigma = \sqrt{w^T \Sigma w}
S = \frac{R}{\sigma}

๐Ÿ—๏ธ Project Structure

portfolio_optimization/
โ”œโ”€โ”€ data/
โ”œโ”€โ”€ include/
โ”œโ”€โ”€ src/
โ”œโ”€โ”€ main_seq.cpp
โ”œโ”€โ”€ main_omp.cpp
โ”œโ”€โ”€ main_mpi.cpp
โ”œโ”€โ”€ CMakeLists.txt

๐Ÿš€ Getting Started

Clone the repository and build:

git clone <repository-url>
cd portfolio_optimization
mkdir build && cd build
cmake ..
make

โ–ถ๏ธ Run Commands

Sequential

./seq

OpenMP

export OMP_NUM_THREADS=4
./omp

MPI

mpirun -np 4 ./mpi

Hybrid

export OMP_NUM_THREADS=4
mpirun -np 2 ./mpi

๐Ÿ“Š Performance Evaluation

The system is evaluated based on:

  • Execution Time
  • Speedup
  • Efficiency
  • Scalability

Observations

  • OpenMP โ†’ moderate speedup
  • MPI โ†’ significant improvement
  • Hybrid โ†’ best performance

โšก Key Optimizations

  • Parallel Monte Carlo loop (main bottleneck)
  • Thread-local random generators
  • OpenMP scheduling strategies
  • MPI communication (Broadcast + Gather)
  • Avoiding race conditions

๐Ÿงช Example Output

MPI RUN | Processes = 4

Best Sharpe: 0.069590
Best Return: 0.000716
Best Risk:   0.010295

Time (sec): 2

๐Ÿ“ˆ Expected Results

  • Moderate speedup with OpenMP
  • Significant speedup with MPI
  • Improved scalability with hybrid model

๐Ÿงพ Conclusion

This project demonstrates how parallel computing techniques can significantly enhance:

  • Financial simulations
  • Risk optimization
  • Large-scale computations

By combining Modern Portfolio Theory with HPC, the system achieves efficient and scalable performance.


๐Ÿงฐ Technologies Used

  • C++
  • OpenMP
  • MPI (OpenMPI)
  • CMake

๐Ÿ‘จโ€๐Ÿ’ป Author

Sameer Computer Engineering Student Focus: HPC, Systems, Optimization