This commit is contained in:
aaron 2024-06-07 22:34:41 +08:00
parent 7a544b3bed
commit 645318bfc6
6 changed files with 37 additions and 65 deletions

View File

@ -1,16 +1,13 @@
import requests
from binance.spot import Spot
import pandas as pd
from datetime import timezone, timedelta
api_key = "HCpeel8g6fsTK2630b7BvGBcS09Z3qfXkLVcAY2JkpaiMm1J6DWRvoQZBQlElDJg"
api_secret= "TySs6onlHOTrGzV8fMdDxLKTWWYnQ4rCHVAmjrcHby17acKflmo7xVTWVsbqtxe7"
client = Spot(api_key, api_secret)
# 获取市值前10的币种
# 获取市值前top的币种
def _get_top_coins_by_market_cap(top):
coingecko_url = "https://api.coingecko.com/api/v3/coins/markets"

View File

@ -1,12 +1,11 @@
import schedule
import setting
import time
import monitors.vegas as vegas
import monitors.large_transfer as lt
import telegram_sender,setting
# 监控大额转账
schedule.every(setting.whaleAlert_minutes).minutes.do(lt.run)
schedule.every(1).minutes.do(lt.run)
schedule.every().hour.at(":00").do(vegas.run_crypto, interval = '1h')
@ -14,7 +13,9 @@ 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')
print(f'Running... V1.2')
version = 'V1.1'
print(f'Running... {version}')
telegram_sender.send_message(setting.chat_id, f'☕️ Strategy is updated Version: {version}')
while True:
schedule.run_pending()
time.sleep(1)

View File

@ -1,50 +1,33 @@
import requests
import setting
from datetime import datetime, timedelta
import time
import telegram_sender
import traceback
import logging
import json
# 你的Whale Alert API密钥
api_key = 'gPkElMPR8Hpe5LxjKisR4YSFzxRxMLj6'
base_url = 'https://api.whale-alert.io/v1/transactions'
def get_large_transactions(min_value=50000000):
params = {
'api_key': api_key,
'min_value': min_value
}
response = requests.get(base_url, params=params)
return response.json()
def run():
try:
start_time = datetime.now() - timedelta(minutes=setting.whaleAlert_minutes)
start_ts = int(start_time.timestamp())
url = f'https://api.whale-alert.io/v1/transactions?api_key={setting.whaleAlert_apikey}&start={start_ts}&min_value={setting.whaleAlert_max_limit}'
headers = {'Accept': 'application/json'}
transactions = get_large_transactions()
if transactions and 'transactions' in transactions:
for ts in transactions['transactions']:
if ts['to']['owner_type'] == 'exchange':
amount = int(ts['amount'])
amount_usd = int(ts['amount_usd'])
resp = requests.get(url, headers=headers).text
# 判断是否为JSON格式
if json.dumps(resp) == False:
print(resp)
return
amount_format = f'{int(amount_usd):,d}'
amount_usd_format = f'{int(amount_usd):,d}'
data = json.loads(resp)
content = f"🚨大额链上交易提醒🚨\r\n\r\n{amount_format} #{ts['symbol']} (价值: {amount_usd_format} USD) 从 {ts['from']['owner']} 转入 {ts['to']['owner']}"
print(data)
if data['result'] == "success":
if 'transactions' in data:
data = data['transactions']
for ts in data:
if ts['to']['owner_type'] == 'exchange':
amount = int(ts['amount'])
amount_usd = int(ts['amount_usd'])
amount_format = f'{int(amount_usd):,d}'
amount_usd_format = f'{int(amount_usd):,d}'
content = f"🚨大额转入提醒🚨\r\n\r\n {amount_format} #{ts['symbol']} ({amount_usd_format} USD) 从 {ts['from']['owner']} 转入 #{ts['to']['owner']}"
print(content)
telegram_sender.send_message(setting.chat_id, content)
else:
print(data)
telegram_sender.send_message(setting.chat_id, data['message'])
except:
logging.error(traceback.format_exc())
print(content)
telegram_sender.send_message(setting.chat_id, content)

View File

@ -67,7 +67,7 @@ def stratergy_run(symbol, interval,df):
def run_crypto(interval):
print('Vegas策略运行....')
print('Vegas策略运行.')
# symbols = crypto.get_top_binance_usdt_pairs(10)
symbols = ['BTCUSDT',"ETHUSDT",'LTCUSDT','DOGEUSDT','FTMUSDT','FILUSDT','OPUSDT','SOLUSDT','BNBUSDT','BCHUSDT','ETCUSDT','ARUSDT']

View File

@ -5,17 +5,3 @@ telegram_bot_key='5863718864:AAFijN65_SbbGQ0WDBggzKJw2SIcZVTVrPw'
#
chat_id = os.getenv("TQ_CHAT_ID", "@cyber4trading")
#oklink
oklink_host = 'https://www.oklink.com'
oklink_apikey='ca822b3f-2e1e-479c-8649-c1f9b62a740d'
oklink_api_headers = {
'Ok-Access-Key' : oklink_apikey
}
#whaleAlert
whaleAlert_minutes=1
whaleAlert_apikey='gPkElMPR8Hpe5LxjKisR4YSFzxRxMLj6'
whaleAlert_max_limit = os.getenv('TQ_WHALEALERT_MAX_USD_AMOUNT',5000 * 10000)

View File

@ -4,5 +4,10 @@ import monitors
import monitors.vegas
from datasource import crypto
from monitors import large_transfer
print(crypto.get_klines('BTCUSDT', '1h'))
# large_transfer.run()
print(crypto.get_top_binance_usdt_pairs(20))