From c619cf32758acd44898e06472d54ed3da19e4616 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Thu, 14 Nov 2024 13:41:55 +0800 Subject: [PATCH] update --- datasource/crypto.py | 1 - dingding.py | 2 +- main.py | 32 ++++++++++++++++++++------------ monitors/vol_up.py | 34 ++++++++++++++++++++++++++++++++++ setting.py | 4 ++++ test.py | 15 ++++++++------- 6 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 monitors/vol_up.py diff --git a/datasource/crypto.py b/datasource/crypto.py index 73f2a1a..a221d2f 100644 --- a/datasource/crypto.py +++ b/datasource/crypto.py @@ -67,7 +67,6 @@ def get_symbols(): def get_future_symbols(): data = future_client.exchange_info()["symbols"] - print(data) # 创建DataFrame columns = ['symbol', 'status','contractType', 'baseAsset', 'quoteAsset'] diff --git a/dingding.py b/dingding.py index 2c1be33..b3fb4da 100644 --- a/dingding.py +++ b/dingding.py @@ -2,7 +2,7 @@ import requests import setting import urllib3 -url = 'https://oapi.dingtalk.com/robot/send?access_token=c197bfacc77010e92804ecdbb6a6e0f95f86d9e7e4968fb35ec68720eeec8fa8' +url = 'https://oapi.dingtalk.com/robot/send?access_token=2278b723cd363bb6f85592c743b59b166e70b9e02a275bb5cedbc33b53a5cbdc' # 发送消息 def send_message(text, isAtAll = False): diff --git a/main.py b/main.py index 6f21c0f..3e3fd56 100644 --- a/main.py +++ b/main.py @@ -1,21 +1,27 @@ import schedule import time - +import dingding import monitors.jin10_cal as jin10 -from monitors import vegas, vegas_cross, macd_boll +from monitors import macd_boll,vol_up #vegas -schedule.every().hour.at(":00").do(vegas.run_crypto, interval = '1h') -times = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00"] -for t in times: - schedule.every().day.at(t).do(vegas.run_crypto, interval = '4h') +# schedule.every().hour.at(":00").do(vegas.run_crypto, interval = '1h') +# times = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00"] +# for t in times: +# schedule.every().day.at(t).do(vegas.run_crypto, interval = '4h') #vegas_cross -schedule.every().hour.at(":00").do(vegas_cross.run_crypto, interval = '1h') -times = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00"] -for t in times: - schedule.every().day.at(t).do(vegas_cross.run_crypto, interval = '4h') +# schedule.every().hour.at(":00").do(vegas_cross.run_crypto, interval = '1h') +# times = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00"] +# for t in times: +# schedule.every().day.at(t).do(vegas_cross.run_crypto, interval = '4h') + + +#vol +schedule.every(5).minutes.do(vol_up.run_crypto, interval = '5m') +schedule.every().hour.at(":00").do(vol_up.run_crypto, interval = '1h') + #macd_boll schedule.every().hour.at(":00").do(macd_boll.run_crypto, interval = '15m') @@ -31,8 +37,10 @@ for t in times: #jin10 schedule.every().day.at("00:00").do(jin10.run) -version = 'V1.23' -print(f'Running... {version}') +version = 'V1.3' +text = f'☕️ Signals running... {version} !' +print(text) +dingding.send_message(text) while True: schedule.run_pending() time.sleep(1) \ No newline at end of file diff --git a/monitors/vol_up.py b/monitors/vol_up.py new file mode 100644 index 0000000..3debc20 --- /dev/null +++ b/monitors/vol_up.py @@ -0,0 +1,34 @@ +# 突然放量策略 +import numpy as np +import datasource,time, dingding + +def stratergy_run(symbol, interval, df, debug): + # 计算过去 30 根 K 线的平均交易量 + average_volume = df["volume"].iloc[-31:-1].mean() # 倒数第 31 到倒数第 2 根的平均 + + # 获取当前(最后一根,即第 500 根)交易量 + current_volume = df["volume"].iloc[-1] + + timestamp = df['timestamp'].iloc[-1] + + rate = current_volume / average_volume + print(f"【{timestamp}】【{symbol}】当前交易量: {current_volume} , 平均交易量: {average_volume} , 倍数: {rate}") + + if rate > 3: + message = "📢信号提醒📢\r\n\r\n" + message += f"{symbol} 在 {interval} 出现放量!\r\n\r\n" + message += timestamp + + if debug == False: + dingding.send_message(message, True) + print(f"【{symbol} - {interval}】 is singal fired!") + else: + print(message) + +def run_crypto(interval, debug=False): + symbols = datasource.crypto.get_future_symbols() + for s in symbols: + df = datasource.crypto.get_klines(s, interval, True,limit=50) + stratergy_run(s,interval, df, debug) + + time.sleep(1) \ No newline at end of file diff --git a/setting.py b/setting.py index 04c8bed..0e3c010 100644 --- a/setting.py +++ b/setting.py @@ -8,3 +8,7 @@ chat_id = os.getenv("TQ_CHAT_ID", "@cyber4trading") symbols = ['BTCUSDT',"ETHUSDT",'LTCUSDT','DOGEUSDT','FTMUSDT','FILUSDT','OPUSDT','SOLUSDT','BNBUSDT','BCHUSDT','ETCUSDT','ARUSDT',"REEFUSDT","BONDUSDT","VIDTUSDT","UNFIUSDT"] + + +#dingding bot +singal_bot_url = 'https://oapi.dingtalk.com/robot/send?access_token=2278b723cd363bb6f85592c743b59b166e70b9e02a275bb5cedbc33b53a5cbdc' \ No newline at end of file diff --git a/test.py b/test.py index 9c211fc..e8f17b6 100644 --- a/test.py +++ b/test.py @@ -4,7 +4,7 @@ from monitors import move from datasource import crypto import talib import discord_sender -from monitors import vegas_cross, jin10_cal +from monitors import vegas_cross, jin10_cal,vol_up from datasource import crypto from monitors import macd_boll import datasource @@ -12,6 +12,7 @@ from binance.um_futures import UMFutures import redis +vol_up.run_crypto('1h') @@ -31,14 +32,14 @@ import redis -key = 'QSZvYevTytwi8CJEkiUqqlZRQBOjIa23BoB8wFwTSY26GBAFkViTExex2mFNJ0ij' -secret = '1eGO4aeICAxPRXQzw2lQBc0QAkIKn6WiCV4cRLnUwnJulzixYFkoBeho5ZzsKTbn' +# key = 'QSZvYevTytwi8CJEkiUqqlZRQBOjIa23BoB8wFwTSY26GBAFkViTExex2mFNJ0ij' +# secret = '1eGO4aeICAxPRXQzw2lQBc0QAkIKn6WiCV4cRLnUwnJulzixYFkoBeho5ZzsKTbn' -client = UMFutures(key=key, secret=secret) -# print(client.exchange_info()) -# data = client.funding_rate('BTCUSD_PERP', limit=1) +# client = UMFutures(key=key, secret=secret) +# # print(client.exchange_info()) +# # data = client.funding_rate('BTCUSD_PERP', limit=1) -print(client.balance()) +# print(client.balance()) # fundingRate = float(data[0]['fundingRate']) * 100