trading-quant/strategy/large_trans.py
2023-06-16 23:01:03 +08:00

26 lines
875 B
Python

import requests
import settings
from datetime import datetime, timedelta
import time
import tg
def strategy_run():
# 获取上一分钟的timestamp
last_min = datetime.now() - timedelta(minutes=1)
ts = time.mktime(last_min.timetuple())
url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={int(ts)}'
resp = requests.get(url).json()
data = resp['transactions']
for ts in data:
usd = int(ts['amount_usd'])
if ts['to']['owner_type'] == 'exchange' and ts['from']['owner_type'] == 'unknown' and usd > settings.whaleAlert_max_limit:
from_text = 'unknown wallet'
content = f"🚨 {ts['amount']} #{ts['symbol']} ({ts['amount_usd']} USD) 从 {from_text} 转入 #{ts['to']['owner']}"
print(content)
tg.send_message(settings.chat_id, content)