38 lines
912 B
Python
38 lines
912 B
Python
import talib
|
|
import numpy as np
|
|
import bn
|
|
import tg
|
|
import datetime
|
|
import setting
|
|
import db
|
|
|
|
def check_volume_growing(data):
|
|
# 提取收盘价
|
|
close_prices = np.array([float(entry[4]) for entry in data])
|
|
|
|
# 提取交易量
|
|
volumes = np.array([float(entry[5]) for entry in data])
|
|
|
|
# 计算量能指标
|
|
obv = talib.OBV(close_prices, volumes)
|
|
|
|
return obv[-1] > obv[-2]
|
|
|
|
|
|
def run(symbol, interval):
|
|
# 获取kline数据
|
|
data = bn.klines(symbol, interval)
|
|
|
|
is_growing= check_volume_growing(data)
|
|
|
|
if is_growing:
|
|
text = f'📶信号预警📶\r\n\r\n品种:【{symbol}】\r\n周期:{interval}\r\n信号名称:量能监控\r\n信号:量能上升\r\n\r\n{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}'
|
|
print(text)
|
|
tg.send_message(setting.chat_id, text)
|
|
else:
|
|
print(f'{symbol} - {interval} 量能上升: {is_growing}')
|
|
|
|
|
|
|
|
|