fix bug.
This commit is contained in:
parent
aa675c084f
commit
bd38e34fd7
13
main.py
13
main.py
@ -6,12 +6,11 @@ import strategy.crossover as crossover
|
|||||||
import strategy.large_trans as lt
|
import strategy.large_trans as lt
|
||||||
|
|
||||||
# 获取交易所交易对
|
# 获取交易所交易对
|
||||||
symbols = bn.symbols()
|
# symbols = bn.symbols()
|
||||||
|
|
||||||
|
# for s in symbols:
|
||||||
for s in symbols:
|
|
||||||
# 5m
|
# 5m
|
||||||
schedule.every(settings.whaleAlert_minutes).minutes.do(lt.strategy_run)
|
# schedule.every(settings.whaleAlert_minutes).minutes.do(lt.strategy_run)
|
||||||
|
|
||||||
|
|
||||||
# 5m
|
# 5m
|
||||||
@ -26,7 +25,11 @@ for s in symbols:
|
|||||||
# 4h
|
# 4h
|
||||||
# schedule.every(4).hours.do(crossover.strategy_run, symbol=s, interval='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:
|
while True:
|
||||||
schedule.run_pending()
|
schedule.run_pending()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -16,6 +16,6 @@ oklink_api_headers = {
|
|||||||
|
|
||||||
|
|
||||||
#whaleAlert
|
#whaleAlert
|
||||||
whaleAlert_minutes=2
|
whaleAlert_minutes=1
|
||||||
whaleAlert_apikey='gPkElMPR8Hpe5LxjKisR4YSFzxRxMLj6'
|
whaleAlert_apikey='gPkElMPR8Hpe5LxjKisR4YSFzxRxMLj6'
|
||||||
whaleAlert_max_limit = os.getenv('TQ_WHALEALERT_MAX_USD_AMOUNT',1000 * 10000)
|
whaleAlert_max_limit = os.getenv('TQ_WHALEALERT_MAX_USD_AMOUNT',1000 * 10000)
|
||||||
@ -7,28 +7,33 @@ import tg
|
|||||||
import traceback
|
import traceback
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
cursor = '0-0-0'
|
||||||
|
|
||||||
def strategy_run():
|
def strategy_run():
|
||||||
# 获取上一分钟的timestamp
|
# 获取上一分钟的timestamp
|
||||||
last_min = datetime.now() - timedelta(minutes=settings.whaleAlert_minutes)
|
last_min = datetime.now() - timedelta(minutes=settings.whaleAlert_minutes)
|
||||||
ts = time.mktime(last_min.timetuple())
|
ts = time.mktime(last_min.timetuple())
|
||||||
|
global cursor
|
||||||
url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={int(ts)}'
|
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()
|
resp = requests.get(url).json()
|
||||||
print(resp)
|
print(resp)
|
||||||
try:
|
if resp['result'] == "success":
|
||||||
if 'transactions' in resp:
|
cursor = resp['cursor']
|
||||||
data = resp['transactions']
|
try:
|
||||||
|
if 'transactions' in resp:
|
||||||
|
data = resp['transactions']
|
||||||
|
|
||||||
for ts in data:
|
for ts in data:
|
||||||
usd = int(ts['amount_usd'])
|
if ts['to']['owner_type'] == 'exchange':
|
||||||
if ts['to']['owner_type'] == 'exchange' and usd > settings.whaleAlert_max_limit:
|
from_text = 'unknown wallet'
|
||||||
from_text = 'unknown wallet'
|
content = f"🚨 {ts['amount']} #{ts['symbol']} ({ts['amount_usd']} USD) 从 {from_text} 转入 #{ts['to']['owner']}"
|
||||||
content = f"🚨 {ts['amount']} #{ts['symbol']} ({ts['amount_usd']} USD) 从 {from_text} 转入 #{ts['to']['owner']}"
|
|
||||||
|
|
||||||
print(content)
|
print(content)
|
||||||
tg.send_message(settings.chat_id, content)
|
tg.send_message(settings.chat_id, content)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(traceback.format_exc())
|
logging.error(traceback.format_exc())
|
||||||
tg.send_message(settings.chat_id, traceback.format_exc())
|
tg.send_message(settings.chat_id, traceback.format_exc())
|
||||||
|
else:
|
||||||
|
print(resp['message'])
|
||||||
Loading…
Reference in New Issue
Block a user