From 43e44a976b5eaa9b3f2464f07112059d14a9c10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Fri, 13 Feb 2026 20:25:56 +0800 Subject: [PATCH] 1 --- check_db_values.py | 21 +++++++++++++++++++++ frontend/src/components/GlobalConfig.jsx | 18 ++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 check_db_values.py diff --git a/check_db_values.py b/check_db_values.py new file mode 100644 index 0000000..6e9cc05 --- /dev/null +++ b/check_db_values.py @@ -0,0 +1,21 @@ + +import sys +import os +from pathlib import Path + +# Add backend to sys.path +backend_dir = Path(__file__).parent / 'backend' +sys.path.insert(0, str(backend_dir)) + +try: + from database.models import GlobalStrategyConfig + from database.connection import db + + keys = ["TAKE_PROFIT_1_PERCENT", "STOP_LOSS_PERCENT", "TAKE_PROFIT_PERCENT"] + for k in keys: + val = GlobalStrategyConfig.get_value(k) + raw = GlobalStrategyConfig.get(k) + print(f"{k}: get_value={val}, raw_db={raw.get('config_value') if raw else 'None'}") + +except Exception as e: + print(f"Error: {e}") diff --git a/frontend/src/components/GlobalConfig.jsx b/frontend/src/components/GlobalConfig.jsx index e645543..e740951 100644 --- a/frontend/src/components/GlobalConfig.jsx +++ b/frontend/src/components/GlobalConfig.jsx @@ -66,9 +66,9 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => { return '' } if (isPctLike) { - return formatPercent(numVal <= 0.05 ? numVal * 100 : numVal) + return formatPercent(numVal) } - return formatPercent(numVal <= 1 ? numVal : numVal / 100) + return formatPercent(numVal) } return val === null || val === undefined ? '' : val } @@ -105,11 +105,13 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => { setIsEditing(false) return } - if (numVal < 0 || numVal > 1) { - setLocalValue(getInitialDisplayValue(config.value)) - setIsEditing(false) - return + + if (numVal < 0) { + setLocalValue(getInitialDisplayValue(config.value)) + setIsEditing(false) + return } + finalValue = numVal } else { finalValue = parseFloat(localValue) @@ -159,7 +161,8 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => { if (config.type === 'number' && !isNumberAsIs) { if (isPercentKey) { const numValue = parseFloat(newValue) - if (newValue !== '' && !isNaN(numValue) && (numValue < 0 || numValue > 1)) { + // 移除 > 1 的限制,允许输入百分比数值(如 30) + if (newValue !== '' && !isNaN(numValue) && numValue < 0) { return } } @@ -176,7 +179,6 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => { style={{ width: '100%', padding: '8px', border: '1px solid #ddd', borderRadius: '4px' }} /> )} - {/* ⚠️ 简化:去掉%符号,直接显示小数(0.30) */} {config.description && (
{config.description}