Track weighted stock portfolios, calculate historical returns, export CSV analytics, and visualize performance from a clean Qt desktop interface.
Features · Quick Start · Usage · Architecture · Roadmap
---Yahoo Stocks is a Python desktop application built with PyQt6 for tracking the historical movement of an investment portfolio. The app fetches stock data from Yahoo Finance, calculates weighted daily portfolio returns, saves results to CSV, and provides visual analytics through multiple chart types.
It is designed as a compact portfolio-analysis tool for users who want to enter ticker symbols, assign portfolio weights, select a buy/sell date range, and quickly understand how the portfolio moved over time.
Disclaimer: This project is for educational and analytical purposes only. It is not financial advice.
| Feature | Description |
|---|---|
| 📈 Yahoo Finance data retrieval | Downloads historical close prices for selected stock tickers using yfinance. |
| ⚖️ Weighted portfolio calculation | Combines multiple assets according to user-defined portfolio weights. |
| 🗓️ Calendar-based date selection | Lets users choose start and end dates through a PyQt6 calendar dialog. |
| 📄 CSV output | Saves calculated portfolio returns to Data/stocks_returns.csv. |
| 📊 Portfolio charts | Generates portfolio movement, profit/loss ratio, and boxplot visualizations with Matplotlib. |
| 🧮 Statistical summary | Creates descriptive statistics such as count, mean, standard deviation, min, quartiles, and max. |
| 🗃️ SQLite history layer | Includes a SQLite-backed module for storing and clearing query history. |
| 🖥️ Desktop-first UI | Uses PyQt6 widgets, tables, dialogs, and multi-window navigation. |
flowchart LR
A[User enters tickers, weights, separator, dates] --> B[MainWindow.py]
B --> C[CalendarWindow.py]
B --> D[BackEnd.py]
D --> E[yfinance / Yahoo Finance]
E --> D
D --> F[Data/stocks_returns.csv]
F --> G[StockWindow.py]
G --> H[MoreInfoWindow.py]
G --> I[GraphWindow.py]
H --> J[Data/more_info.csv]
I --> K[BuildGraphs.py]
K --> L[Portfolio chart]
K --> M[Profit vs loss pie chart]
K --> N[Boxplot]
B --> O[HistoryWindow.py]
O --> P[WorkWithHistory.py]
P --> Q[History.sqlite]
| Layer | Technology |
|---|---|
| GUI | PyQt6 |
| Market data | yfinance |
| Data processing | pandas |
| Visualization | matplotlib |
| Local persistence | sqlite3 |
| Export format | CSV |
Yahoo-Stocks-QT6-app/
├── Qt project/
│ ├── BackEnd.py # Yahoo Finance requests, weighted return calculation, CSV export
│ ├── BuildGraphs.py # Matplotlib chart builders
│ ├── CalendarWindow.py # Date picker dialog
│ ├── GraphWindow.py # Chart selection window
│ ├── HistoryWindow.py # History UI
│ ├── MainWindow.py # Main PyQt6 application entry point
│ ├── MoreInfoWindow.py # Statistical summary table
│ ├── StockWindow.py # Portfolio return table and analytics actions
│ └── WorkWithHistory.py # SQLite history helpers
├── Project presentation.pdf
├── LICENSE.md
└── README.md
git clone https://github.com/whoIsClownHere/Yahoo-Stocks-QT6-app.git
cd Yahoo-Stocks-QT6-apppython3 -m venv .venv
source .venv/bin/activatepython -m venv .venv
.venv\Scripts\Activate.ps1pip install PyQt6 pandas yfinance matplotlibThe app writes generated CSV files into Data/.
mkdir -p "Qt project/Data"New-Item -ItemType Directory -Force -Path "Qt project\Data"cd "Qt project"
python MainWindow.py-
Open the application.
-
Enter stock tickers in the stock name field.
Example:
AAPL, MSFT, NVDA -
Enter portfolio weights in the same order.
Example:
0.4, 0.35, 0.25 -
Keep or change the separator.
Example:
, -
Select purchase and sale dates using the calendar buttons.
-
Click Get Data.
-
Review the generated return table.
-
Open charts or statistical summaries from the results window.
The app produces two main CSV outputs:
| File | Purpose |
|---|---|
Data/stocks_returns.csv |
Stores daily weighted portfolio return values. |
Data/more_info.csv |
Stores descriptive statistics generated from the return table. |
Available visualizations:
- Portfolio movement chart — shows the overall movement of the portfolio.
- Profit/loss pie chart — compares the number of profitable and losing days.
- Boxplot — visualizes distribution, median, spread, and outliers.
Main application window. It handles user input for tickers, weights, separators, and dates, then launches the calculation workflow.
Fetches historical stock data using yfinance, calculates weighted portfolio movements, and writes return data to CSV.
Displays calculated portfolio return data in a table and provides actions for charting and advanced information.
Builds Matplotlib visualizations for portfolio movement, profit/loss distribution, and return distribution.
Displays statistical summary data generated with pandas.
Contains SQLite helper functions for reading, writing, and clearing query history.
The repository currently includes a project presentation PDF:
Suggested screenshot layout for future updates:
docs/assets/
├── main-window.png
├── results-table.png
├── portfolio-chart.png
├── statistics-window.png
└── graphs-window.png
After adding screenshots, you can embed them like this:
<p align="center">
<img src="docs/assets/main-window.png" width="48%" alt="Main input window">
<img src="docs/assets/results-table.png" width="48%" alt="Portfolio results table">
</p>A few improvements that would make the project easier to install and maintain:
- Add a
requirements.txtfile. - Add input validation for missing tickers, invalid weights, empty dates, and unmatched ticker/weight counts.
- Use
pathlibfor reliable cross-platform paths. - Ensure
Data/is created automatically before CSV export. - Package the project as an installable Python application.
- Add automated tests for portfolio-return calculations.
- Add GitHub Actions for linting and test execution.
- Add
requirements.txt - Auto-create the
Data/directory - Improve ticker and weight validation
- Persist and replay query history from SQLite
- Add export buttons for generated charts
- Add application theme support
- Add tests for calculation logic
- Build standalone desktop releases with PyInstaller
Contributions are welcome.
-
Fork the repository.
-
Create a feature branch.
git checkout -b feature/your-feature-name
-
Commit your changes.
git commit -m "Add your feature" -
Push the branch.
git push origin feature/your-feature-name
-
Open a pull request.
This project is licensed under the MIT License. See LICENSE.md for details.
Made with Python, PyQt6, pandas, Matplotlib, SQLite, and Yahoo Finance data.
:::