Add BTC candlestick chart with local OHLC storage
- Store daily BTC OHLC candles in SQLite to avoid hitting CoinGecko on every load - Seed with 30 days of daily candles on first boot (free tier gives daily granularity for days<=30) - Auto-detect and replace coarse legacy candle data on startup - Daily refresh adds new candles on each container restart - New GET /candles endpoint (supports ?days=365 and ?days=all) - Switch BTCHistoryChart to BTCCandlestickChart using lightweight-charts (TradingView) - Purchase markers with nearest-candle matching and multi-purchase merging - Fullscreen mode showing all stored candles - Fix frontend port to 3001 and pass REACT_APP_API_URL as build arg Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from .database import engine, Base
|
||||
from .routes import users, purchases, stats, history
|
||||
from .database import engine, Base, SessionLocal
|
||||
from .routes import users, purchases, stats, history, candles
|
||||
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
@@ -10,7 +10,7 @@ app = FastAPI(title="BTC Portfolio API")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:3000"],
|
||||
allow_origins=["http://localhost:3000", "http://localhost:3001"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
@@ -20,6 +20,17 @@ app.include_router(users.router)
|
||||
app.include_router(purchases.router)
|
||||
app.include_router(stats.router)
|
||||
app.include_router(history.router)
|
||||
app.include_router(candles.router)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def startup():
|
||||
from .services.candles import refresh_latest_candles
|
||||
db = SessionLocal()
|
||||
try:
|
||||
refresh_latest_candles(db)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
|
||||
Reference in New Issue
Block a user