refactor: Update BB calculation with ffill() and debug print

This commit is contained in:
Bobby (aider) 2025-02-13 23:40:38 -08:00
parent 17e9024a3f
commit c771e479bb

View File

@ -80,10 +80,14 @@ class DynamicStrategy(Strategy):
middle_col = bb_result.columns[1] # BBM
lower_col = bb_result.columns[0] # BBL
# Extract and process the values
upper = bb_result[upper_col].fillna(method='ffill').fillna(0).values
middle = bb_result[middle_col].fillna(method='ffill').fillna(0).values
lower = bb_result[lower_col].fillna(method='ffill').fillna(0).values
# Extract and process the values using ffill() instead of fillna(method='ffill')
upper = bb_result[upper_col].ffill().fillna(0).values
middle = bb_result[middle_col].ffill().fillna(0).values
lower = bb_result[lower_col].ffill().fillna(0).values
# Add debug print to verify values
if len(upper) > 0:
print(f"Debug BB values - Upper: {upper[-1]:.2f}, Middle: {middle[-1]:.2f}, Lower: {lower[-1]:.2f}")
return upper, middle, lower