fix some issue
This commit is contained in:
parent
89d06d9fbd
commit
e0bf2bbbfb
|
|
@ -4,3 +4,4 @@
|
|||
core/db/__pycache__/db_market_data.cpython-312.pyc
|
||||
core/biz/__pycache__/metrics_calculation.cpython-312.pyc
|
||||
core/biz/__pycache__/market_data_monitor.cpython-312.pyc
|
||||
core/db/__pycache__/db_market_data.cpython-312.pyc
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ class MetricsCalculation:
|
|||
KDJ_K < 30, KDJ_D < 30, KDJ_J < 20: 超卖
|
||||
否则为"徘徊"
|
||||
"""
|
||||
logging.info("设置KDJ形态")
|
||||
# 初始化kdj_pattern列
|
||||
df["kdj_pattern"] = "徘徊"
|
||||
|
||||
|
|
@ -150,6 +151,7 @@ class MetricsCalculation:
|
|||
|
||||
使用20个周期的滚动窗口计算相对统计特征,避免绝对阈值过于严格的问题
|
||||
"""
|
||||
logging.info("设置均线多空和发散")
|
||||
data["ma_long_short"] = "震荡"
|
||||
data["ma_divergence"] = "未知"
|
||||
|
||||
|
|
@ -464,6 +466,7 @@ class MetricsCalculation:
|
|||
超卖:价格接近下轨,且KDJ超卖
|
||||
震荡:其他情况
|
||||
"""
|
||||
logging.info("设置BOLL形态")
|
||||
# 初始化boll_pattern列
|
||||
df["boll_pattern"] = "震荡"
|
||||
|
||||
|
|
@ -539,6 +542,7 @@ class MetricsCalculation:
|
|||
- 长:K线实体或影线较长
|
||||
- 超长:K线实体和影线都很长
|
||||
"""
|
||||
logging.info("设置K线长度")
|
||||
# 检查必要的列是否存在
|
||||
required_columns = ["close", "open", "high", "low"]
|
||||
missing_columns = [col for col in required_columns if col not in df.columns]
|
||||
|
|
@ -645,6 +649,7 @@ class MetricsCalculation:
|
|||
- 超大实体:实体占比70%-90%
|
||||
- 光头光脚:实体占比>90%(非一字情况)
|
||||
"""
|
||||
logging.info("设置K线形状")
|
||||
# 检查必要的列是否存在
|
||||
required_columns = ["close", "open", "high", "low"]
|
||||
missing_columns = [col for col in required_columns if col not in df.columns]
|
||||
|
|
@ -840,6 +845,8 @@ class MetricsCalculation:
|
|||
"avg_price_range",
|
||||
"std_price_range",
|
||||
"price_range_zscore",
|
||||
"price_range_ratio_p75",
|
||||
"price_range_zscore_p75",
|
||||
]
|
||||
df.drop(columns=temp_columns, inplace=True)
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -478,7 +478,7 @@ class DBMarketData:
|
|||
:param start: 开始时间
|
||||
:param end: 结束时间
|
||||
"""
|
||||
if start is None or end is None:
|
||||
if start is None and end is None:
|
||||
sql = """
|
||||
SELECT * FROM crypto_market_data
|
||||
WHERE symbol = :symbol AND bar = :bar
|
||||
|
|
|
|||
|
|
@ -88,20 +88,21 @@ class MarketDataMain:
|
|||
logging.error(f"开始时间格式错误: {start}")
|
||||
return None
|
||||
|
||||
# 如果bar为5m, 15m:
|
||||
# 如果bar为5m, 15m, 30m:
|
||||
# end_time_ts与start_time_ts相差超过1天,则按照1天为单位
|
||||
# 如果bar为1H, 4H,
|
||||
# end_time_ts与start_time_ts相差超过5天,则按照5天为单位
|
||||
# 如果bar为1D, 则end_time_ts与start_time_ts相差超过10天,则按照10天为单位
|
||||
# 获取数据,直到end_time_ts
|
||||
threshold = None
|
||||
if bar in ["5m", "15m"]:
|
||||
if bar in ["5m", "15m", "30m"]:
|
||||
threshold = 86400000
|
||||
elif bar in ["1H", "4H"]:
|
||||
threshold = 432000000
|
||||
elif bar == "1D":
|
||||
threshold = 864000000
|
||||
|
||||
get_data = False
|
||||
min_start_time_ts = start_time_ts
|
||||
while start_time_ts < end_time_ts:
|
||||
current_start_time_ts = end_time_ts - threshold
|
||||
|
|
@ -212,10 +213,11 @@ class MarketDataMain:
|
|||
current_min_start_time_ts = data["timestamp"].min()
|
||||
if current_min_start_time_ts < min_start_time_ts:
|
||||
min_start_time_ts = current_min_start_time_ts
|
||||
get_data = True
|
||||
if current_start_time_ts == start_time_ts:
|
||||
break
|
||||
end_time_ts = current_start_time_ts
|
||||
if min_start_time_ts is not None:
|
||||
if min_start_time_ts is not None and get_data:
|
||||
# 补充技术指标数据
|
||||
# 获得min_start_time_ts之前30条数据
|
||||
logging.info(f"开始补充技术指标数据: {symbol} {bar}")
|
||||
|
|
@ -223,7 +225,7 @@ class MarketDataMain:
|
|||
symbol, bar, min_start_time_ts, 30
|
||||
)
|
||||
if before_data is not None and len(before_data) > 0:
|
||||
earliest_timestamp = before_data[0]["timestamp"]
|
||||
earliest_timestamp = before_data[-1]["timestamp"]
|
||||
else:
|
||||
earliest_timestamp = min_start_time_ts
|
||||
handle_data = self.db_market_data.query_market_data_by_symbol_bar(
|
||||
|
|
|
|||
Loading…
Reference in New Issue