Skip to main content

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&region=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.csv in 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yfinance_viz-0.2.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yfinance_viz-0.2.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file yfinance_viz-0.2.0.tar.gz.

File metadata

  • Download URL: yfinance_viz-0.2.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for yfinance_viz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 91fed1315e3049d349226371760eed559f5ecea8b4b845f00b6c1ccf6f251176
MD5 a35589f8e68104c2e1ffe31cbdb1aa1c
BLAKE2b-256 a03894c2a9e4cf695603639e6de373a676d7b62d5a524ec91e4abbdcf96d124b

See more details on using hashes here.

File details

Details for the file yfinance_viz-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for yfinance_viz-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0112b5c00a140cf916ef9cbdd4f43d5f97d63e32bbe11834ccfbcea53f16ebae
MD5 f42eb9777340b6b18a01d43ca4d52ab2
BLAKE2b-256 f6ada87d3368f2f754803581cd174a6e185502b459e3ff0e0a4aacbf3e4b2faa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page