first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from apps.api.auth import require_auth
|
||||
from packages.config import get_settings
|
||||
from packages.db import Repository
|
||||
from packages.domain import LEVERAGE_FORMULA_VERSION
|
||||
|
||||
router = APIRouter(tags=["meta"], dependencies=[Depends(require_auth)])
|
||||
|
||||
|
||||
@router.get("/meta/latest")
|
||||
def latest() -> dict:
|
||||
s = get_settings()
|
||||
repo = Repository(s.db_path)
|
||||
try:
|
||||
hb = repo.get_heartbeat()
|
||||
by_side = repo.latest_quotes_by_side()
|
||||
return {
|
||||
"formula_version": LEVERAGE_FORMULA_VERSION,
|
||||
"leverage_def": "index_px / ask",
|
||||
"timezone": s.tz,
|
||||
"underlying": s.underlying,
|
||||
"min_option_leverage": s.min_option_leverage,
|
||||
"heartbeat": {
|
||||
"last_ok_ts_ms": hb.get("last_ok_ts_ms"),
|
||||
"last_error": hb.get("last_error"),
|
||||
"consecutive_failures": hb.get("consecutive_failures"),
|
||||
"meta": hb.get("meta"),
|
||||
},
|
||||
"call": by_side.get("C"),
|
||||
"put": by_side.get("P"),
|
||||
}
|
||||
finally:
|
||||
repo.close()
|
||||
Reference in New Issue
Block a user