support title with details, and only output records which volume ratio greater than huge volume mean value.

This commit is contained in:
blade 2025-08-14 20:08:48 +08:00
parent 38a4465e29
commit f929ff8a2f
4 changed files with 19 additions and 3 deletions

View File

@ -55,10 +55,13 @@ def create_metrics_report(
f"symbol: {symbol} {bar} window_size: {window_size} date_time: {date_time} 下跌,不发送相关数据"
)
return
volume_ratio = round(float(row["volume_ratio"]), 4)
change = "" if pct_chg > 0 else ""
brief = f"{symbol} {bar} 量率: {volume_ratio} {change}: {pct_chg}%"
if huge_volume == 1:
contents.append(f"## 交易巨量报告")
contents.append(f"## {brief} 交易巨量报告")
else:
contents.append(f"## 交易量报告")
contents.append(f"## {brief} 交易量报告")
if now_datetime_str is not None:
contents.append(f"## {symbol} {bar} 滑动窗口: {window_size} 最新数据时间: {now_datetime_str}")
else:
@ -72,7 +75,6 @@ def create_metrics_report(
volume = round(float(row["volume"]), 4)
volCcy = round(float(row["volCcy"]), 4)
volCCyQuote = round(float(row["volCCyQuote"]), 4)
volume_ratio = round(float(row["volume_ratio"]), 4)
spike_intensity = round(float(row["spike_intensity"]), 4)
close_80_high = int(row["close_80_high"])
close_20_low = int(row["close_20_low"])

View File

@ -66,6 +66,7 @@ class MarketMonitorMain:
symbol: str,
bar: str,
only_output_huge_volume: bool = False,
only_output_over_mean_volume: bool = False,
only_output_rise: bool = False,
):
"""
@ -135,6 +136,16 @@ class MarketMonitorMain:
if only_output_huge_volume:
if realtime_row["huge_volume"] == 1:
logging.info(f"监控到巨量: {symbol} {bar} 窗口大小: {self.window_size}")
if only_output_over_mean_volume:
# 获得huge_volume==1时的volume_ratio的均量
mean_huge_volume_ratio = real_time_data[real_time_data["huge_volume"] == 1]["volume_ratio"].mean()
if realtime_row["volume_ratio"] >= mean_huge_volume_ratio:
logging.info(f"监控到巨量且超过均量: {symbol} {bar} 窗口大小: {self.window_size}")
else:
logging.info(
f"监控到巨量但未超过均量: {symbol} {bar} 窗口大小: {self.window_size},退出本次监控"
)
return
else:
logging.info(
f"监控到非巨量: {symbol} {bar} 窗口大小: {self.window_size},退出本次监控"
@ -233,6 +244,7 @@ class MarketMonitorMain:
def batch_monitor_realtime_market(
self,
only_output_huge_volume: bool = True,
only_output_over_mean_volume: bool = True,
only_output_rise: bool = True,
):
for symbol in self.market_data_main.symbols:
@ -245,6 +257,7 @@ class MarketMonitorMain:
symbol,
bar,
only_output_huge_volume,
only_output_over_mean_volume,
only_output_rise,
)
except Exception as e:

View File

@ -11,6 +11,7 @@ def monitor_schedule():
while True: # 每分钟监控一次
market_monitor_main.batch_monitor_realtime_market(
only_output_huge_volume=True,
only_output_over_mean_volume=True,
only_output_rise=False,
)
logging.info("本次循环监控结束等待30秒")