This commit is contained in:
薇薇安 2026-02-13 20:25:56 +08:00
parent 8b45c81906
commit 43e44a976b
2 changed files with 31 additions and 8 deletions

21
check_db_values.py Normal file
View File

@ -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}")

View File

@ -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 */}
</div>
{config.description && (
<div style={{ fontSize: '12px', color: '#666', marginTop: '4px' }}>{config.description}</div>