Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. # create empty dataframe for log returns information
  2. log_returns_df = pd.DataFrame()
  3.  
  4. # calculate log returns of each asset
  5. # loop through each column in dataframe and and calculate the daily log returns
  6. # add log returns column to new a dataframe
  7. for col in raw_asset_prices_df.columns:
  8. # dates are given in reverse order so need to set diff to -1.
  9. log_returns_df[col] = np.log(raw_asset_prices_df[col]).diff(-1)
  10.  
  11. #check output of log returns dataframe
  12. log_returns_df.head()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement