Creating Portfolios
Building Portfolios¶
Let’s imagine for a second that we can build portfolios that automatically rebalance each day to a set allocation. I am making this assumption to avoid issues with stocks getting much bigger or smaller than their original allocation. What might a portfolio look like in comparison to the other two stocks on their own? Let’s take a look at our first two stocks and get some statistics on them.
In [36]:
#Get the first two sets of stock returns
r1 = stock_returns[0]
r2 = stock_returns[1]
#Print out statistics on them
print("Mean Daily Return:")
print("Stock 1: {}".format(np.mean(r1)))
print("Stock 2: {}".format(np.mean(r2)))
print()
print("Standard Deviation:")
print("Stock 1: {}".format(np.std(r1)))
print("Stock 2: {}".format(np.std(r2)))
print()
print("Correlation:")
print(np.corrcoef(r1, r2)[0,1])
What about a portfolio of 50%/50% these two, what is the return and standard deviation then?
In [37]:
portfolio_returns = r1 * .5 + r2 * .5
print("Mean Daily Return:")
print("Stock 1: {}".format(np.mean(r1)))
print("Stock 2: {}".format(np.mean(r2)))
print("Portfolio: {}".format(np.mean(portfolio_returns)))
print()
print("Standard Deviation:")
print("Stock 1: {}".format(np.std(r1)))
print("Stock 2: {}".format(np.std(r2)))
print("Portfolio: {}".format(np.std(portfolio_returns)))
print()