Cache last known BTC price and show stale warning in UI
When the CoinGecko API fails, fall back to the last successful price instead of 0.0, and surface a warning indicator on the price card. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,7 @@ def get_stats(
|
||||
net_btc = total_btc_bought - total_btc_sold
|
||||
net_invested = total_invested - proceeds_eur
|
||||
average_price = net_invested / net_btc if net_btc > 0 else 0.0
|
||||
current_price = get_btc_price_eur()
|
||||
current_price, price_is_cached = get_btc_price_eur()
|
||||
portfolio_value = net_btc * current_price
|
||||
profit_loss = portfolio_value - net_invested
|
||||
|
||||
@@ -35,6 +35,7 @@ def get_stats(
|
||||
"total_btc": round(net_btc, 8),
|
||||
"average_price": round(average_price, 2),
|
||||
"current_price": round(current_price, 2),
|
||||
"price_is_cached": price_is_cached,
|
||||
"portfolio_value": round(portfolio_value, 2),
|
||||
"profit_loss": round(profit_loss, 2),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user