Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Modified Heatmap Based on Grant Kiehne's Example

Inspired by Grant Kiehne's example, this version has vectorized Z calculations and an alternate Seaborn heatmap.

3 responses

In case you can't see the notebook, here's the gist of the Z calculation, along with the heatmap image.

volumes = data.iloc[:, 0:2]  
means = volumes.apply(lambda x: pd.rolling_mean(x, window=MINUTES_PER_MARKET_DAY))  
sds = volumes.apply(lambda x: pd.rolling_std(x, window=MINUTES_PER_MARKET_DAY))  
zs = ((volumes - means) / sds)  
data['z_diff'] = zs.iloc[:, 1] - zs.iloc[:, 0]  

Heatmap Image

Thanks Michael,

Did you actually compare the computation times for the two approaches? Although you vectorized the z-score computation, there are still rolling computations for the means & standard deviations. So, I'm wondering if there ends up being an actual computational efficiency improvement.

Grant

The original takes about 81 seconds, while the new version takes about 0.01 seconds.