add large_trans.
This commit is contained in:
parent
133c7b3bbb
commit
cb4ac50cbb
11
main.py
11
main.py
@ -3,23 +3,28 @@ import bn
|
||||
import settings
|
||||
import time
|
||||
import strategy.crossover as crossover
|
||||
import strategy.large_trans as lt
|
||||
|
||||
# 获取交易所交易对
|
||||
symbols = bn.symbols()
|
||||
|
||||
|
||||
for s in symbols:
|
||||
# 1m
|
||||
schedule.every(1).minutes.do(lt.strategy_run)
|
||||
|
||||
|
||||
# 5m
|
||||
# schedule.every(5).minutes.do(crossover.strategy_run, symbol=s, interval='5m')
|
||||
|
||||
# 30m
|
||||
schedule.every(30).minutes.do(crossover.strategy_run, symbol=s, interval='30m')
|
||||
# schedule.every(30).minutes.do(crossover.strategy_run, symbol=s, interval='30m')
|
||||
|
||||
# 1h
|
||||
schedule.every(1).hours.do(crossover.strategy_run, symbol=s, interval='1h')
|
||||
# schedule.every(1).hours.do(crossover.strategy_run, symbol=s, interval='1h')
|
||||
|
||||
# 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}')
|
||||
while True:
|
||||
|
||||
15
settings.py
15
settings.py
@ -4,4 +4,17 @@ import os
|
||||
telegram_bot_key='5863718864:AAFijN65_SbbGQ0WDBggzKJw2SIcZVTVrPw'
|
||||
|
||||
#
|
||||
chat_id = os.getenv("TQ_CHAT_ID", "@cyber4trading")
|
||||
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_apikey='gPkElMPR8Hpe5LxjKisR4YSFzxRxMLj6'
|
||||
whaleAlert_max_limit = os.getenv('TQ_WHALEALERT_MAX_USD_AMOUNT',2000 * 20000)
|
||||
26
strategy/large_trans.py
Normal file
26
strategy/large_trans.py
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
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)
|
||||
44
test.py
44
test.py
@ -2,30 +2,34 @@ import bn
|
||||
import pandas as pd
|
||||
import mplfinance as mpf
|
||||
import datetime as dt
|
||||
import strategy.large_trans as lt
|
||||
|
||||
def binanceDataFrame(klines):
|
||||
df = pd.DataFrame(klines.reshape(-1,12),dtype=float, columns = ('Open Time',
|
||||
'Open',
|
||||
'High',
|
||||
'Low',
|
||||
'Close',
|
||||
'Volume',
|
||||
'Close time',
|
||||
'Quote asset volume',
|
||||
'Number of trades',
|
||||
'Taker buy base asset volume',
|
||||
'Taker buy quote asset volume',
|
||||
'Ignore'))
|
||||
# def binanceDataFrame(klines):
|
||||
# df = pd.DataFrame(klines.reshape(-1,12),dtype=float, columns = ('Open Time',
|
||||
# 'Open',
|
||||
# 'High',
|
||||
# 'Low',
|
||||
# 'Close',
|
||||
# 'Volume',
|
||||
# 'Close time',
|
||||
# 'Quote asset volume',
|
||||
# 'Number of trades',
|
||||
# 'Taker buy base asset volume',
|
||||
# 'Taker buy quote asset volume',
|
||||
# 'Ignore'))
|
||||
|
||||
df['Open Time'] = pd.to_datetime(df['Open Time'], unit='ms')
|
||||
# df['Open Time'] = pd.to_datetime(df['Open Time'], unit='ms')
|
||||
|
||||
|
||||
return df
|
||||
# return df
|
||||
|
||||
|
||||
klines = bn.klines('BTCUSDT', '1h')
|
||||
# klines = bn.klines('BTCUSDT', '1h')
|
||||
|
||||
df = pd.DataFrame(klines,dtype=float)
|
||||
df.columns = ['Open time', 'Open', 'High', 'Low', 'Close', 'Volume', 'ctime', 'Quote asset volume', 'Number of trades', 'Taker buy base asset volume', 'Taker buy quote asset volume', 'Can be ignored']
|
||||
df.index = [dt.datetime.fromtimestamp(x/1000.0) for x in df.ctime]
|
||||
mpf.plot(df, type='line')
|
||||
# df = pd.DataFrame(klines,dtype=float)
|
||||
# df.columns = ['Open time', 'Open', 'High', 'Low', 'Close', 'Volume', 'ctime', 'Quote asset volume', 'Number of trades', 'Taker buy base asset volume', 'Taker buy quote asset volume', 'Can be ignored']
|
||||
# df.index = [dt.datetime.fromtimestamp(x/1000.0) for x in df.ctime]
|
||||
# mpf.plot(df, type='line')
|
||||
|
||||
|
||||
lt.strategy_run()
|
||||
Loading…
Reference in New Issue
Block a user