Add READ_ONLY_API environment variable and enhance trading error handling

This commit is contained in:
coddard
2026-05-19 02:41:00 +03:00
parent 32537ef6e2
commit 22ac0da394
5 changed files with 114 additions and 2 deletions
+4
View File
@@ -1,3 +1,5 @@
import os
from fastapi import APIRouter
from fastapi.responses import JSONResponse
@@ -10,6 +12,7 @@ router = APIRouter()
async def health():
ib_connected = False
account = None
trading_mode = os.getenv("TRADING_MODE", "unknown").split("#", 1)[0].strip() or "unknown"
try:
ib_inst = dependencies.get_ib()
ib_connected = ib_inst.isConnected()
@@ -30,6 +33,7 @@ async def health():
{
"status": "ok" if (ib_connected and db_ok) else "degraded",
"ib_connected": ib_connected,
"trading_mode": trading_mode,
"account": account,
"db_ok": db_ok,
"version": "3.0",