This repository provides a quantum approach to portfolio optimization using the Quantum Approximate Optimization Algorithm (QAOA) and compares its results with a classical approach for optimizing the Sharpe ratio.
The analysis includes four assets over the period from 2016-01-01 to 2021-09-20:
- BRKM5.SA
- ITUB4.SA
- VALE3.SA
- KLBN4.SA
- notebooks/qaoa.ipynb
- Formulates a cost function based on expected returns, risk (covariance matrix), and portfolio constraints
- Defines the optimization problem as a Quadratic Unconstrained Binary Optimization (QUBO) problem
- Construct the Hamiltonian for the cost function, such that its ground state represents the optimal solution
- Simulates the QAOA algorithm for various circuit depths
- notebooks/classical_optimization.ipynb
- Maximizes the Sharpe ratio of a portfolio using classical optimization techniques.
- Computes the optimal portfolio weights based on expected returns and covariance matrix.
Both approaches are applied to the same dataset of selected assets, and their results are compared to evaluate the effectiveness of QAOA in portfolio optimization.
The QAOA algorithm was designed to select two assets to include in the optimal portfolio, while the classical approach returns a weighted optimal portfolio. The results demonstrate that the two assets selected by QAOA align with the first two assets identified by the classical approach.
This implementation was inspired by the paper Quantum Finance: um tutorial de computação quântica aplicada ao mercado financeiro by Askery Canabarro et al., which introduces QAOA for portfolio optimization using assets from the Brazilian stock market. The same assets and time period (January 2016 to September 2021) were used to validate the quantum approach, achieving results consistent with those presented in the paper.