1
This commit is contained in:
parent
bbe27d8d1f
commit
f303e19a46
@ -4,6 +4,7 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
|
import numpy as np
|
||||||
from app.utils.logger import logger
|
from app.utils.logger import logger
|
||||||
from app.utils.system_status import get_system_monitor
|
from app.utils.system_status import get_system_monitor
|
||||||
from app.crypto_agent.crypto_agent import get_crypto_agent
|
from app.crypto_agent.crypto_agent import get_crypto_agent
|
||||||
@ -15,6 +16,28 @@ from app.services.hyperliquid_trading_service import get_hyperliquid_service
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
def _sanitize_for_response(value: Any) -> Any:
|
||||||
|
if isinstance(value, dict):
|
||||||
|
return {str(key): _sanitize_for_response(item) for key, item in value.items()}
|
||||||
|
if isinstance(value, list):
|
||||||
|
return [_sanitize_for_response(item) for item in value]
|
||||||
|
if isinstance(value, tuple):
|
||||||
|
return [_sanitize_for_response(item) for item in value]
|
||||||
|
if isinstance(value, set):
|
||||||
|
return [_sanitize_for_response(item) for item in value]
|
||||||
|
if isinstance(value, np.bool_):
|
||||||
|
return bool(value)
|
||||||
|
if isinstance(value, np.integer):
|
||||||
|
return int(value)
|
||||||
|
if isinstance(value, np.floating):
|
||||||
|
return float(value)
|
||||||
|
if isinstance(value, np.ndarray):
|
||||||
|
return [_sanitize_for_response(item) for item in value.tolist()]
|
||||||
|
if isinstance(value, np.generic):
|
||||||
|
return value.item()
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def _parse_signal_timestamp(value: Any) -> datetime | None:
|
def _parse_signal_timestamp(value: Any) -> datetime | None:
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
@ -455,7 +478,7 @@ async def get_console_snapshot():
|
|||||||
execution_events,
|
execution_events,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
payload = {
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"data": {
|
"data": {
|
||||||
"generated_at": now.isoformat(),
|
"generated_at": now.isoformat(),
|
||||||
@ -475,6 +498,7 @@ async def get_console_snapshot():
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return _sanitize_for_response(payload)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"获取总控台快照失败: {e}")
|
logger.error(f"获取总控台快照失败: {e}")
|
||||||
raise HTTPException(status_code=500, detail=f"获取总控台快照失败: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"获取总控台快照失败: {str(e)}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user