Know exactly how much to buy or sell to hit your target crypto portfolio allocation.
This CLI takes your current holdings and target percentages, fetches live prices from CoinGecko (free), and tells you exactly what to trade. No spreadsheets needed.
What It Does
python3 rebalance.py --current SOL:10 ETH:2 BTC:0.5 --target 'SOL:40%' 'ETH:40%' 'BTC:20%'
Output:
ASSET CURRENT TARGET % USD VAL TARGET DIFF ACTION
SOL 10.0000 40% $840.00 4.7059 -5.2941 SELL 5.29 ($444.70)
ETH 2.0000 40% $6,200.00 1.8824 -0.1176 SELL 0.12 ($364.56)
BTC 0.5000 20% $30,000.00 0.9412 +0.4412 BUY 0.44 ($26,470.40)
Save and load configs:
python3 rebalance.py --current SOL:10 ETH:2 --target 'SOL:60%' 'ETH:40%' --save my_portfolio.json
python3 rebalance.py --load my_portfolio.json --target 'SOL:50%' 'ETH:50%'
JSON mode:
python3 rebalance.py --current SOL:10 --target 'SOL:100%' --json
Install
No pip needed:
curl -L https://raw.githubusercontent.com/neuralmint/portfolio-rebalance/main/rebalance.py -o rebalance.py
python3 rebalance.py --help
Or clone:
git clone https://github.com/neuralmint/portfolio-rebalance.git
cd portfolio-rebalance
python3 rebalance.py --help
Support
SOL: 4TGyiYBjaYhFFPNYyCoJjf16ctUsWVBiMR1FXQxEfhWi
ETH: 0xe07f177E0725c11EEc8BeA34C5b5193CaF2a1A6a
Follow for more Python tools.
Top comments (0)