Fix Supertrend strategy for NumPy 2.x compatibility

- Replaced  `np.NaN` with `None` to ensure compatibility with NumPy 2.x.
- Prevents AttributeError during backtesting in freqtrade with NumPy 2.x.
This commit is contained in:
Akash
2025-11-29 18:48:26 +05:30
committed by GitHub
parent a9a3fc2bbf
commit ac0d4729f7
+1 -1
View File
@@ -164,7 +164,7 @@ class Supertrend(IStrategy):
df['final_lb'].iat[i] if df[st].iat[i - 1] == df['final_lb'].iat[i - 1] and df['close'].iat[i] >= df['final_lb'].iat[i] else \
df['final_ub'].iat[i] if df[st].iat[i - 1] == df['final_lb'].iat[i - 1] and df['close'].iat[i] < df['final_lb'].iat[i] else 0.00
# Mark the trend direction up/down
df[stx] = np.where((df[st] > 0.00), np.where((df['close'] < df[st]), 'down', 'up'), np.NaN)
df[stx] = np.where((df[st] > 0.00), np.where((df['close'] < df[st]), 'down', 'up'), None)
# Remove basic and final bands from the columns
df.drop(['basic_ub', 'basic_lb', 'final_ub', 'final_lb'], inplace=True, axis=1)