import dash
from dash import html
from datetime import datetime
import requests
import random
# CoinGecko API-Key
API_KEY = "CG-AA9irFbKztQh3VTVDHRoeZVH"
HEADERS = {"x-cg-demo-api-key": API_KEY}
def fetch_eth_price():
url = "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=eur"
response = requests.get(url, headers=HEADERS)
response.raise_for_status()
return response.json()["ethereum"]["eur"]
def randomized_forecast(base_percentage):
fluctuation = 0.15
adjusted = base_percentage * (1 + random.uniform(-fluctuation, fluctuation))
return round(adjusted, 2)
def generate_forecast(current_price, base_percent):
percent = randomized_forecast(base_percent)
price = round(current_price * (1 + percent / 100), 2)
return price, percent
def get_forecast_data():
now = datetime.now()
current_price = fetch_eth_price()
forecast_bases = {
"2025": {"Optimistisch": 220, "Durchschnittlich": 160, "Pessimistisch": 60},
"2026": {"Optimistisch": 280, "Durchschnittlich": 190, "Pessimistisch": 75},
"2030": {"Optimistisch": 390, "Durchschnittlich": 210, "Pessimistisch": 120}
}
forecast = {}
for year, scenarios in forecast_bases.items():
forecast[year] = {
label: generate_forecast(current_price, base)
for label, base in scenarios.items()
}
return forecast, now.strftime("%d.%m.%Y %H:%M Uhr")
forecast_data, timestamp_str = get_forecast_data()
app = dash.Dash(__name__)
app.title = "Ethereum Prognosen"
def build_forecast_box(year, data, timestamp):
return html.Div(style={
"background": "#f1f1f1",
"border": "3px solid #ffcc00",
"borderRadius": "12px",
"padding": "20px",
"margin": "20px auto",
"maxWidth": "500px",
"fontFamily": "Segoe UI"
}, children=[
html.H3(f"Ethereum Prognose {year}", style={"textAlign": "center"}),
html.Div([
html.Div([
html.Div(label, className="label"),
html.Div(f"{price:,.2f} €", className="value"),
html.Div(f"+ {percent:.2f} %", className="percent")
], style={"display": "flex", "justifyContent": "space-between", "margin": "5px 0"})
for label, (price, percent) in data.items()
]),
html.Div(f"Letztes Update: {timestamp}", style={
"textAlign": "center", "fontSize": "0.8em", "color": "#666", "marginTop": "10px"
})
])
app.layout = html.Div([
html.H1("Ethereum Prognosen", style={"textAlign": "center", "fontFamily": "Segoe UI"}),
build_forecast_box("2025", forecast_data["2025"], timestamp_str),
build_forecast_box("2026", forecast_data["2026"], timestamp_str),
build_forecast_box("2030", forecast_data["2030"], timestamp_str)
])
__all__ = ['app']
app.index_string = """
<!DOCTYPE html>
<html>
<head>
{%metas%}
<title>{%title%}</title>
{%favicon%}
{%css%}
<style>
.label {
width: 33%;
font-weight: bold;
}
.value {
width: 33%;
text-align: right;
padding-right: 8px;
}
.percent {
width: 33%;
text-align: right;
color: green;
}
</style>
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
</body>
</html>
"""