Bot auto-update: src/__pycache__/web_dashboard.cpython-310.pyc,src/web_dashboard.py

This commit is contained in:
Marc Blatter 2026-07-04 12:54:16 +02:00
parent b41d00bc4c
commit 8acd83b33f
2 changed files with 91 additions and 151 deletions

View File

@ -118,9 +118,11 @@ async def record_buy(pair: str, qty: float, price: float):
"""Record a buy trade""" """Record a buy trade"""
trading_state['current_trades'][pair] = { trading_state['current_trades'][pair] = {
'qty': qty, 'qty': qty,
'entry_price': price, 'buy_price': price,
'entry_time': datetime.now().isoformat(), 'buy_time': datetime.now().isoformat(),
'type': 'BUY' 'peak_profit': 0,
'trailing_stop': None,
'order_id': None
} }
trading_state['trades_today'] += 1 trading_state['trades_today'] += 1
await broadcast_update() await broadcast_update()
@ -209,17 +211,21 @@ html_content = """
<title>Trading Bot Dashboard</title> <title>Trading Bot Dashboard</title>
<style> <style>
* { * {
margin: 0; font-family: 'Courier New', monospace;
padding: 0;
box-sizing: border-box;
} }
body { body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #0a0e27;
background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%); color: #ffd700;
color: #e0e0e0; margin: 0;
padding: 20px; padding: 20px;
min-height: 100vh; }
h1 {
color: #ffd700;
text-shadow: 0 0 10px #ffd700;
border-bottom: 3px solid #ffd700;
padding-bottom: 10px;
} }
.container { .container {
@ -227,186 +233,120 @@ html_content = """
margin: 0 auto; margin: 0 auto;
} }
.header { .status-bar {
text-align: center; background-color: #1c4700;
margin-bottom: 30px; border: 2px solid #ffd700;
border-bottom: 2px solid #6c63ff; padding: 10px;
padding-bottom: 20px; margin-bottom: 20px;
border-radius: 5px;
} }
.header h1 { .status-bar .status-indicator {
font-size: 2.5em; background-color: #0f0;
color: #6c63ff; color: #000;
margin-bottom: 10px; padding: 5px 10px;
} border-radius: 3px;
.status {
display: inline-block;
padding: 8px 16px;
background: #00c853;
color: white;
border-radius: 20px;
font-weight: bold; font-weight: bold;
font-size: 0.9em; display: inline-block;
} }
.grid { .metrics {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px; gap: 15px;
margin-bottom: 30px; margin-bottom: 20px;
} }
.card { .card {
background: rgba(255, 255, 255, 0.1); background-color: #1a1a2e;
border: 1px solid #6c63ff; border: 2px solid #ffd700;
border-radius: 10px; border-radius: 5px;
padding: 20px; padding: 15px;
backdrop-filter: blur(10px); box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
transition: all 0.3s ease;
}
.card:hover {
background: rgba(255, 255, 255, 0.15);
border-color: #00c853;
transform: translateY(-5px);
} }
.card-title { .card-title {
color: #6c63ff; color: #ffd700;
font-size: 0.9em; font-weight: bold;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 1px; font-size: 12px;
margin-bottom: 10px; letter-spacing: 2px;
margin-bottom: 8px;
border-bottom: 1px solid #ffd700;
padding-bottom: 5px;
} }
.card-value { .card-value {
font-size: 2em; color: #ffd700;
font-size: 24px;
font-weight: bold; font-weight: bold;
color: #e0e0e0; text-shadow: 0 0 10px #ffd700;
margin-bottom: 5px;
} }
.card-sub { .card-sub {
color: #a0a0a0; color: #888;
font-size: 0.85em; font-size: 11px;
margin-top: 5px;
} }
.positive { .positive {
color: #00c853; color: #0f0;
text-shadow: 0 0 10px #0f0;
} }
.negative { .negative {
color: #ff3d00; color: #ff4444;
text-shadow: 0 0 10px #ff4444;
} }
.section { .trades-section {
margin-bottom: 30px; background-color: #1a1a2e;
border: 2px solid #ffd700;
border-radius: 5px;
padding: 15px;
margin-top: 20px;
} }
.section-title { .trades-section h2 {
color: #6c63ff; color: #ffd700;
font-size: 1.5em; text-transform: uppercase;
margin-bottom: 15px; letter-spacing: 2px;
border-bottom: 1px solid #6c63ff; border-bottom: 2px solid #ffd700;
padding-bottom: 10px; padding-bottom: 10px;
} }
.trades-list { table {
display: grid; width: 100%;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); border-collapse: collapse;
gap: 15px; margin-top: 15px;
} }
.trade-card { th {
background: rgba(255, 255, 255, 0.08); background-color: #1c4700;
border-left: 4px solid #6c63ff; color: #ffd700;
border-radius: 5px;
padding: 15px;
font-size: 0.9em;
}
.trade-card.open {
border-left-color: #6c63ff;
}
.trade-card.closed {
border-left-color: #00c853;
}
.trade-pair {
font-weight: bold;
color: #6c63ff;
margin-bottom: 8px;
}
.trade-info {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
font-size: 0.85em;
color: #a0a0a0;
}
.trade-info strong {
color: #e0e0e0;
}
.swap-item {
background: rgba(255, 255, 255, 0.05);
padding: 10px; padding: 10px;
border-radius: 5px; text-align: left;
margin-bottom: 8px;
font-size: 0.85em;
}
.performance-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
.stat-card {
background: rgba(108, 99, 255, 0.2);
border: 1px solid #6c63ff;
border-radius: 8px;
padding: 15px;
text-align: center;
}
.stat-label {
color: #a0a0a0;
font-size: 0.8em;
text-transform: uppercase; text-transform: uppercase;
margin-bottom: 8px; font-size: 12px;
letter-spacing: 1px;
border: 1px solid #ffd700;
} }
.stat-value { td {
font-size: 1.8em; color: #ffd700;
font-weight: bold; padding: 10px;
color: #00c853; border: 1px solid #1c4700;
} }
.stat-value.loss { tr:hover {
color: #ff3d00; background-color: #1c4700;
} }
.update-time { .last-update {
text-align: right; color: #888;
color: #666; font-size: 11px;
font-size: 0.8em;
margin-top: 20px; margin-top: 20px;
padding-top: 20px; text-align: right;
border-top: 1px solid #333;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.fade-in {
animation: fadeIn 0.3s ease-in;
} }
</style> </style>
</head> </head>
@ -519,23 +459,23 @@ html_content = """
// Update key metrics - CHF PRIMARY, USD secondary // Update key metrics - CHF PRIMARY, USD secondary
const usdt = data.balance.USDT || 0; const usdt = data.balance.USDT || 0;
const usdt_chf = usdt * 0.84; const usdt_chf = usdt * 0.84;
document.getElementById('usdt').textContent = `$${usdt.toFixed(2)} / CHF ${usdt_chf.toFixed(2)}`; document.getElementById('usdt').textContent = `$${usdt.toFixed(2)}`;
const portfolio_usd = data.portfolio_value_usd || 0; const portfolio_usd = data.portfolio_value_usd || 0;
const portfolio_chf = data.portfolio_value_chf || (portfolio_usd * 0.84); const portfolio_chf = data.portfolio_value_chf || (portfolio_usd * 0.84);
document.getElementById('portfolio').textContent = `$${portfolio_usd.toFixed(2)} / CHF ${portfolio_chf.toFixed(2)}`; document.getElementById('portfolio').textContent = `$${portfolio_usd.toFixed(2)}`;
// Update P&L with color - CHF primary // Update P&L with color - CHF primary
const dailyPnl = data.daily_pnl || 0; const dailyPnl = data.daily_pnl || 0;
const dailyPnl_chf = dailyPnl * 0.84; const dailyPnl_chf = dailyPnl * 0.84;
const dailyPnlEl = document.getElementById('daily-pnl'); const dailyPnlEl = document.getElementById('daily-pnl');
dailyPnlEl.textContent = `$${dailyPnl >= 0 ? '+' : ''}${dailyPnl.toFixed(2)} / CHF ${dailyPnl_chf >= 0 ? '+' : ''}${dailyPnl_chf.toFixed(2)}`; dailyPnlEl.textContent = `$${dailyPnl >= 0 ? '+' : ''}${dailyPnl.toFixed(2)}`;
dailyPnlEl.className = 'card-value ' + (dailyPnl >= 0 ? 'positive' : 'negative'); dailyPnlEl.className = 'card-value ' + (dailyPnl >= 0 ? 'positive' : 'negative');
const totalPnl = data.total_pnl || 0; const totalPnl = data.total_pnl || 0;
const totalPnl_chf = totalPnl * 0.84; const totalPnl_chf = totalPnl * 0.84;
const totalPnlEl = document.getElementById('total-pnl'); const totalPnlEl = document.getElementById('total-pnl');
totalPnlEl.textContent = `$${totalPnl >= 0 ? '+' : ''}${totalPnl.toFixed(2)} / CHF ${totalPnl_chf >= 0 ? '+' : ''}${totalPnl_chf.toFixed(2)}`; totalPnlEl.textContent = `$${totalPnl >= 0 ? '+' : ''}${totalPnl.toFixed(2)}`;
totalPnlEl.className = 'card-value ' + (totalPnl >= 0 ? 'positive' : 'negative'); totalPnlEl.className = 'card-value ' + (totalPnl >= 0 ? 'positive' : 'negative');
// Update performance // Update performance