I have a DF of 3 asset returns which I have converted to daily pct change in my notebook
returns = pd.read_csv("Collar Backtest Data.csv",index_col=0)
returns.index = pd.to_datetime(returns.index)
pct_returns=returns.pct_change()
pct_returns
This DF has the date as the index column and then 3 asset class daily % returns
I have then built another DF of 100 rows of random portfolio weights which add up to 1
wdf = pd.DataFrame(np.random.randint(0,100,size=(100, 3)), columns=list('ABC'))
wdf['D'] = wdf.sum(axis=1, numeric_only=True)
wdf[['A', 'B', 'C']] = wdf[['A', 'B', 'C']].div(wdf['D'], axis=0)
wdf = wdf.drop('D', axis=1)
wdf
this dataframe has kept the index column as default and then has 3 columns so the weights in column A apply to the first asset in the returns dataframe
what I would now like to do is apply the weights row by row to the returns dataframe and build up a set of 100 different total portfolio returns including the 3 assets but using the changing portfolio weights.
I have tried iloc on the weights DF to isolate the row and then multiplying the returns DF by this but I just get a df full of NaN’s
Any thoughts on how to do this?
Thanks