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 and Codex to explore AI-driven development for architectural designs, scaffolding, code generation, and iterative feature work.

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.3.0.tar.gz (7.0 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.3.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for portfolio_rebalancer_cli-0.3.0.tar.gz
Algorithm Hash digest
SHA256 793ebfc1f69b91f2b01e4cab958e021fbfdac7e73e41e0a237c0695a4c93ace2
MD5 03c6c7566849ec2791135c434ef13429
BLAKE2b-256 6280138070e752625fb5b5886d490dd5ea724afc3181f6c59111ddece3e42c7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for portfolio_rebalancer_cli-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c409ddc8db8e3d8682a0572f698b134b197a40466cb3e9dbc492e0b27e7c1096
MD5 906606ea17d580744fdfe72a3106e01c
BLAKE2b-256 66d46885dcaa955dfcc659da0cd15b90f075584139f6672ce98daae6b50b08b1

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