| name | rebalancing-strategy |
| description | 再平衡策略,支持日历再平衡、阈值再平衡与最优频率分析。适用于组合再平衡理论与实践的。回测未考虑冲击成本、税费与流动性约束,不适用于实盘资产管理,不构成投资建议。 |
| version | 1.0.0 |
| author | wangyi |
rebalancing-strategy
再平衡策略工具,支持日历再平衡、阈值再平衡,并分析最优再平衡频率,仅使用 Python 标准库。
📌 说明:本工具基于简化模型实现,仅使用 Python 标准库。结果仅供学习参考,不构成投资建议。
脚本API
weight_deviations(current_weights, target_weights)
计算权重偏离。
必填: current_weights, target_weights
max_deviation(current_weights, target_weights)
计算最大绝对权重偏离。
必填: current_weights, target_weights
needs_rebalance_threshold(current_weights, target_weights, threshold=0.05, method='absolute')
判断是否需要阈值再平衡。
必填: current_weights, target_weights
calculate_turnover(current_weights, target_weights)
计算再平衡的换手率。
必填: current_weights, target_weights
execute_rebalance(current_weights, target_weights, transaction_cost_rate=0.001)
执行再平衡并计算成本。
必填: current_weights, target_weights
calendar_rebalance_simulation(returns_history, initial_weights, frequency=12, transaction_cost_rate=0.001)
日历再平衡回测模拟。
必填: returns_history, initial_weights
threshold_rebalance_simulation(returns_history, initial_weights, threshold=0.05, method='absolute', transaction_cost_rate=0.001)
阈值再平衡回测模拟。
必填: returns_history, initial_weights
optimal_frequency_analysis(returns_history, initial_weights, frequencies=None, transaction_cost_rate=0.001)
分析不同再平衡频率的效果,寻找最优频率。
必填: returns_history, initial_weights
调用示例
python scripts/main.py \
--returns-history <returns_history> \
--initial-weights <initial_weights> \
--frequencies <frequencies> \
--transaction-cost-rate <transaction_cost_rate>