Ken Sang Tang commited on
Commit
df4937d
·
verified ·
1 Parent(s): 3f8befe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -56,11 +56,18 @@ def add_technical_indicators(data):
56
 
57
  # Add Bollinger Bands and handle potential missing columns
58
  bbands = ta.bbands(data['Close'])
59
- if 'BBU_20_2.0' in bbands.columns:
60
- data['BB_upper'], data['BB_middle'], data['BB_lower'] = bbands['BBU_20_2.0'], bbands['BBM_20_2.0'], bbands['BBL_20_2.0']
 
 
 
 
 
 
 
61
  else:
62
  print("Bollinger Bands data not available.")
63
-
64
  return data
65
 
66
  # Step 3: Analyze Sentiment using FinBERT
 
56
 
57
  # Add Bollinger Bands and handle potential missing columns
58
  bbands = ta.bbands(data['Close'])
59
+ if bbands is not None:
60
+ data['BB_upper'] = bbands.get('BBU_20_2.0')
61
+ data['BB_middle'] = bbands.get('BBM_20_2.0')
62
+ data['BB_lower'] = bbands.get('BBL_20_2.0')
63
+
64
+ # Ensure the columns are added only if they exist
65
+ if data[['BB_upper', 'BB_middle', 'BB_lower']].isnull().all().all():
66
+ print("Bollinger Bands data is incomplete or not available.")
67
+ data.drop(columns=['BB_upper', 'BB_middle', 'BB_lower'], inplace=True, errors='ignore')
68
  else:
69
  print("Bollinger Bands data not available.")
70
+
71
  return data
72
 
73
  # Step 3: Analyze Sentiment using FinBERT