1
This commit is contained in:
parent
fbbf48b8f1
commit
7b34e6cd4a
@ -40,8 +40,12 @@ def stratergy_run(symbol, interval, df, debug):
|
||||
d2 = df.iloc[-2]
|
||||
d3 = df.iloc[-3]
|
||||
|
||||
isbullish = d1['isLongArrangement'] == True and d2['isLongArrangement'] == True and d3['isLongArrangement'] == False
|
||||
isBear = d1['isShortArrangement'] == True and d2['isShortArrangement'] == True and d3['isShortArrangement'] == False
|
||||
maxDiff = max(d1['shortDiff'], d1['midDiff'], d1['longDiff'])
|
||||
minDiff = min(d1['shortDiff'], d1['midDiff'], d1['longDiff'])
|
||||
isOffset = maxDiff / minDiff < 3
|
||||
|
||||
isbullish = d1['isLongArrangement'] == True and d2['isLongArrangement'] == True and d3['isLongArrangement'] == False and isOffset == True
|
||||
isBear = d1['isShortArrangement'] == True and d2['isShortArrangement'] == True and d3['isShortArrangement'] == False and isOffset == True
|
||||
|
||||
print(f"{symbol} - {interval} bullish: {isbullish} | bear : {isBear} | LongArrangement: {d1['isLongArrangement']} | ShortArrangement: {d1['isShortArrangement']}")
|
||||
if(isbullish | isBear):
|
||||
|
||||
9
test.py
9
test.py
@ -14,6 +14,10 @@ df['ema10'] = talib.EMA(df['close'], timeperiod=10)
|
||||
df['ema30'] = talib.EMA(df['close'], timeperiod=30)
|
||||
df['ema144'] = talib.EMA(df['close'], timeperiod=144)
|
||||
|
||||
df['shortDiff'] = abs(df['ema5'] - df['ema10']) / df['ema10']
|
||||
df['midDiff'] = abs(df['ema10'] - df['ema30']) / df['ema30']
|
||||
df['longDiff'] = abs(df['ema30'] - df['ema144']) / df['ema144']
|
||||
|
||||
df['isLongArrangement'] = ((df['ema5'] > df['ema10']) & (df['ema10'] > df['ema30']) & (df['ema30'] > df['ema144']))
|
||||
df['isShortArrangement'] = ((df['ema5'] < df['ema10']) & (df['ema10'] < df['ema30']) & (df['ema30'] < df['ema144']))
|
||||
|
||||
@ -22,6 +26,9 @@ d2 = df.iloc[-2]
|
||||
d3 = df.iloc[-3]
|
||||
|
||||
isBear = d1['isShortArrangement'] == True and d2['isShortArrangement'] == True and d3['isShortArrangement'] == False
|
||||
maxDiff = max(d1['shortDiff'], d1['midDiff'], d1['longDiff'])
|
||||
minDiff = min(d1['shortDiff'], d1['midDiff'], d1['longDiff'])
|
||||
isOffset = maxDiff / minDiff < 3
|
||||
|
||||
print(df)
|
||||
print(isBear)
|
||||
print(isOffset)
|
||||
Loading…
Reference in New Issue
Block a user