This commit is contained in:
薇薇安 2026-01-23 20:03:07 +08:00
parent 7a64ff44c2
commit 7adf5c7126

View File

@ -45,6 +45,7 @@ async def get_performance_stats(
@router.get("/dashboard") @router.get("/dashboard")
async def get_dashboard_data(account_id: int = Depends(get_account_id)): async def get_dashboard_data(account_id: int = Depends(get_account_id)):
"""获取仪表板数据""" """获取仪表板数据"""
logger.info(f"获取仪表板数据 (account_id={account_id})")
try: try:
account_data = None account_data = None
account_error = None account_error = None
@ -180,7 +181,7 @@ async def get_dashboard_data(account_id: int = Depends(get_account_id)):
try: try:
from database.models import TradingConfig from database.models import TradingConfig
total_balance = float(account_data.get('total_balance', 0)) total_balance = float(account_data.get('total_balance', 0))
max_total_position_percent = float(TradingConfig.get_value('MAX_TOTAL_POSITION_PERCENT', 0.30)) max_total_position_percent = float(TradingConfig.get_value('MAX_TOTAL_POSITION_PERCENT', 0.30, account_id=account_id))
# 名义仓位notional与保证金占用margin是两个口径 # 名义仓位notional与保证金占用margin是两个口径
# - 名义仓位可以 > 100%(高杠杆下非常正常) # - 名义仓位可以 > 100%(高杠杆下非常正常)
@ -241,7 +242,7 @@ async def get_dashboard_data(account_id: int = Depends(get_account_id)):
from database.models import TradingConfig from database.models import TradingConfig
config_keys = ['STOP_LOSS_PERCENT', 'TAKE_PROFIT_PERCENT', 'LEVERAGE', 'MAX_POSITION_PERCENT'] config_keys = ['STOP_LOSS_PERCENT', 'TAKE_PROFIT_PERCENT', 'LEVERAGE', 'MAX_POSITION_PERCENT']
for key in config_keys: for key in config_keys:
config = TradingConfig.get(key) config = TradingConfig.get(key, account_id=account_id)
if config: if config:
trading_config[key] = { trading_config[key] = {
'value': TradingConfig._convert_value(config['config_value'], config['config_type']), 'value': TradingConfig._convert_value(config['config_value'], config['config_type']),