From 721968b85d98e41ebbaead63670855a7bd951de3 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Thu, 6 Jun 2024 22:48:51 +0800 Subject: [PATCH] 1 --- main.py | 4 ++-- monitors/vegas.py | 5 +++-- test.py | 18 ++++-------------- utils.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 utils.py diff --git a/main.py b/main.py index ad51845..9c5b8e2 100644 --- a/main.py +++ b/main.py @@ -6,11 +6,11 @@ import monitors.large_transfer as lt # 监控 schedule.every(setting.whaleAlert_minutes).minutes.do(lt.run) + schedule.every().hour.at(":00").do(vegas.run, interval = '1h') +schedule.every().hour.at(":00").do(vegas.run, interval = '4h') print(f'Running... ChatID: {setting.chat_id}') while True: schedule.run_pending() time.sleep(1) - -# vegas.run('1h') \ No newline at end of file diff --git a/monitors/vegas.py b/monitors/vegas.py index e350580..54681f4 100644 --- a/monitors/vegas.py +++ b/monitors/vegas.py @@ -4,6 +4,7 @@ import numpy as np import pandas as pd import time,setting import telegram_sender +import utils api_key = "HCpeel8g6fsTK2630b7BvGBcS09Z3qfXkLVcAY2JkpaiMm1J6DWRvoQZBQlElDJg" @@ -91,14 +92,14 @@ def check_signal(symbol, interval,df): if latest['longResut']==True: direction = '多' - message = f"⭐️信号提醒⭐️\r\n\r\n品种: {symbol}\r\n周期: {interval}\r\n信号: {direction}\r\n当前价格:{latest['open']}\r\n\r\n{latest['timestamp']}" + message = f"⭐️信号提醒⭐️\r\n\r\n品种: {symbol}\r\n周期: {interval}\r\n信号: 【{direction}】\r\n当前价格:{latest['open']}\r\n\r\n{latest['timestamp']}" print(f"{symbol} - {interval} is checked!") if direction != "": telegram_sender.send_message(setting.chat_id, message) def run(interval): print('Vegas策略运行....') - symbols= get_symbols() + symbols = utils.get_top_binance_usdt_pairs(20) for s in symbols: df = get_dataFrame(s, interval) check_signal(s,interval, df) diff --git a/test.py b/test.py index 9cf1a88..fd56eac 100644 --- a/test.py +++ b/test.py @@ -1,17 +1,7 @@ - import requests +import utils +def main(): + print(utils.get_top_binance_usdt_pairs(30)) -# telegram bot key -telegram_bot_key='5863718864:AAFijN65_SbbGQ0WDBggzKJw2SIcZVTVrPw' - -#chatid -chat_id = "@cyber4trading" - -url = f'https://api.telegram.org/bot{telegram_bot_key}/sendMessage' -formData = { - "chat_id" : chat_id, - "text" : '12312' -} - -requests.post(url, data= formData) \ No newline at end of file +main() \ No newline at end of file diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..ff5c4ad --- /dev/null +++ b/utils.py @@ -0,0 +1,43 @@ +import requests + + +# 获取市值前10的币种 +def get_top_coins_by_market_cap(top): + + coingecko_url = "https://api.coingecko.com/api/v3/coins/markets" + params = { + 'vs_currency': 'usd', + 'order': 'market_cap_desc', + 'per_page': top, + 'page': 1 + } + response = requests.get(coingecko_url, params=params) + coins = response.json() + return coins + +# 获取Binance上的USDT交易对信息 +def get_binance_usdt_pairs(): + url = "https://api.binance.com/api/v3/exchangeInfo" + response = requests.get(url) + data = response.json() + + usdt_pairs = [symbol['symbol'] for symbol in data['symbols'] if (symbol['quoteAsset'] == 'USDT' and symbol['status'] == 'TRADING')] + return usdt_pairs + +def get_top_binance_usdt_pairs(top): + # 获取市值前10的币种 + top_coins = get_top_coins_by_market_cap(top) + + # 获取Binance上的USDT交易对 + usdt_pairs = get_binance_usdt_pairs() + + + # 筛选出前10币种中与USDT有交易对的币种 + top_pairs = [] + for coin in top_coins: + coin_symbol = coin['symbol'].upper() + pair = f"{coin_symbol}USDT" + if pair in usdt_pairs: + top_pairs.append(pair) + + return top_pairs \ No newline at end of file