Portfolio Rebalancer
Calculate buy/sell amounts to rebalance your investment portfolio to target allocations.
| Asset | Current ($) | Current % | Target % | Action |
|---|---|---|---|---|
| US Stocks | $50,000.00 | 55.56% | 60.00% | +$4,000.00 |
| Bonds | $30,000.00 | 33.33% | 30.00% | -$3,000.00 |
| International | $10,000.00 | 11.11% | 10.00% | -$1,000.00 |
| Total | $90,000.00 | 100% | 100.00% |
About this tool
A portfolio rebalancer is an essential tool for investors who want to maintain their target asset allocation over time. Market fluctuations cause your portfolio's actual allocation to drift from your intended targets, which can increase risk or reduce returns. This tool helps you quickly calculate exactly how much of each asset to buy or sell in order to restore your portfolio to its target allocation.
To use the portfolio rebalancer, enter your current holdings and their current market values, then specify your target allocation percentages for each asset class. The tool instantly calculates the dollar or percentage amounts you need to adjust—whether buying underweighted positions or selling overweighted ones. This is particularly valuable for investors managing multiple asset classes, those rebalancing quarterly or annually, or anyone who wants to avoid emotional trading decisions and stick to their strategic plan.
Regular rebalancing helps lock in gains from outperforming assets while buying dips in underperforming ones, a disciplined approach that reduces the temptation to chase trends. Keep in mind that taxes and transaction costs may apply, so consider consulting a financial advisor before executing trades. The tool provides the math; you control when and how to implement the changes.
Frequently Asked Questions
Code Implementation
def rebalance_portfolio(holdings: dict, total_value: float = None) -> dict:
"""
holdings: {'AssetName': {'current_value': 50000, 'target_pct': 60}}
Returns buy/sell amounts needed
"""
if total_value is None:
total_value = sum(h['current_value'] for h in holdings.values())
results = {}
for name, h in holdings.items():
current = h['current_value']
target_pct = h['target_pct']
current_pct = (current / total_value) * 100 if total_value > 0 else 0
target_value = (target_pct / 100) * total_value
diff = target_value - current
results[name] = {
'current': current,
'current_pct': round(current_pct, 2),
'target_pct': target_pct,
'target_value': round(target_value, 2),
'action': round(diff, 2),
'action_type': 'BUY' if diff > 0 else 'SELL' if diff < 0 else 'HOLD'
}
return results
# Example
portfolio = {
'US Stocks': {'current_value': 50000, 'target_pct': 60},
'Bonds': {'current_value': 30000, 'target_pct': 30},
'International': {'current_value': 10000, 'target_pct': 10},
}
result = rebalance_portfolio(portfolio)
total = sum(h['current_value'] for h in portfolio.values())
print(f"Total Portfolio: ${total:,.0f}")
for name, r in result.items():
action = "BUY" if r['action'] > 0 else "SELL"
print(f"{name}: {r['current_pct']}% → {r['target_pct']}% | {action} ${abs(r['action']):,.0f}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.