简体   繁体   English

优化权重的月度投资组合再平衡

[英]Monthly Portfolio Rebalancing from Optimized Weights

I have daily stock Returns which are optimizated by lets say the Minimum variance algorithm.我有通过最小方差算法优化的每日股票收益。 This gives me an Output of daily optimal weights.这给了我每日最佳重量的输出。 If I rebalance the Portfolio every day with the new optimal weights, I just lag the Returns by one period and multiply the optimal weights * Returns.如果我每天都用新的最佳权重重新平衡投资组合,我只是将回报滞后一个周期,然后乘以最佳权重 * 回报。

However, I am quite confused how to test for monthly rebalancing.但是,我很困惑如何测试每月重新平衡。 What I want is basically Keep the optimization with daily Returns but only use the optimal weights calculated at the end of the month for the next 30 days.我想要的基本上是保持每日收益的优化,但仅在接下来的 30 天内使用月底计算的最佳权重。

How is that usually done?通常是怎么做的? If I set the next 30 day weights equal the optimal weight from the last day of the previous month, and mulitply with the Returns, isnt that also some Kind of daily rebalancing, but just with the old weights?如果我将接下来的 30 天权重设置为与上个月最后一天的最佳权重相等,并与收益相乘,那不也是某种每日重新平衡,而只是使用旧权重?

I am quite confused how to do that.我很困惑如何做到这一点。 Please find below an example how the data might look like for 1 time series of stock Returns and optimal daily weights.请在下面找到一个示例,了解 1 个股票回报时间序列和最佳每日权重的数据可能是什么样子。

import numpy as np
import numpy.random as nrand
import pandas as pd


date = pd.date_range(start='12/31/2017', periods=60)
returns = pd.DataFrame(nrand.uniform(-0.1, 0.1, 60))
weights = pd.DataFrame(nrand.uniform(0, 1, 60))

weights_returns = pd.concat([returns,weights],axis=1)
weights_returns["date"] = date
weights_returns = weights_returns.set_index("date")
weights_returns.columns.values[0] = "weights"
weights_returns.columns.values[1] = "returns"

print(weights_returns)

I feel you are asking both financial and pandas questions here.我觉得你在这里问的是金融问题和熊猫问题。 If you are okay with propagating last day weight to the next month, then merge_asof is your friend.如果您可以将最后一天的重量传播到下个月,那么merge_asof就是您的朋友。

weight_month_end = (weights_returns['weights'].resample('M')
                                              .last()
                                              .rename('weight_new'))

pd.merge_asof(weights_returns, weight_month_end,left_index=True,right_index=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM