541b5f57d2
New GET /history endpoint fetches 365 days of BTC/EUR data from CoinGecko, deduplicates by date, and joins the user's purchases. BTCHistoryChart component renders the price line with orange dot markers on purchase dates and a dashed cyan avg buy price line. Tooltip shows purchase details on marked dates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
785 B
Python
28 lines
785 B
Python
import requests
|
|
|
|
|
|
def get_btc_history_eur() -> list:
|
|
try:
|
|
resp = requests.get(
|
|
"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart",
|
|
params={"vs_currency": "eur", "days": "365", "interval": "daily"},
|
|
timeout=15,
|
|
)
|
|
resp.raise_for_status()
|
|
return resp.json().get("prices", []) # [[timestamp_ms, price], ...]
|
|
except Exception:
|
|
return []
|
|
|
|
|
|
def get_btc_price_eur() -> float:
|
|
try:
|
|
resp = requests.get(
|
|
"https://api.coingecko.com/api/v3/simple/price",
|
|
params={"ids": "bitcoin", "vs_currencies": "eur"},
|
|
timeout=10,
|
|
)
|
|
resp.raise_for_status()
|
|
return float(resp.json()["bitcoin"]["eur"])
|
|
except Exception:
|
|
return 0.0
|