feat(Data): added new derived features + asset pairs for crypto tickers (#6)

This commit is contained in:
Mark Aron Szulyovszky
2021-11-17 12:07:49 +01:00
committed by GitHub
parent b0b0d5bbba
commit 3fec439c08
72 changed files with 78660 additions and 12513 deletions
+29
View File
@@ -0,0 +1,29 @@
import pandas as pd
import numpy as np
def STOK(close, low, high, n):
STOK = ((close - low.rolling(n).min()) / (high.rolling(n).max() - low.rolling(n).min())) * 100
return STOK
def STOD(close, low, high, n):
STOK = ((close - low.rolling(n).min()) / (high.rolling(n).max() - low.rolling(n).min())) * 100
STOD = STOK.rolling(3).mean()
return STOD
def RSI(series, period):
delta = series.diff().dropna()
u=delta*0
d = u.copy()
u[delta > 0] = delta[delta > 0]
d[delta < 0] = -delta[delta < 0]
u[u.index[period-1]] = np.mean( u[:period] ) #first value is sum of avg gains u = u.drop(u.index[:(period-1)])
d[d.index[period-1]] = np.mean( d[:period] ) #first value is sum of avg losses d = d.drop(d.index[:(period-1)])
rs = u.ewm(com=period-1, adjust=False).mean() / \
d.ewm(com=period-1, adjust=False).mean()
return 100-100/(1+rs)
def ROC(df, n):
M = df.diff(n - 1)
N = df.shift(n - 1)
ROC = pd.Series(((M / N) * 100), name = 'ROC_' + str(n))
return ROC