Session Ready
Exercise

Join stock DataFrames and calculate returns

Our first step towards calculating modern portfolio theory (MPT) portfolios is to get daily and monthly returns. Eventually we're going to get the best portfolios of each month based on the Sharpe ratio. The easiest way to do this is to put all our stock prices into one DataFrame, then to resample them to the daily and monthly time frames. We need daily price changes to calculate volatility, which we will use as our measure of risk.

Instructions
100 XP
  • Join together lng_df, spy_df, and smlv_df using pd.concat() into the full_df DataFrame.
  • Resample the full_df to Business Month Start ('BMS') frequency.
  • Get the daily percent change of full_df with .pct_change().