fix(strategies): unpack BIAS triple return value in bias_reversal

MyTT.BIAS returns (BIAS6, BIAS12, BIAS24) but the strategy was assigning
all three to a single variable, causing 'array with more than one element'
ValueError when comparing to a scalar threshold.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
GitHub
2026-06-09 18:56:07 +08:00
co-authored by Claude Opus 4.8
parent 6a6d75f5d5
commit 5550702620
+4 -3
View File
@@ -1,6 +1,6 @@
"""乖离率反转策略。 """乖离率反转策略。
乖离率低于阈值(超跌)买入,乖离率高于阈值(超涨)卖出。 6 日乖离率低于 -3%(超跌)买入,高于 3%(超涨)卖出。
适合震荡市。 适合震荡市。
用法:: 用法::
@@ -16,10 +16,11 @@ class BIAStrategy(Strategy):
"""乖离率反转策略。""" """乖离率反转策略。"""
def init(self) -> None: def init(self) -> None:
self.bias = self.I(MyTT.BIAS, self.data.close, 6) # BIAS 返回 3 个数组: BIAS6, BIAS12, BIAS24,只取 6 日
self.bias6, _, _ = self.I(MyTT.BIAS, self.data.close, 6)
def next(self) -> None: def next(self) -> None:
val = self.bias[self._bar_index] val = float(self.bias6[self._bar_index])
if val < -3 and self.position["size"] == 0: if val < -3 and self.position["size"] == 0:
self.buy(size=0) self.buy(size=0)