Skip to main content

A CLI tool for contribution-only portfolio rebalancing.

Project description

Portfolio Rebalancer

A CLI tool designed to help investors maintain their target asset allocation through contribution-only rebalancing.

PyPI version Python 3.10+

output_example

This project was built using Gemini CLI to explore AI-driven development for architectural designs, scaffolding, and code generation.

Motivation

I originally managed my investments and rebalancing through a spreadsheet. I ported the logic to a CLI tool to achieve:

  • Workflow efficiency. Faster execution and a foundation for future automation.
  • Version control. My investment strategy and portfolio can now be tracked with Git.
  • Reliability. All logic lies within modules that are invisible to the user. No more accidental formula breaks!

Features

  • Tax-Efficient Logic: Prioritizes buying underweight assets, never selling.
  • JSON Portfolios: Load your custom portfolio from a simple json file.
  • Proportional Scaling: Handles contributions that are too small to fill all gaps perfectly.
  • Modern Python: Built with type hints, dataclasses, and a modular package structure.

Installation

Install the tool directly from PyPI:

pip install portfolio-rebalancer-cli

Usage

  1. Configure your portfolio: Create a portfolio.json file in your current directory using the following format, adding asset classes and adjusting according to your portfolio:

    {
      "assets": [
        {
          "name": "US Total Stock",
          "target_allocation": 0.60,
          "current_balance": 6000.00
        },
        {
          "name": "International Stock",
          "target_allocation": 0.30,
          "current_balance": 2000.00
        },
        {
          "name": "Bond Market",
          "target_allocation": 0.10,
          "current_balance": 2000.00
        }
      ]
    }
    
  2. Run the rebalancer:

    • Default Mode (looks for portfolio.json in current folder):

      rebalance --contribution 1000
      
    • Custom File Mode:

      rebalance --contribution 1000 --file my_custom_portfolio.json
      

Development & Testing

If you want to contribute or run the tests:

git clone https://github.com/aaronCruise/Portfolio-Rebalancer.git
cd Portfolio-Rebalancer
pip install -e .
pytest

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

portfolio_rebalancer_cli-0.2.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

portfolio_rebalancer_cli-0.2.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for portfolio_rebalancer_cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4a0b7fa2e5d2e2f24c1cd74f1adb158b8efe55c3a02545f36fdee51de1a87f17
MD5 f5355b6bc0b802530f5e417c70c84a49
BLAKE2b-256 b6f1267cb3c3519ae247a351168c99b7421b92e64c729b8b8e9150620cfb9a9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for portfolio_rebalancer_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27ed8b1d0a4c9f6ae9a7c64dea7039b7ffdcfeca3611294a37c7bcf6ab6e9ab1
MD5 ee40aaf39f185f804ec299a7e8da82b4
BLAKE2b-256 0f3f95f2f8cc31ce56a9f56f0b27f5f6e726d4600c2bbb6a49661f5df901d0c1

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