简体   繁体   中英

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.

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?

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.

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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