Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -164,7 +164,7 @@ def analyze_sentiment(asset_name):
|
|
| 164 |
"""Analyze market sentiment for selected asset"""
|
| 165 |
try:
|
| 166 |
ticker = asset_map[asset_name]
|
| 167 |
-
# FIX: Memanggil fungsi yang benar dari sentiment_analyzer.py
|
| 168 |
sentiment_score, news_summary = sentiment_analyzer.analyze_market_sentiment(ticker)
|
| 169 |
|
| 170 |
# --- Implementasi Matplotlib Gauge (Sesuai Gambar Referensi) ---
|
|
@@ -182,15 +182,13 @@ def analyze_sentiment(asset_name):
|
|
| 182 |
theta = np.linspace(np.pi, 0, 100)
|
| 183 |
x, y = np.cos(theta), np.sin(theta)
|
| 184 |
|
| 185 |
-
# Draw full light gray arc
|
| 186 |
ax.plot(x, y, color='lightgray', linewidth=10, solid_capstyle='round', zorder=1)
|
| 187 |
|
| 188 |
# Segments (Matching the image)
|
| 189 |
-
# Warna arc harus dicocokkan dengan gambar
|
| 190 |
-
|
| 191 |
# 1. Red: -1.0 to -0.5
|
| 192 |
ax.fill_between(x[75:], y[75:], 0, where=x[75:]<=-0.5, color='#F08080', alpha=0.9, linewidth=0, zorder=2)
|
| 193 |
-
# 2. Yellow/Orange: -0.5 to 0.0
|
| 194 |
ax.fill_between(x[50:75], y[50:75], 0, where=x[50:75]<0, color='#FFD700', alpha=0.9, linewidth=0, zorder=2)
|
| 195 |
# 3. Light Gray: 0.0 to 0.5 (Neutral)
|
| 196 |
ax.fill_between(x[25:50], y[25:50], 0, where=x[25:50]>0, color='#D3D3D3', alpha=0.9, linewidth=0, zorder=2)
|
|
@@ -207,7 +205,7 @@ def analyze_sentiment(asset_name):
|
|
| 207 |
ax.plot([0, needle_x], [0, needle_y], color='gold', linewidth=6, solid_capstyle='round', zorder=5)
|
| 208 |
# Draw the black cap on the arc (untuk tampilan jarum)
|
| 209 |
ax.plot([needle_x], [needle_y], marker='|', color='black', markersize=15, markeredgewidth=2, zorder=6)
|
| 210 |
-
# Center black point
|
| 211 |
ax.plot([0], [0], marker='o', color='black', markersize=8, zorder=7)
|
| 212 |
|
| 213 |
# Draw score number (seperti gambar)
|
|
|
|
| 164 |
"""Analyze market sentiment for selected asset"""
|
| 165 |
try:
|
| 166 |
ticker = asset_map[asset_name]
|
| 167 |
+
# FIX PENTING: Memanggil fungsi yang benar dari sentiment_analyzer.py
|
| 168 |
sentiment_score, news_summary = sentiment_analyzer.analyze_market_sentiment(ticker)
|
| 169 |
|
| 170 |
# --- Implementasi Matplotlib Gauge (Sesuai Gambar Referensi) ---
|
|
|
|
| 182 |
theta = np.linspace(np.pi, 0, 100)
|
| 183 |
x, y = np.cos(theta), np.sin(theta)
|
| 184 |
|
| 185 |
+
# Draw full light gray arc (Outer ring)
|
| 186 |
ax.plot(x, y, color='lightgray', linewidth=10, solid_capstyle='round', zorder=1)
|
| 187 |
|
| 188 |
# Segments (Matching the image)
|
|
|
|
|
|
|
| 189 |
# 1. Red: -1.0 to -0.5
|
| 190 |
ax.fill_between(x[75:], y[75:], 0, where=x[75:]<=-0.5, color='#F08080', alpha=0.9, linewidth=0, zorder=2)
|
| 191 |
+
# 2. Yellow/Orange: -0.5 to 0.0
|
| 192 |
ax.fill_between(x[50:75], y[50:75], 0, where=x[50:75]<0, color='#FFD700', alpha=0.9, linewidth=0, zorder=2)
|
| 193 |
# 3. Light Gray: 0.0 to 0.5 (Neutral)
|
| 194 |
ax.fill_between(x[25:50], y[25:50], 0, where=x[25:50]>0, color='#D3D3D3', alpha=0.9, linewidth=0, zorder=2)
|
|
|
|
| 205 |
ax.plot([0, needle_x], [0, needle_y], color='gold', linewidth=6, solid_capstyle='round', zorder=5)
|
| 206 |
# Draw the black cap on the arc (untuk tampilan jarum)
|
| 207 |
ax.plot([needle_x], [needle_y], marker='|', color='black', markersize=15, markeredgewidth=2, zorder=6)
|
| 208 |
+
# Center black point
|
| 209 |
ax.plot([0], [0], marker='o', color='black', markersize=8, zorder=7)
|
| 210 |
|
| 211 |
# Draw score number (seperti gambar)
|