INNER CODE UNIT · Python
lifespan
GuntharDeNiro/gunbot-quant · gunbot_quant/api/main.py:23
async def lifespan(app: FastAPI):
"""Manages application startup and shutdown events."""
# Code here runs on startup
print("Gunbot Quant API starting up...")
yield
# Code here runs on shutdown
print("Gunbot Quant API shutting down...")
gunbot_client.close_gunbot_api()
app = FastAPI(
title="Gunbot Quant API",
description="API for running cryptocurrency trading strategy backtests and market screening.",
version="1.0.0",
lifespan=lifespan # Register the lifespan manager
)
# Shared state for background jobs
app.state.job_results = {}