Skip to content

Instantly share code, notes, and snippets.

@alexrios22
Created November 22, 2020 22:03
Show Gist options
  • Save alexrios22/e4a25acd725efe7d460030d173431c4f to your computer and use it in GitHub Desktop.
Save alexrios22/e4a25acd725efe7d460030d173431c4f to your computer and use it in GitHub Desktop.
Trend.ibpynb
window = 253
# detrend tome series by MA
ratesM = data['Adj Close'].rolling(window).mean().dropna()
ratesD = data['Adj Close'].reindex(ratesM.index).sub(ratesM)
fig, axs = plt.subplots(2, figsize=(16, 8), sharex=True)
data['Adj Close'].plot(ax=axs[0], title="Trend")
ratesM.plot(ax=axs[0])
ratesD.plot(ax=axs[1], c="g", title="Residuals");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment