加入一个回测,

This commit is contained in:
ddrwode
2026-03-09 14:26:38 +08:00
parent c3f8928d78
commit 34f123bcf0

View File

@@ -550,8 +550,10 @@ class BBDelayReversalTrader:
# 5. 极值更新与半仓/延迟全平反手逻辑
if self.position == 1 and self.open_avg_price:
if self.highest_since_open is None or current_price > self.highest_since_open:
self.highest_since_open = current_price
# 记录持有期内的最高价 (包含当前实时价和当前K线最高价)
current_max = max(current_price, cur_high)
if self.highest_since_open is None or current_max > self.highest_since_open:
self.highest_since_open = current_max
# 延迟平仓逻辑: 之前触碰过上轨
if self.touched_band_price is not None:
@@ -632,8 +634,10 @@ class BBDelayReversalTrader:
continue
elif self.position == -1 and self.open_avg_price:
if self.lowest_since_open is None or current_price < self.lowest_since_open:
self.lowest_since_open = current_price
# 记录持有期内的最低价 (包含当前实时价和当前K线最低价)
current_min = min(current_price, cur_low)
if self.lowest_since_open is None or current_min < self.lowest_since_open:
self.lowest_since_open = current_min
# 延迟平仓逻辑: 之前触碰过下轨
if self.touched_band_price is not None: