A Python command-line tool for portfolio optimization using quantum computing (QUBO) techniques.
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install the package in editable mode:
pip install -e .List active stocks with at least 2 years of trading history:
qpo stocks --min-years 2 --limit 50Save to file:
qpo stocks --output tickers.txtDownload historical price data for specific stocks:
# Using period (convenient)
qpo fetch AAPL MSFT GOOGL --period 2y --output-dir data/stocks
# Using date range (precise)
qpo fetch TSLA --start 2020-01-01 --end 2023-12-31
# From file
qpo fetch --input tickers.txt --period 1yPeriod options: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, max
Merge individual stock CSVs into a single portfolio matrix:
qpo portfolio data/stocks/ --output portfolio.csvAdvanced options:
# Use adjusted close prices
qpo portfolio data/stocks/ --column "Adj Close"
# Handle missing data with interpolation
qpo portfolio data/stocks/ --fill-method interpolate# 1. Get list of stocks
qpo stocks --limit 20 --output tickers.txt
# 2. Fetch 2 years of data
qpo fetch --input tickers.txt --period 2y --output-dir data/stocks
# 3. Create portfolio matrix
qpo portfolio data/stocks/ --output portfolio.csvThe package structure:
qpo/
├── cli.py # Main CLI entry point
├── commands/ # Subcommands
│ ├── stocks.py # List active stocks
│ ├── fetch.py # Download stock data
│ └── portfolio.py # Create portfolio matrix
└── utils/
└── yahoo_api.py # Yahoo Finance utilities
Copyright (C) 2025 Postquant Labs Incorporated
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Important: If you run a modified version of this software as a network service (e.g., as a web API, cloud service, or any other networked application), you must make the complete source code of your modified version available to users of that service under the terms of the AGPLv3 license. This is a key requirement of the AGPL license that distinguishes it from the standard GPL.
- COPYING - Full text of the GNU Affero General Public License v3.0
- NOTICE - Third-party software attributions and copyright notices
This project uses several open-source libraries. See the NOTICE file for detailed attribution and license information for all dependencies.
All third-party dependencies are compatible with AGPLv3. Key dependencies include:
- Apache-2.0 licensed: requests, yfinance, cvxpy, D-Wave Ocean SDK components
- BSD-3-Clause licensed: pandas, NumPy, SciPy, scikit-learn, seaborn, Click
- MIT licensed: PyYAML, setuptools
- GPL-3.0 licensed: ECOS (compatible with AGPL-3.0)