修复bug

This commit is contained in:
dekun
2026-05-18 08:10:28 +08:00
parent 24550b0ce0
commit 82a7237063
8 changed files with 132 additions and 58 deletions
+3 -14
View File
@@ -3,6 +3,8 @@ from __future__ import annotations
from dataclasses import dataclass, field
from statistics import mean
from .candle_rows import rows_to_ohlcv
# 以下换算仅针对 5m K(与是否单独拉 4h 图无关):
# 每小时 60/5 = 12 根;一根「4 小时」大周期对应 4×12 = 48 根 5m。
BARS_5M_PER_HOUR = 12
@@ -29,19 +31,6 @@ class ExchangeRuleResult:
metrics: dict = field(default_factory=dict)
def _rows_to_ohlcv(rows: list[list[str]]) -> tuple[list[float], list[float], list[float], list[float], list[float]]:
o, h, l, c, v = [], [], [], [], []
for item in rows:
if len(item) < 6:
continue
o.append(float(item[1]))
h.append(float(item[2]))
l.append(float(item[3]))
c.append(float(item[4]))
v.append(float(item[5]))
return o, h, l, c, v
def evaluate_exchange(
symbol: str,
alt_rows: list[list[str]],
@@ -56,7 +45,7 @@ def evaluate_exchange(
"""
breakout_max_pct = 0.5
result = ExchangeRuleResult()
_, ah, al, ac, av = _rows_to_ohlcv(alt_rows)
_, ah, al, ac, av = rows_to_ohlcv(alt_rows)
bars_for_range = max(
MIN_BOX_LOOKBACK_BARS_5M,