This commit is contained in:
aazhou 2023-06-17 11:55:43 +08:00
parent aa675c084f
commit bd38e34fd7
3 changed files with 30 additions and 22 deletions

13
main.py
View File

@ -6,12 +6,11 @@ import strategy.crossover as crossover
import strategy.large_trans as lt
# 获取交易所交易对
symbols = bn.symbols()
# symbols = bn.symbols()
for s in symbols:
# for s in symbols:
# 5m
schedule.every(settings.whaleAlert_minutes).minutes.do(lt.strategy_run)
# schedule.every(settings.whaleAlert_minutes).minutes.do(lt.strategy_run)
# 5m
@ -26,7 +25,11 @@ for s in symbols:
# 4h
# schedule.every(4).hours.do(crossover.strategy_run, symbol=s, interval='4h')
print(f'监控开始... ChatID: {settings.chat_id}')
# 监控
schedule.every(settings.whaleAlert_minutes).minutes.do(lt.strategy_run)
print(f'Running... ChatID: {settings.chat_id}')
while True:
schedule.run_pending()
time.sleep(1)

View File

@ -16,6 +16,6 @@ oklink_api_headers = {
#whaleAlert
whaleAlert_minutes=2
whaleAlert_minutes=1
whaleAlert_apikey='gPkElMPR8Hpe5LxjKisR4YSFzxRxMLj6'
whaleAlert_max_limit = os.getenv('TQ_WHALEALERT_MAX_USD_AMOUNT',1000 * 10000)

View File

@ -7,28 +7,33 @@ import tg
import traceback
import logging
cursor = '0-0-0'
def strategy_run():
# 获取上一分钟的timestamp
last_min = datetime.now() - timedelta(minutes=settings.whaleAlert_minutes)
ts = time.mktime(last_min.timetuple())
url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={int(ts)}'
global cursor
cursor_query = f"&cursor={cursor}" if cursor != '0-0-0' else ""
url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={int(ts)}&min_value={settings.whaleAlert_max_limit}' + cursor_query
print(f'Request url: {url}')
resp = requests.get(url).json()
print(resp)
try:
if 'transactions' in resp:
data = resp['transactions']
if resp['result'] == "success":
cursor = resp['cursor']
try:
if 'transactions' in resp:
data = resp['transactions']
for ts in data:
usd = int(ts['amount_usd'])
if ts['to']['owner_type'] == 'exchange' 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']}"
for ts in data:
if ts['to']['owner_type'] == 'exchange':
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)
except Exception as e:
logging.error(traceback.format_exc())
tg.send_message(settings.chat_id, traceback.format_exc())
print(content)
tg.send_message(settings.chat_id, content)
except Exception as e:
logging.error(traceback.format_exc())
tg.send_message(settings.chat_id, traceback.format_exc())
else:
print(resp['message'])