From 5550702620758cc0eaa5fb0dd0a3ae3b117ce6d1 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 9 Jun 2026 18:56:07 +0800 Subject: [PATCH] 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 --- strategies/bias_reversal.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/strategies/bias_reversal.py b/strategies/bias_reversal.py index 13c36cb..eeff260 100644 --- a/strategies/bias_reversal.py +++ b/strategies/bias_reversal.py @@ -1,6 +1,6 @@ """乖离率反转策略。 -乖离率低于阈值(超跌)买入,乖离率高于阈值(超涨)卖出。 +6 日乖离率低于 -3%(超跌)买入,高于 3%(超涨)卖出。 适合震荡市。 用法:: @@ -16,10 +16,11 @@ class BIAStrategy(Strategy): """乖离率反转策略。""" 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: - val = self.bias[self._bar_index] + val = float(self.bias6[self._bar_index]) if val < -3 and self.position["size"] == 0: self.buy(size=0)