mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-09 09:07:49 +00:00
chore(Linter): reformatted code with black (#211)
* chore(Linter): reformatted code with black * Create black.yaml
This commit is contained in:
committed by
GitHub
parent
f3fee4a4e1
commit
8dd2d88740
@@ -1,29 +1,43 @@
|
||||
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
|
||||
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
|
||||
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
|
||||
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)
|
||||
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
|
||||
ROC = pd.Series(((M / N) * 100), name="ROC_" + str(n))
|
||||
return ROC
|
||||
|
||||
Reference in New Issue
Block a user