This commit is contained in:
aazhou 2023-06-18 17:47:24 +08:00
parent bd38e34fd7
commit 8de86e4e55
4 changed files with 19 additions and 62 deletions

View File

@ -7,17 +7,16 @@ 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())
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()
start_time = datetime.now() - timedelta(minutes=settings.whaleAlert_minutes)
start_ts = int(start_time.timestamp())
url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={start_ts}&min_value={settings.whaleAlert_max_limit}'
headers = {'Accept': 'application/json'}
resp = requests.get(url, headers=headers).json()
print(resp)
if resp['result'] == "success":
cursor = resp['cursor']
@ -36,4 +35,5 @@ def strategy_run():
logging.error(traceback.format_exc())
tg.send_message(settings.chat_id, traceback.format_exc())
else:
print(resp['message'])
print(resp['message'])
tg.send_message(settings.chat_id, traceback.format_exc())

View File

@ -1,44 +0,0 @@
import talib
import numpy as np
import bn
import tg
import settings
# 获取K线价格数据
def get_prices(data):
# 提取最高价、最低价和收盘价
high_prices = [float(entry[2]) for entry in data]
low_prices = [float(entry[3]) for entry in data]
close_prices = [float(entry[4]) for entry in data]
return np.array(high_prices), np.array(low_prices), np.array(close_prices)
# 计算支撑位和压力位
def calculate_support_resistance(data):
# 获取价格数据
high_prices, low_prices, close_prices = get_prices(data)
# 计算平均真实范围ATR
atr = talib.ATR(high_prices, low_prices, close_prices, timeperiod=14)
# 计算支撑位和压力位
support = talib.SMA(close_prices - 1.618 * atr, timeperiod=20)
resistance = talib.SMA(close_prices + 1.618 * atr, timeperiod=20)
return support, resistance
def strategy_run(symbol, interval):
# 获取kline数据
data = bn.klines(symbol, interval)
support_levels, resistance_levels = calculate_support_resistance(data)
# 打印支撑位和压力位
print("支撑位:", support_levels)
print("压力位:", resistance_levels)
# if check_bullish_crossover(data):
# print('多头排列信号出现!')
# text = f'${symbol} - {interval}\r\n\r\n出现【多头排列】信号'
# tg.send_message(settings.chat_id, text)

View File

@ -1,9 +1,3 @@
import strategy.support_resistance as sr
import strategy.large_trans as lt
lt.strategy_run()
# sr.strategy_run('BTCUSDT', '1h')
lt.strategy_run()

View File

@ -32,4 +32,11 @@ import strategy.large_trans as lt
# mpf.plot(df, type='line')
lt.strategy_run()
# lt.strategy_run()
from datetime import datetime, timedelta
import time,settings
last_min = datetime.now() - timedelta(minutes=settings.whaleAlert_minutes)
print(last_min)
print(time.mktime(last_min.timetuple()))
print(last_min.timestamp())