Full-stack iOS options trading assistant: - Python FastAPI backend with SQLite, APScheduler (15-min position monitor), APNs push notifications, and yfinance market data integration - Signal engine: IV Rank (rolling HV proxy), SMA-50/200, swing-based support/resistance, earnings detection, signal strength scoring and noise-resistant SHA hash for change detection - Recommendation engine: covered call and cash-secured put strike/expiry selection across 0DTE, 1DTE, weekly, and monthly horizons - REST API: /devices, /portfolio, /recommendations, /positions, /signals, /alerts - iOS SwiftUI app (iOS 17+): dashboard, recommendations, trades, portfolio, and alerts tabs with push notification deep-linking - Unit + integration tests for signal engine and API layer Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
from contextlib import asynccontextmanager
|
|
from datetime import datetime
|
|
from typing import AsyncGenerator
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.database import init_db
|
|
from app.scheduler import start_scheduler, stop_scheduler, scheduler
|
|
from app.routers import devices, portfolio, recommendations, positions, signals, alerts
|
|
from app.models.schemas import HealthResponse
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI) -> AsyncGenerator:
|
|
# Startup
|
|
init_db()
|
|
start_scheduler()
|
|
yield
|
|
# Shutdown
|
|
stop_scheduler()
|
|
|
|
|
|
app = FastAPI(
|
|
title="Options Sidekick",
|
|
description="Covered call and cash-secured put recommendation engine",
|
|
version="1.0.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Routers
|
|
app.include_router(devices.router, prefix="/api/v1")
|
|
app.include_router(portfolio.router, prefix="/api/v1")
|
|
app.include_router(recommendations.router, prefix="/api/v1")
|
|
app.include_router(positions.router, prefix="/api/v1")
|
|
app.include_router(signals.router, prefix="/api/v1")
|
|
app.include_router(alerts.router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/api/v1/health", response_model=HealthResponse, tags=["health"])
|
|
def health():
|
|
from app.services.position_monitor import last_run
|
|
return HealthResponse(
|
|
status="ok",
|
|
scheduler_running=scheduler.running,
|
|
last_run=last_run,
|
|
)
|