Spaces:
Runtime error
Runtime error
Ken Sang Tang commited on
Update app.py
Browse files
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
|
| 60 |
-
data['BB_upper']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|