Portfolio Tools Documentation

Python Version License Documentation

Portfolio Toolkit is a comprehensive Python library for portfolio management, analysis, and visualization. It supports multi-currency portfolios with automatic currency conversion, FIFO cost calculation, and advanced analytics.

Features

  • Multi-Currency Support: Handle portfolios with transactions in different currencies (USD, EUR, CAD, etc.)

  • FIFO Cost Calculation: Accurate cost basis tracking using First-In-First-Out methodology

  • Automatic Currency Conversion: Real-time currency conversion with configurable exchange rates

  • Portfolio Analytics: Comprehensive analysis tools including returns, composition, and evolution tracking

  • Data Visualization: Rich plotting capabilities for portfolio composition and performance analysis

  • CSV Export: Export transaction data and portfolio positions to CSV format

  • CLI Interface: Powerful command-line tools built with Click for portfolio analysis, data visualization, and market research

Quick Start

Installation

pip install portfolio-toolkit

Basic Usage (CLI)

The easiest way to get started is using the command-line interface:

# View available commands
portfolio-toolkit --help

# Show current portfolio positions
portfolio-toolkit portfolio positions portfolio.json 2025-07-30

# View portfolio transactions
portfolio-toolkit portfolio transactions portfolio.json

# Analyze performance over time
portfolio-toolkit portfolio performance portfolio.json

# Generate portfolio evolution chart
portfolio-toolkit portfolio evolution portfolio.json

Library Usage

For programmatic access, you can use the Python library:

from portfolio_toolkit.data_provider.yf_data_provider import YFDataProvider
from portfolio_toolkit.portfolio.load_portfolio_json import load_portfolio_json
from portfolio_toolkit.cli.commands.utils import load_json_file

# Load portfolio
data = load_json_file('portfolio.json')
data_provider = YFDataProvider()
portfolio = load_portfolio_json(data, data_provider=data_provider)

For detailed library usage, see Basic Usage Examples.

Portfolio JSON Format

Create a portfolio JSON file to get started. For detailed format documentation, see Portfolio JSON Format.

{
  "name": "My Investment Portfolio",
  "currency": "USD",
  "account": [
    {
      "date": "2023-01-15",
      "type": "deposit",
      "amount": 10000,
      "currency": "USD"
    }
  ],
  "assets": [
    {
      "ticker": "AAPL",
      "transactions": [
        {
          "date": "2023-01-20",
          "type": "buy",
          "quantity": 50,
          "price": 150.25,
          "currency": "USD"
        }
      ]
    },
    {
      "ticker": "MSFT",
      "transactions": [
        {
          "date": "2023-02-10",
          "type": "buy",
          "quantity": 30,
          "price": 280.50,
          "currency": "USD"
        }
      ]
    }
  ]
}

Command Line Interface

The CLI provides powerful tools for portfolio analysis:

# Portfolio analysis commands
portfolio-toolkit portfolio transactions portfolio.json              # View transactions
portfolio-toolkit portfolio positions portfolio.json 2025-07-30     # Current positions
portfolio-toolkit portfolio performance portfolio.json               # Performance analysis
portfolio-toolkit portfolio evolution portfolio.json                 # Evolution chart

# Export options
portfolio-toolkit portfolio transactions portfolio.json --output transactions.csv
portfolio-toolkit portfolio performance portfolio.json --output performance.csv

# Performance analysis with different time periods
portfolio-toolkit portfolio performance portfolio.json --period-type months -n 6
portfolio-toolkit portfolio performance portfolio.json --period-type quarters -n 4

For comprehensive CLI documentation, see CLI Usage Examples.

Examples

User Guide

API Reference

Testing

Indices and Tables