1
This commit is contained in:
parent
8b45c81906
commit
43e44a976b
21
check_db_values.py
Normal file
21
check_db_values.py
Normal 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}")
|
||||||
|
|
@ -66,9 +66,9 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
if (isPctLike) {
|
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
|
return val === null || val === undefined ? '' : val
|
||||||
}
|
}
|
||||||
|
|
@ -105,11 +105,13 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
||||||
setIsEditing(false)
|
setIsEditing(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (numVal < 0 || numVal > 1) {
|
|
||||||
setLocalValue(getInitialDisplayValue(config.value))
|
if (numVal < 0) {
|
||||||
setIsEditing(false)
|
setLocalValue(getInitialDisplayValue(config.value))
|
||||||
return
|
setIsEditing(false)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
finalValue = numVal
|
finalValue = numVal
|
||||||
} else {
|
} else {
|
||||||
finalValue = parseFloat(localValue)
|
finalValue = parseFloat(localValue)
|
||||||
|
|
@ -159,7 +161,8 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
||||||
if (config.type === 'number' && !isNumberAsIs) {
|
if (config.type === 'number' && !isNumberAsIs) {
|
||||||
if (isPercentKey) {
|
if (isPercentKey) {
|
||||||
const numValue = parseFloat(newValue)
|
const numValue = parseFloat(newValue)
|
||||||
if (newValue !== '' && !isNaN(numValue) && (numValue < 0 || numValue > 1)) {
|
// 移除 > 1 的限制,允许输入百分比数值(如 30)
|
||||||
|
if (newValue !== '' && !isNaN(numValue) && numValue < 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +179,6 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
||||||
style={{ width: '100%', padding: '8px', border: '1px solid #ddd', borderRadius: '4px' }}
|
style={{ width: '100%', padding: '8px', border: '1px solid #ddd', borderRadius: '4px' }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* ⚠️ 简化:去掉%符号,直接显示小数(0.30) */}
|
|
||||||
</div>
|
</div>
|
||||||
{config.description && (
|
{config.description && (
|
||||||
<div style={{ fontSize: '12px', color: '#666', marginTop: '4px' }}>{config.description}</div>
|
<div style={{ fontSize: '12px', color: '#666', marginTop: '4px' }}>{config.description}</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user