Portfolio Rebalancer
A CLI tool designed to help investors maintain their target asset allocation through contribution-only rebalancing.
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
jsonfile. - Proportional Scaling: Handles contributions that are too small to fill all gaps perfectly.
- Command-Line Values: Enter current asset values without editing the JSON file.
- 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
-
Configure your portfolio: Create a
portfolio.jsonfile 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 } ] }
-
Run the rebalancer:
-
Default Mode (looks for
portfolio.jsonin current folder):rebalance --contribution 1000
The shorter contribution flag is also supported:
rebalance -c 1000
-
Enter Values Directly:
rebalance -c 1000 --value "US Total Stock=6000" --value "International Stock=2500"
Add
--save-valuesto save the entered values to the portfolio file. -
Clear Current Values:
rebalance clearThis sets all current balances to zero while keeping the rest of the portfolio unchanged.
-
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
Metadata
Release files for portfolio-rebalancer-cli 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| portfolio_rebalancer_cli-0.4.0.tar.gz | 8.5 kB | Without provenance | Details for portfolio_rebalancer_cli-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| portfolio_rebalancer_cli-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for portfolio_rebalancer_cli-0.4.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / portfolio_rebalancer_cli-0.4.0.tar.gz
| Download URL | portfolio_rebalancer_cli-0.4.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ac1842aaabece43892d7e13c05963ea0cea69a41549c96637f5966d1051d8ae
|
|
BLAKE2b-256 checksum How to use checksums |
0b5bc7074112a5105f95aa02cfe46888c7dda021eb0a05719f42cc6fb6c5dc2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / portfolio_rebalancer_cli-0.4.0-py3-none-any.whl
| Download URL | portfolio_rebalancer_cli-0.4.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ade3afd054ee9feba61b7b29479b046093ac33d50ed4d65b95ccddc6f848c9b
|
|
BLAKE2b-256 checksum How to use checksums |
b9c987c3d00bb2bb2e3f132dcc68d8c93304226a105e2acc95df25ea1d932c2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for portfolio-rebalancer-cli 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.