support output last huge volume record
This commit is contained in:
parent
6f72a18663
commit
5969f427a5
|
|
@ -76,6 +76,7 @@ WINDOW_SIZE = {"window_sizes":[50, 80, 100, 120]}
|
|||
BAR_THRESHOLD = {
|
||||
"5m": 1000 * 60 * 5,
|
||||
"15m": 1000 * 60 * 15,
|
||||
"30m": 1000 * 60 * 30,
|
||||
"1H": 1000 * 60 * 60,
|
||||
"4H": 1000 * 60 * 60 * 4,
|
||||
"1D": 1000 * 60 * 60 * 24
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,6 +1,7 @@
|
|||
import pandas as pd
|
||||
import numpy as np
|
||||
from metrics_config import METRICS_CONFIG
|
||||
from config import BAR_THRESHOLD
|
||||
from time import time
|
||||
|
||||
import logging
|
||||
|
|
@ -12,6 +13,7 @@ def create_metrics_report(
|
|||
row: pd.Series,
|
||||
next_bar_row: pd.Series,
|
||||
btc_bar_row: pd.Series,
|
||||
all_data: pd.DataFrame,
|
||||
only_output_huge_volume: bool = False,
|
||||
only_output_rise: bool = False,
|
||||
now_datetime_str: str = None,
|
||||
|
|
@ -64,7 +66,7 @@ def create_metrics_report(
|
|||
k_shape = str(row["k_shape"])
|
||||
contents.append(f"### 价格信息")
|
||||
contents.append(f"当前价格: {close}, 开盘价: {open}, 最高价: {high}, 最低价: {low}")
|
||||
contents.append(f"涨跌幅: {pct_chg}")
|
||||
contents.append(f"涨跌幅: {pct_chg}%")
|
||||
contents.append(f"当前K线形态: {k_shape}")
|
||||
|
||||
volume = round(float(row["volume"]), 4)
|
||||
|
|
@ -95,6 +97,10 @@ def create_metrics_report(
|
|||
elif close_10_low:
|
||||
contents.append(f"当前价格处于滑动窗口期10%分位数低点")
|
||||
|
||||
timestamp = int(row["timestamp"])
|
||||
last_huge_volume_info = get_last_huge_volume_record(all_data, bar, timestamp)
|
||||
contents.extend(last_huge_volume_info)
|
||||
|
||||
long_short_info = {"多": [], "空": []}
|
||||
ma_long_short = str(row["ma_long_short"])
|
||||
ma_long_short_value = METRICS_CONFIG.get("ma_long_short", {}).get(ma_long_short, 1)
|
||||
|
|
@ -300,6 +306,57 @@ def create_metrics_report(
|
|||
return mark_down_text
|
||||
|
||||
|
||||
def get_last_huge_volume_record(all_data: pd.DataFrame, bar: str, timestamp: int):
|
||||
"""
|
||||
1. 获取最近一次巨量记录
|
||||
a. 获取最近一次巨量记录的日期时间
|
||||
b. 获取最近一次巨量记录的日期时间距今多少个K线
|
||||
c. 获取最近一次巨量记录的涨跌幅
|
||||
d. 获取最近一次巨量记录的成交量比率
|
||||
2. 获得最近十个周期内,出现巨量的次数
|
||||
"""
|
||||
last_record_title = f"#### 最近一次{bar}周期巨量记录信息"
|
||||
results = []
|
||||
results.append(last_record_title)
|
||||
try:
|
||||
# 根据timestamp降序排序
|
||||
all_data = all_data.sort_values(by="timestamp", ascending=False)
|
||||
# 获取timestamp小于等于timestamp的行
|
||||
earlier_huge_volume_data = all_data[(all_data["timestamp"] < timestamp) & (all_data["huge_volume"] == 1)]
|
||||
|
||||
if earlier_huge_volume_data.empty:
|
||||
results.append(f"窗口周期内无其他巨量记录,当前为首次出现巨量")
|
||||
return results
|
||||
else:
|
||||
#a. 获取最近一次巨量记录的日期时间
|
||||
#b. 获取最近一次巨量记录的日期时间距今多少个K线
|
||||
#c. 获取最近一次巨量记录的涨跌幅
|
||||
#d. 获取最近一次巨量记录的成交量比率
|
||||
last_record = earlier_huge_volume_data.iloc[0]
|
||||
last_record_date_time = last_record["date_time"]
|
||||
last_record_timestamp = last_record["timestamp"]
|
||||
last_record_pct_chg = float(round(last_record["pct_chg"], 4))
|
||||
last_record_volume_ratio = float(round(last_record["volume_ratio"], 4))
|
||||
|
||||
bar_threshold = BAR_THRESHOLD.get(bar, 1000 * 60 * 60 * 24)
|
||||
period_diff = int((timestamp - last_record_timestamp) / bar_threshold)
|
||||
last_record_text = f"日期时间: {last_record_date_time}"
|
||||
last_record_text += f",距今{period_diff}个K线"
|
||||
last_record_text += f",涨跌幅: {last_record_pct_chg}%"
|
||||
last_record_text += f",成交量比率: {last_record_volume_ratio}"
|
||||
results.append(last_record_text)
|
||||
# 2. 获得最近十个周期内,出现巨量的次数
|
||||
# 从第2行开始取,取10行
|
||||
ten_period_data = all_data.iloc[1:11]
|
||||
huge_volume_in_ten_period_count= int(ten_period_data["huge_volume"].sum())
|
||||
results.append(f"最近十个周期内,出现巨量的次数: {huge_volume_in_ten_period_count}")
|
||||
return results
|
||||
except Exception as e:
|
||||
logging.error(f"获取最近一次巨量记录信息失败: {e}")
|
||||
results.append(f"获取最近一次巨量记录信息失败: {e}")
|
||||
return results
|
||||
|
||||
|
||||
def get_long_short_over_buy_sell(
|
||||
row: pd.Series,
|
||||
now_datetime_str: str = None,
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ class MarketMonitorMain:
|
|||
realtime_row,
|
||||
next_bar_row,
|
||||
btc_bar_row,
|
||||
real_time_data,
|
||||
only_output_huge_volume,
|
||||
only_output_rise,
|
||||
now_datetime_str,
|
||||
|
|
@ -258,6 +259,6 @@ if __name__ == "__main__":
|
|||
market_monitor_main.monitor_realtime_market(
|
||||
symbol="PUMP-USDT",
|
||||
bar="15m",
|
||||
only_output_huge_volume=True,
|
||||
only_output_rise=True,
|
||||
only_output_huge_volume=False,
|
||||
only_output_rise=False,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue