- Added FastAPI backend with core API endpoints for strategies, backtests, and data management. - Introduced Vue 3 frontend with a dark theme, enabling users to run backtests, adjust parameters, and compare results. - Implemented Pydantic schemas for request/response validation and SQLAlchemy models for database interactions. - Enhanced project structure with dedicated modules for services, routers, and components. - Updated dependencies in `pyproject.toml` and `frontend/package.json` to include FastAPI, SQLAlchemy, and Vue-related packages. - Improved `.gitignore` to exclude unnecessary files and directories.
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
"""
|
|
FastAPI application entry point for Lowkey Backtest UI.
|
|
|
|
Run with: uvicorn api.main:app --reload
|
|
"""
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from api.models.database import init_db
|
|
from api.routers import backtest, data, strategies
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Initialize database on startup."""
|
|
init_db()
|
|
yield
|
|
|
|
|
|
app = FastAPI(
|
|
title="Lowkey Backtest API",
|
|
description="API for running and analyzing trading strategy backtests",
|
|
version="0.1.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
# CORS configuration for local development
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Register routers
|
|
app.include_router(strategies.router, prefix="/api", tags=["strategies"])
|
|
app.include_router(data.router, prefix="/api", tags=["data"])
|
|
app.include_router(backtest.router, prefix="/api", tags=["backtest"])
|
|
|
|
|
|
@app.get("/api/health")
|
|
async def health_check():
|
|
"""Health check endpoint."""
|
|
return {"status": "ok", "service": "lowkey-backtest-api"}
|