Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -101,9 +101,9 @@ def calculate_fibonacci_levels(data):
|
|
| 101 |
"78.6%": high - diff * 0.786,
|
| 102 |
}
|
| 103 |
|
| 104 |
-
# Function to calculate probabilities
|
| 105 |
def calculate_probabilities(data):
|
| 106 |
-
# Calculate indicators
|
| 107 |
data['RSI'] = calculate_rsi(data)
|
| 108 |
data['MACD'], data['MACD_Signal'] = calculate_macd(data)
|
| 109 |
data['EMA_50'] = calculate_ema(data, period=50)
|
|
@@ -117,7 +117,7 @@ def calculate_probabilities(data):
|
|
| 117 |
# Use the most recent values for predictions
|
| 118 |
recent_data = data.iloc[-1]
|
| 119 |
|
| 120 |
-
# Calculate probabilities
|
| 121 |
probabilities = {
|
| 122 |
"RSI": {"Pump": 0, "Dump": 0},
|
| 123 |
"MACD": {"Pump": 0, "Dump": 0},
|
|
@@ -273,9 +273,12 @@ def fetch_crypto_news(symbol):
|
|
| 273 |
# Format the date as "Month Day"
|
| 274 |
published_date = datetime.strptime(entry.published, "%a, %d %b %Y %H:%M:%S %z").strftime("%B %d")
|
| 275 |
|
|
|
|
|
|
|
|
|
|
| 276 |
news_items.append({
|
| 277 |
"title": entry.title,
|
| 278 |
-
"
|
| 279 |
"sentiment": sentiment,
|
| 280 |
"published": published_date,
|
| 281 |
})
|
|
@@ -295,7 +298,7 @@ def crypto_app(symbol):
|
|
| 295 |
if len(data) < 20:
|
| 296 |
return f"Not enough data to calculate indicators. Only {len(data)} rows available. Please try a longer period."
|
| 297 |
else:
|
| 298 |
-
# Calculate probabilities
|
| 299 |
probabilities, recent_data = calculate_probabilities(data)
|
| 300 |
|
| 301 |
# Predict future prices
|
|
@@ -308,7 +311,7 @@ def crypto_app(symbol):
|
|
| 308 |
fib_levels = calculate_fibonacci_levels(data)
|
| 309 |
|
| 310 |
# Prepare output
|
| 311 |
-
output = f"**{symbol} Pump/Dump Probabilities
|
| 312 |
for indicator, values in probabilities.items():
|
| 313 |
output += f"- **{indicator}**: Pump: {values['Pump']:.2f}%, Dump: {values['Dump']:.2f}%\n"
|
| 314 |
|
|
@@ -325,8 +328,7 @@ def crypto_app(symbol):
|
|
| 325 |
output += "\n**Latest Crypto News Sentiment:**\n"
|
| 326 |
if isinstance(news_items, list):
|
| 327 |
for news in news_items:
|
| 328 |
-
output += f"- **{news['title']}** ({news['sentiment']}) - {news['
|
| 329 |
-
output += f" [Read more]({news['link']})\n"
|
| 330 |
else:
|
| 331 |
output += news_items
|
| 332 |
|
|
@@ -334,13 +336,15 @@ def crypto_app(symbol):
|
|
| 334 |
else:
|
| 335 |
return "Please enter a cryptocurrency symbol."
|
| 336 |
|
| 337 |
-
# Gradio Interface
|
| 338 |
iface = gr.Interface(
|
| 339 |
fn=crypto_app,
|
| 340 |
inputs=gr.Textbox(placeholder="Enter cryptocurrency symbol (e.g., ETH, BTC)"),
|
| 341 |
outputs="text",
|
| 342 |
-
title="Crypto
|
| 343 |
description="This app provides technical indicator-based predictions, price forecasts, and sentiment analysis for any cryptocurrency.",
|
|
|
|
|
|
|
| 344 |
)
|
| 345 |
|
| 346 |
iface.launch()
|
|
|
|
| 101 |
"78.6%": high - diff * 0.786,
|
| 102 |
}
|
| 103 |
|
| 104 |
+
# Function to calculate probabilities
|
| 105 |
def calculate_probabilities(data):
|
| 106 |
+
# Calculate indicators
|
| 107 |
data['RSI'] = calculate_rsi(data)
|
| 108 |
data['MACD'], data['MACD_Signal'] = calculate_macd(data)
|
| 109 |
data['EMA_50'] = calculate_ema(data, period=50)
|
|
|
|
| 117 |
# Use the most recent values for predictions
|
| 118 |
recent_data = data.iloc[-1]
|
| 119 |
|
| 120 |
+
# Calculate probabilities
|
| 121 |
probabilities = {
|
| 122 |
"RSI": {"Pump": 0, "Dump": 0},
|
| 123 |
"MACD": {"Pump": 0, "Dump": 0},
|
|
|
|
| 273 |
# Format the date as "Month Day"
|
| 274 |
published_date = datetime.strptime(entry.published, "%a, %d %b %Y %H:%M:%S %z").strftime("%B %d")
|
| 275 |
|
| 276 |
+
# Extract website name from the link
|
| 277 |
+
website = entry.link.split("//")[1].split("/")[0]
|
| 278 |
+
|
| 279 |
news_items.append({
|
| 280 |
"title": entry.title,
|
| 281 |
+
"website": website,
|
| 282 |
"sentiment": sentiment,
|
| 283 |
"published": published_date,
|
| 284 |
})
|
|
|
|
| 298 |
if len(data) < 20:
|
| 299 |
return f"Not enough data to calculate indicators. Only {len(data)} rows available. Please try a longer period."
|
| 300 |
else:
|
| 301 |
+
# Calculate probabilities
|
| 302 |
probabilities, recent_data = calculate_probabilities(data)
|
| 303 |
|
| 304 |
# Predict future prices
|
|
|
|
| 311 |
fib_levels = calculate_fibonacci_levels(data)
|
| 312 |
|
| 313 |
# Prepare output
|
| 314 |
+
output = f"**{symbol} Pump/Dump Probabilities:**\n"
|
| 315 |
for indicator, values in probabilities.items():
|
| 316 |
output += f"- **{indicator}**: Pump: {values['Pump']:.2f}%, Dump: {values['Dump']:.2f}%\n"
|
| 317 |
|
|
|
|
| 328 |
output += "\n**Latest Crypto News Sentiment:**\n"
|
| 329 |
if isinstance(news_items, list):
|
| 330 |
for news in news_items:
|
| 331 |
+
output += f"- **{news['title']}** ({news['sentiment']}) - {news['website']}\n"
|
|
|
|
| 332 |
else:
|
| 333 |
output += news_items
|
| 334 |
|
|
|
|
| 336 |
else:
|
| 337 |
return "Please enter a cryptocurrency symbol."
|
| 338 |
|
| 339 |
+
# Gradio Interface with Background Image
|
| 340 |
iface = gr.Interface(
|
| 341 |
fn=crypto_app,
|
| 342 |
inputs=gr.Textbox(placeholder="Enter cryptocurrency symbol (e.g., ETH, BTC)"),
|
| 343 |
outputs="text",
|
| 344 |
+
title="Crypto AI Agent ππ",
|
| 345 |
description="This app provides technical indicator-based predictions, price forecasts, and sentiment analysis for any cryptocurrency.",
|
| 346 |
+
theme="default", # Use a theme that supports custom backgrounds
|
| 347 |
+
css=".gradio-container { background-image: url('https://example.com/crypto-background.jpg'); background-size: cover; }",
|
| 348 |
)
|
| 349 |
|
| 350 |
iface.launch()
|