diff --git a/main.py b/main.py index d264724..43ab79b 100644 --- a/main.py +++ b/main.py @@ -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) \ No newline at end of file diff --git a/settings.py b/settings.py index cefcd7e..a2e3d49 100644 --- a/settings.py +++ b/settings.py @@ -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) \ No newline at end of file diff --git a/strategy/large_trans.py b/strategy/large_trans.py index bcd2e49..e4e7e3b 100644 --- a/strategy/large_trans.py +++ b/strategy/large_trans.py @@ -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()) \ No newline at end of file + 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']) \ No newline at end of file