I am trying to 'calculate the weighted return for my portfolio assuming assuming an equal number of shares for each stock'. I am looking at three stocks.
I combined all three stocks as so:
my_portfolio = pd.concat([appl_df, cost_df, goog_df], axis='columns', join='inner')
my_portfolio.columns = ['APPL', 'COST', 'GOOG']
my_portfolio_return = my_portfolio.sort_index()
my_portfolio_return.head()
Now I tried to set the weights as follow and then calculate my weighted portfolio; the only thing is I am not sure if I am using the correct syntax (dot).
# Set weights
weights = [1/3, 1/3, 1/3]
# Calculate portfolio return
weighted_portfolio = my_portfolio_return.dot(weights)
weighted_portfolio.sum
weighted_portfolio
Can anyone tell me what I'm doing wrong?
Try normalizing each of the three stocks to a maximum ceiling value like a percentage or something.
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.