add large_trans.
This commit is contained in:
parent
133c7b3bbb
commit
f468dcbd5e
11
main.py
11
main.py
@ -3,23 +3,28 @@ import bn
|
|||||||
import settings
|
import settings
|
||||||
import time
|
import time
|
||||||
import strategy.crossover as crossover
|
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:
|
||||||
|
# 1m
|
||||||
|
schedule.every(1).minutes.do(lt.strategy_run)
|
||||||
|
|
||||||
|
|
||||||
# 5m
|
# 5m
|
||||||
# schedule.every(5).minutes.do(crossover.strategy_run, symbol=s, interval='5m')
|
# schedule.every(5).minutes.do(crossover.strategy_run, symbol=s, interval='5m')
|
||||||
|
|
||||||
# 30m
|
# 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
|
# 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
|
# 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}')
|
print(f'监控开始... ChatID: {settings.chat_id}')
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
13
settings.py
13
settings.py
@ -5,3 +5,16 @@ 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 pandas as pd
|
||||||
import mplfinance as mpf
|
import mplfinance as mpf
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
import strategy.large_trans as lt
|
||||||
|
|
||||||
def binanceDataFrame(klines):
|
# def binanceDataFrame(klines):
|
||||||
df = pd.DataFrame(klines.reshape(-1,12),dtype=float, columns = ('Open Time',
|
# df = pd.DataFrame(klines.reshape(-1,12),dtype=float, columns = ('Open Time',
|
||||||
'Open',
|
# 'Open',
|
||||||
'High',
|
# 'High',
|
||||||
'Low',
|
# 'Low',
|
||||||
'Close',
|
# 'Close',
|
||||||
'Volume',
|
# 'Volume',
|
||||||
'Close time',
|
# 'Close time',
|
||||||
'Quote asset volume',
|
# 'Quote asset volume',
|
||||||
'Number of trades',
|
# 'Number of trades',
|
||||||
'Taker buy base asset volume',
|
# 'Taker buy base asset volume',
|
||||||
'Taker buy quote asset volume',
|
# 'Taker buy quote asset volume',
|
||||||
'Ignore'))
|
# '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 = 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.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]
|
# df.index = [dt.datetime.fromtimestamp(x/1000.0) for x in df.ctime]
|
||||||
mpf.plot(df, type='line')
|
# mpf.plot(df, type='line')
|
||||||
|
|
||||||
|
|
||||||
|
lt.strategy_run()
|
||||||
Loading…
Reference in New Issue
Block a user