-
-
Save quantra-go-algo/3b0a1048c651066f7fd26fde97624b2d 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 smooth graph of close price data | |
from scipy.signal import savgol_filter | |
# To find amount of data in months | |
month_diff = series.shape[0] // 30 | |
# We need value to be greater than 0 | |
if month_diff == 0: | |
month_diff = 1 | |
# Algo to determine smoothness | |
smooth = int(2 * month_diff + 3) | |
# Smooth price data | |
points = savgol_filter(series, smooth, 7) | |
# Plot the smooth price graph over default price graph | |
plt.figure(figsize=(15,7)) | |
plt.title(symbol) | |
plt.xlabel('Days') | |
plt.ylabel('Price') | |
# Close price data | |
plt.plot(series, label=symbol) | |
# Smooth close price data | |
plt.plot(points, label=f'Smooth {symbol}') | |
plt.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment