Py.Cafe

paulo.dias/

ethereum-preisprognose

Ethereum Preisprognose

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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>
"""