Created
September 7, 2019 16:54
-
-
Save julian-west/c88bcf7639dbcc1cb1d147155e8d33e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create empty dataframe for log returns information | |
log_returns_df = pd.DataFrame() | |
# calculate log returns of each asset | |
# loop through each column in dataframe and and calculate the daily log returns | |
# add log returns column to new a dataframe | |
for col in raw_asset_prices_df.columns: | |
# dates are given in reverse order so need to set diff to -1. | |
log_returns_df[col] = np.log(raw_asset_prices_df[col]).diff(-1) | |
#check output of log returns dataframe | |
log_returns_df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment