Yahoo Finance Portfolio Visualizer - A Python tool for downloading and visualizing stock portfolio transactions using Yahoo Finance data
Project description
yfinance-viz
Yahoo Finance Portfolio Visualizer - A Python tool for downloading and visualizing stock portfolio transactions using Yahoo Finance data.
Features
- Transaction Parser: Converts Yahoo Finance portfolio JSON exports to CSV format
- Stock History Downloader: Automatically downloads historical stock data for portfolio tickers
- Portfolio Visualization: Creates interactive Sankey diagrams showing fund flows between positions
- Multi-currency Support: Handles USD/EUR conversions automatically
- Command-Line Tools: Easy-to-use CLI commands for all functionality
Installation
pip install yfinance-viz
Usage
Using CLI Commands
After installation, you can use the convenient CLI commands:
# Parse transactions from your portfolio data directory
yfinance-viz-parse --resources-path /path/to/my/portfolio/data
# Download stock history to your portfolio data directory
yfinance-viz-download --resources-path /path/to/my/portfolio/data
# Generate visualization from your portfolio data directory
yfinance-viz-visualize --resources-path /path/to/my/portfolio/data
Workflow
1. Export Your Portfolio Data
Determine your portafolio ID by going to and looking for the p_0 or similar in the path when opening the portafolio in:
https://finance.yahoo.com/portfolios/
Download your portfolio transactions from Yahoo Finance:
https://query1.finance.yahoo.com/ws/portfolio-api/v1/portfolio/transactions?pfId=YOUR_PORTFOLIO_ID&category=trades&groupByPositionId=true&lang=en-US®ion=US
Save the JSON file in your chosen resources directory (e.g., my_portfolio_data/my_portfolio.json).
2. Parse Transactions
yfinance-viz-parse --resources-path /path/to/my/portfolio/data
This will:
- Prompt you to select which JSON files to process
- Convert transactions to CSV format
- Save as
transactions.csvin your resources directory
3. Download Stock History
yfinance-viz-download --resources-path /path/to/my/portfolio/data
Downloads historical price data for all tickers in your transactions.
4. Generate Visualization
yfinance-viz-visualize --resources-path /path/to/my/portfolio/data
Creates an interactive Sankey diagram showing fund flows between your portfolio positions.
Project Structure
yfinance-viz/
├── yfinance_viz/ # Main module
│ ├── __init__.py
│ ├── transaction_parser.py
│ ├── download_stock_history.py
│ └── transactions_visualize.py
├── tests/ # Comprehensive test suite
├── pyproject.toml # Project configuration
└── README.md
Command-Line Options
All scripts require the following argument:
--resources-path: Path to the directory containing your portfolio data- Required: This argument must be provided
- Example:
--resources-path /Users/john/my_portfolio_data
Development
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=yfinance_viz
Privacy
- All personal portfolio data should be stored in your chosen resources directory
- The tool processes local files only - no data is sent to external services
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yfinance_viz-0.1.0.tar.gz.
File metadata
- Download URL: yfinance_viz-0.1.0.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f841a5761ee2662822ef79d27f7fbc1ef14d90c470f564ec032949b76bd18fa
|
|
| MD5 |
9389e54a069abbe5b976867e030b33b4
|
|
| BLAKE2b-256 |
f2d24a0af50d94ce4c1e9f3a53b2b2818b11758b7aab2606b9019a2f4fbb88ac
|
File details
Details for the file yfinance_viz-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yfinance_viz-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de3b61cc87c8ae90f7ad9af34946549f36ee4bfbbe634ba7bb4d38a26bcdefd5
|
|
| MD5 |
8407006ae7941c21d73091934b1bc997
|
|
| BLAKE2b-256 |
42908880ad5420b7843227c95ec80f54371a7356e8a252c45025ef949d2931c9
|