This commit is contained in:
aaron 2024-09-18 17:51:12 +08:00
parent da3c2836c0
commit 9d309a38d2
4 changed files with 20 additions and 37 deletions

View File

@ -1,12 +1,10 @@
import requests
from discord_webhook import DiscordWebhook, DiscordEmbed
def send_message(url,title,content):
webhook = DiscordWebhook(url)
mUrl = "https://discordapp.com/api/webhooks/1285867836454998077/JNAFUyur_ygOJIh6C4beUAVYMpm1TZf4IEeMn8Q1p0TglO1Hjyiu2LQqiU5AxVovWyiO"
embed = DiscordEmbed(title=title, description=content, color="03b2f8")
def send_message(content):
data = {"content": content}
response = requests.post(mUrl, json=data)
webhook.add_embed(embed)
print(response.status_code)
print(response.content)
response = webhook.execute()

View File

@ -57,7 +57,10 @@ def stratergy_run(symbol, interval, df, debug):
message += f"收盘价: {d1['close']}\r\n"
dingding.send_message(message, isAtAll=True)
telegram_sender.send_message(setting.chat_id, message)
discord_sender.send_message(message)
url = 'https://discordapp.com/api/webhooks/1285867836454998077/JNAFUyur_ygOJIh6C4beUAVYMpm1TZf4IEeMn8Q1p0TglO1Hjyiu2LQqiU5AxVovWyiO'
discord_sender.send_message(url,'信号提醒',message)
def run_crypto(interval, debug=False):

View File

@ -5,4 +5,5 @@ pandas
requests
schedule
TA_Lib
tweepy
tweepy
discord_webhook

35
test.py
View File

@ -3,37 +3,18 @@ from monitors import move
from datasource import crypto
import talib
import discord_sender
# # move.run_crypto('5m')
# df = crypto.get_klines('PEOPLEUSDT', '5m')
from binance.cm_futures import CMFutures
# ## 计算 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)
client = CMFutures()
data = client.funding_rate('BTCUSD_PERP', limit=1)
# 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']
fundingRate = float(data[0]['fundingRate']) * 100
# 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)
text = f"币种: {data[0]['symbol']}\r\n资金费率: {fundingRate} %"
discord_sender.send_message('https://www.youtube.com/watch?v=_yI5SYTMo0U')
mUrl = "https://discordapp.com/api/webhooks/1285898004641091605/DwIh9yZvrU6TwelVmJr96XBdpFTEEpeFD8GsZpH7rBdwT4UwVyZTrtdmBzS4ae0Ta7PH"
discord_sender.send_message(mUrl, '消息内容',text)