April 2019
Intermediate to advanced
426 pages
11h 13m
English
Visualizing correlations can also be achieved with the rolling() command. We will use the Last prices of ABN and SANTA on a daily basis from 2016 to 2017, from Quandl. The two datasets are downloaded to the DataFrame df, and its rolling correlations plotted as follows:
In [ ]: %matplotlib inline import quandl quandl.ApiConfig.api_key = QUANDL_API_KEY df = quandl.get(['EURONEXT/ABN.4', 'EURONEXT/SANTA.4'], start_date='2016-01-01', end_date='2017-12-31') df_filled = df.asfreq('D', method='ffill') daily_changes= df_filled.pct_change() abn_returns = daily_changes['EURONEXT/ABN - Last'] santa_returns = daily_changes['EURONEXT/SANTA - Last'] window = int(len(df_filled.index)/2) df_corrs = abn_returns\ .rolling(window=window, ...Read now
Unlock full access