diff --git a/__pycache__/bn.cpython-310.pyc b/__pycache__/bn.cpython-310.pyc deleted file mode 100644 index a8f9be4..0000000 Binary files a/__pycache__/bn.cpython-310.pyc and /dev/null differ diff --git a/__pycache__/crossover.cpython-310.pyc b/__pycache__/crossover.cpython-310.pyc deleted file mode 100644 index a607b7e..0000000 Binary files a/__pycache__/crossover.cpython-310.pyc and /dev/null differ diff --git a/bn.py b/bn.py index a001ea2..8a93e6b 100644 --- a/bn.py +++ b/bn.py @@ -4,8 +4,10 @@ client = Spot() # Get klines -def klines(symbol, interval, limit=300): - return client.klines(symbol,interval,limit=limit) +def klines(symbol, interval): + lines = client.klines(symbol,interval) + print(len(lines)) + return lines # Get Symbols def symbols(): @@ -16,4 +18,4 @@ def symbols(): if s['symbol'].endswith('USDT'): symbols.append(s['symbol']) - return symbols + return symbols \ No newline at end of file diff --git a/main.py b/main.py index 4a37515..b78164c 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ import schedule import bn import time -import crossover +import strategy.crossover as crossover # 获取交易所交易对 symbols = bn.symbols() diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..8a21c86 --- /dev/null +++ b/settings.py @@ -0,0 +1,6 @@ + +# telegram bot key +telegram_bot_key='5863718864:AAFijN65_SbbGQ0WDBggzKJw2SIcZVTVrPw' + +# +chat_id = "@dragon_invest" \ No newline at end of file diff --git a/crossover.py b/strategy/crossover.py similarity index 81% rename from crossover.py rename to strategy/crossover.py index 986b030..2423447 100644 --- a/crossover.py +++ b/strategy/crossover.py @@ -1,6 +1,8 @@ import talib import numpy as np import bn +import tg +import settings # 检查是否出现多头排列信号 def check_bullish_crossover(data): @@ -40,9 +42,16 @@ def check_bearish_crossover(data): def strategy_run(symbol, interval): # 获取kline数据 data = bn.klines(symbol, interval) + print(f'获取Kline数据: [{symbol}] - [{interval}]') if check_bullish_crossover(data): print('多头排列信号出现!') + text = f'${symbol} - {interval}\r\n\r\n出现【多头排列】信号' + tg.send_message(settings.chat_id, text) + + if check_bearish_crossover(data): print("空头排列信号出现!") + text = f'${symbol} - {interval}\r\n\r\n出现【空头排列】信号' + tg.send_message(settings.chat_id, text) \ No newline at end of file diff --git a/tg.py b/tg.py new file mode 100644 index 0000000..927c6cd --- /dev/null +++ b/tg.py @@ -0,0 +1,11 @@ +import requests +import settings + +# 发送消息 +def send_message(chat_id, text): + url = f'https://api.telegram.org/bot{settings.telegram_bot_key}/sendMessage' + formData = { + "chat_id" : chat_id, + "text" : text + } + requests.post(url, data= formData) \ No newline at end of file