I am working on a dataset about crypto currency and i want to calculate slope based on different range of data in different time range
from scipy.stats import linregress
slope, intercept, r_value, p_value, std_err = linregress(X, y)
X
is price of BTC in all time and y
is the timestamp.
I want to calculate the slope in range of 7 days and 21 days. How should I do it? I don't know the exact amount of days every time and I want to make 7 or 21 series back to back and if it is less than 7 or 21 days, it should calculate with the fewer amount of days.