This commit is contained in:
aazhou 2023-06-07 14:38:35 +08:00
parent 41cb601203
commit c68ee8bac2
7 changed files with 32 additions and 4 deletions

Binary file not shown.

8
bn.py
View File

@ -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

View File

@ -1,7 +1,7 @@
import schedule
import bn
import time
import crossover
import strategy.crossover as crossover
# 获取交易所交易对
symbols = bn.symbols()

6
settings.py Normal file
View File

@ -0,0 +1,6 @@
# telegram bot key
telegram_bot_key='5863718864:AAFijN65_SbbGQ0WDBggzKJw2SIcZVTVrPw'
#
chat_id = "@dragon_invest"

View File

@ -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)

11
tg.py Normal file
View File

@ -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)