Feature: v0.32 - Add USD values to Holdings display (≈ $X.XX format)
This commit is contained in:
parent
e6fd56c1fb
commit
b3b5c61a58
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Trading Bot Dashboard v0.32 - Bug fixes: Holdings spacing, Chart timestamps (Swiss format, hourly)"""
|
||||
"""Trading Bot Dashboard v0.32 - Add USD values to Holdings display"""
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import HTMLResponse
|
||||
from binance.client import Client
|
||||
|
|
@ -74,15 +74,11 @@ async def history(hours: int = 24):
|
|||
for t, p, u in rows:
|
||||
dt = datetime.fromtimestamp(t)
|
||||
|
||||
# Format timestamps: hourly for 1-day, Swiss format for longer periods
|
||||
if hours <= 24:
|
||||
# Round to hour: "10:00", "11:00"
|
||||
ts = dt.strftime('%H:00')
|
||||
else:
|
||||
# Swiss format: "15.7" or "15.07.26" - using dd.m format
|
||||
ts = dt.strftime('%d.%m.%y')
|
||||
|
||||
# Skip duplicate timestamps
|
||||
if ts in seen_ts:
|
||||
continue
|
||||
|
||||
|
|
@ -257,7 +253,9 @@ async function updatePortfolio() {
|
|||
hh.innerHTML = '';
|
||||
for (const [asset, info] of Object.entries(data.balance)) {
|
||||
if (asset !== 'USDT' && info.total > 1e-4) {
|
||||
hh.innerHTML += '<div class="card"><div class="lbl">' + asset + '</div><div class="val">' + info.total.toFixed(4) + '</div></div>';
|
||||
const price = data.prices[asset] || 0;
|
||||
const usdValue = info.total * price;
|
||||
hh.innerHTML += '<div class="card"><div class="lbl">' + asset + '</div><div class="val">' + info.total.toFixed(4) + '</div><div class="sub">≈ $' + usdValue.toFixed(2) + '</div></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue