Portfolio Rebalancer
计算买卖数量以将投资组合重新平衡至目标配置。
资产名称
当前价值($)
目标%
%
%
%
| 资产 | 当前($) | 当前% | 目标% | 操作 |
|---|---|---|---|---|
| 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 |
| 总计 | $90,000.00 | 100% | 100.00% |
= 超配(卖出)
= 配置不足(买入)
已平衡
关于此工具
投资组合再平衡工具是想要长期保持目标资产配置的投资者的必需工具。市场波动会导致投资组合的实际配置与既定目标发生偏离,这可能增加风险或降低收益。此工具可帮助您快速计算出每项资产需要买入或卖出的具体金额,以便将投资组合恢复到目标配置。
要使用投资组合再平衡工具,请输入您当前持有的资产及其当前市场价值,然后为每个资产类别指定目标配置百分比。该工具会立即计算出您需要调整的金额或百分比,无论是买入低配资产还是卖出高配资产。这对于管理多个资产类别的投资者、按季度或年度进行再平衡的人,或希望避免情感化交易决策、坚持战略计划的任何人都特别有用。
定期再平衡有助于锁定表现优异资产的收益,同时在表现不佳的资产出现下跌时买入,这是一种有纪律的做法,可以减少追逐趋势的诱惑。请注意,税款和交易费用可能适用,因此在执行交易前建议咨询财务顾问。该工具提供数学计算,您则掌控实施变更的时机和方式。
常见问题
代码实现
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.