Skip to content

Instantly share code, notes, and snippets.

@silgon
Last active April 20, 2022 18:46
Show Gist options
  • Save silgon/65b4932c007aca40dd5a0a79242be05c to your computer and use it in GitHub Desktop.
Save silgon/65b4932c007aca40dd5a0a79242be05c to your computer and use it in GitHub Desktop.
peak_indicator
import pandas_datareader as pdr
import matplotlib.pyplot as plt
from statsmodels.tsa.arima_model import ARIMA
from scipy.signal import find_peaks
data = pdr.get_data_yahoo("FR.PA")
data_ = data[data.index>"2017"]
# find_peaks(data_["Volume"])
peaks = find_peaks(data_["Volume"],threshold=10**6)[0]
plt.clf()
plt.subplot(211)
plt.plot(data_.index, data_["Close"], linewidth=1)
plt.ylabel("Price (€)")
for peak in data_.index[peaks]:
plt.axvline(x=peak, color='gray', linestyle='--', linewidth=1, alpha=0.5)
plt.subplot(212)
plt.plot(data_.index, data_["Volume"], linewidth=1)
for peak in data_.index[peaks]:
plt.axvline(x=peak, color='gray', linestyle='--', linewidth=1, alpha=0.5)
plt.ylabel("Volume")
plt.xlabel("Date")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment