Stack: FastAPI + React/TypeScript + SQLite + GPT-4o Features: Radar géopolitique, Marchés, Régime Macro, Journal de Bord MTM, Rapport IA, Super Contexte (base de raisonnement évolutive), Boucle feedback IA. Deploy: Docker + docker-compose + nginx pour openfin.open-squared.tech Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from routers import market_data, geopolitical, options, backtest, ai, portfolio, config, patterns, journal, cycle as cycle_router, profiles as profiles_router, reasoning as reasoning_router, knowledge as knowledge_router
|
|
from services.database import init_db, get_config
|
|
import os
|
|
import uvicorn
|
|
|
|
app = FastAPI(
|
|
title="GeoOptions Intelligence",
|
|
description="Geopolitical Options Trading Cockpit API",
|
|
version="2.0.0",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:5173", "http://localhost:3000", "http://127.0.0.1:5173"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
|
|
@app.on_event("startup")
|
|
def startup():
|
|
init_db()
|
|
key = get_config("openai_api_key") or ""
|
|
if key:
|
|
os.environ["OPENAI_API_KEY"] = key
|
|
# Seed built-in patterns into DB (idempotent)
|
|
from services.geo_analyzer import GEO_PATTERNS
|
|
from services.database import seed_builtin_patterns
|
|
seed_builtin_patterns(GEO_PATTERNS)
|
|
# Start auto-cycle scheduler if enabled
|
|
from services.auto_cycle import start_scheduler
|
|
start_scheduler()
|
|
|
|
|
|
@app.on_event("shutdown")
|
|
def shutdown():
|
|
from services.auto_cycle import stop_scheduler
|
|
stop_scheduler()
|
|
|
|
|
|
app.include_router(market_data.router)
|
|
app.include_router(geopolitical.router)
|
|
app.include_router(options.router)
|
|
app.include_router(backtest.router)
|
|
app.include_router(ai.router)
|
|
app.include_router(portfolio.router)
|
|
app.include_router(config.router)
|
|
app.include_router(patterns.router)
|
|
app.include_router(journal.router)
|
|
app.include_router(cycle_router.router)
|
|
app.include_router(profiles_router.router)
|
|
app.include_router(reasoning_router.router)
|
|
app.include_router(knowledge_router.router)
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"app": "GeoOptions Intelligence Cockpit", "version": "2.0.0", "docs": "/docs"}
|
|
|
|
|
|
@app.get("/api/health")
|
|
def health():
|
|
return {"status": "ok", "version": "2.0.0"}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|