diff --git a/strategy/large_trans.py b/strategy/large_trans.py index e4e7e3b..31f46fd 100644 --- a/strategy/large_trans.py +++ b/strategy/large_trans.py @@ -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']) \ No newline at end of file + print(resp['message']) + tg.send_message(settings.chat_id, traceback.format_exc()) \ No newline at end of file diff --git a/strategy/support_resistance.py b/strategy/support_resistance.py deleted file mode 100644 index d1a5d27..0000000 --- a/strategy/support_resistance.py +++ /dev/null @@ -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) diff --git a/strategy_test.py b/strategy_test.py index e5f2798..8b8d2b8 100644 --- a/strategy_test.py +++ b/strategy_test.py @@ -1,9 +1,3 @@ -import strategy.support_resistance as sr import strategy.large_trans as lt - - -lt.strategy_run() - - -# sr.strategy_run('BTCUSDT', '1h') \ No newline at end of file +lt.strategy_run() \ No newline at end of file diff --git a/test.py b/test.py index 3208190..f83e3a2 100644 --- a/test.py +++ b/test.py @@ -32,4 +32,11 @@ import strategy.large_trans as lt # mpf.plot(df, type='line') -lt.strategy_run() \ No newline at end of file +# 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()) \ No newline at end of file