DEV Community

qing
qing

Posted on

Python Crypto Dashboard: Track BTC ($62,613) and ETH Live

Python Crypto Dashboard: Track BTC and ETH Prices in Real-Time

Current BTC: $62,613 (+1.0%) 📈
Current ETH: $1,763 (+1.5%)

Build a real-time crypto price tracker in Python!

Setup

pip install httpx
Enter fullscreen mode Exit fullscreen mode

Complete Dashboard

import httpx
import asyncio
from datetime import datetime

SYMBOLS = ["BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT"]

async def get_price(symbol: str) -> dict:
    async with httpx.AsyncClient() as client:
        r = await client.get(
            "https://api.binance.com/api/v3/ticker/24hr",
            params={"symbol": symbol}
        )
        d = r.json()
        return {
            "symbol": symbol.replace("USDT", ""),
            "price": float(d["lastPrice"]),
            "change_24h": float(d["priceChangePercent"]),
            "volume": float(d["volume"]),
        }

async def dashboard():
    print(f"\n==================================================")
    print(f"🚀 Crypto Dashboard - {datetime.now().strftime('%H:%M:%S')}")
    print(f"==================================================")

    prices = await asyncio.gather(*[get_price(s) for s in SYMBOLS])

    for p in prices:
        icon = "📈" if p["change_24h"] > 0 else "📉"
        print(f"{icon} {p['symbol']}: ${p['price']:>10,.2f} | {p['change_24h']:>+6.2f}%")

    print(f"\n==================================================")

# Run once
asyncio.run(dashboard())

# Or run every 30 seconds
async def live_dashboard():
    while True:
        await dashboard()
        await asyncio.sleep(30)

asyncio.run(live_dashboard())
Enter fullscreen mode Exit fullscreen mode

Add Alerts

async def price_alert(symbol: str, threshold: float):
    while True:
        data = await get_price(symbol)
        if abs(data["change_24h"]) > threshold:
            print(f"🚨 ALERT: {symbol} moved {data['change_24h']:+.2f}%!")
        await asyncio.sleep(60)

asyncio.run(price_alert("BTCUSDT", 5.0))  # Alert if BTC moves >5%
Enter fullscreen mode Exit fullscreen mode

Current Market (2026-07-04)

Coin Price 24h Change
BTC $62,613 +1.0%
ETH $1,763 +1.5%

Live data from Binance public API. Follow for more Python finance tips!

Follow for more Python content!


💡 Related: **Content Creator Ultimate Bundle (Save 33%)* — $29.99*

Top comments (0)