trading-quant/test.py
2024-09-18 16:17:22 +08:00

40 lines
1.3 KiB
Python

import requests
from monitors import move
from datasource import crypto
import talib
import discord_sender
# # move.run_crypto('5m')
# df = crypto.get_klines('PEOPLEUSDT', '5m')
# ## 计算 ema
# df['ema5'] = talib.EMA(df['close'], timeperiod=5)
# 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']))
# d1 = df.iloc[-1]
# 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(isOffset)
discord_sender.send_message('https://www.youtube.com/watch?v=_yI5SYTMo0U')