1
This commit is contained in:
parent
213e31142c
commit
f8058083e3
|
|
@ -101,7 +101,7 @@ class GlobalStrategyConfigManager:
|
|||
self._cache = {}
|
||||
self._redis_client: Optional[redis.Redis] = None
|
||||
self._redis_connected = False
|
||||
self._redis_hash_key = "global_strategy_config_v2" # 独立的Redis键 (v2: 强制刷新缓存)
|
||||
self._redis_hash_key = "global_strategy_config_v3" # 独立的Redis键 (v3: 强制刷新缓存 - 2025-02-13)
|
||||
self._init_redis()
|
||||
self._load_from_db()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,18 @@ from pathlib import 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}")
|
||||
from database.models import GlobalStrategyConfig, TradingConfig
|
||||
from database.connection import db
|
||||
|
||||
print("Checking DB values...")
|
||||
keys = ['TAKE_PROFIT_PERCENT', 'TAKE_PROFIT_1_PERCENT', 'STOP_LOSS_PERCENT']
|
||||
|
||||
print("--- GlobalStrategyConfig ---")
|
||||
for key in keys:
|
||||
val = GlobalStrategyConfig.get_value(key)
|
||||
print(f"{key}: {val} (Type: {type(val)})")
|
||||
|
||||
print("\n--- TradingConfig (All Accounts) ---")
|
||||
rows = db.execute_query("SELECT account_id, config_key, config_value FROM trading_config WHERE config_key IN ('TAKE_PROFIT_PERCENT', 'TAKE_PROFIT_1_PERCENT', 'STOP_LOSS_PERCENT') ORDER BY account_id")
|
||||
for row in rows:
|
||||
print(f"Account {row['account_id']} - {row['config_key']}: {row['config_value']}")
|
||||
|
|
|
|||
|
|
@ -791,7 +791,7 @@ const ConfigPanel = () => {
|
|||
key,
|
||||
value:
|
||||
(key.includes('PERCENT') || key.includes('PCT')) && !PCT_LIKE_KEYS.has(key)
|
||||
? value / 100
|
||||
? value
|
||||
: value,
|
||||
type,
|
||||
category,
|
||||
|
|
@ -802,7 +802,7 @@ const ConfigPanel = () => {
|
|||
key,
|
||||
value:
|
||||
(key.includes('PERCENT') || key.includes('PCT')) && !PCT_LIKE_KEYS.has(key)
|
||||
? value / 100
|
||||
? value
|
||||
: value,
|
||||
type: config.type,
|
||||
category: config.category,
|
||||
|
|
@ -1267,7 +1267,7 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
|||
return formatPercent(numVal <= 0.05 ? numVal * 100 : numVal)
|
||||
}
|
||||
// 常规比例型:直接显示数据库中的值(0.30),如果>1则可能是旧数据
|
||||
return formatPercent(numVal <= 1 ? numVal : numVal / 100)
|
||||
return formatPercent(numVal)
|
||||
}
|
||||
return val === null || val === undefined ? '' : val
|
||||
}
|
||||
|
|
@ -1311,7 +1311,7 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
|||
} else if (localValue === '.' || localValue === '-.') {
|
||||
// "." 或 "-." 视为无效,恢复原值
|
||||
const restoreValue = isPercentKey
|
||||
? (typeof value === 'number' ? formatPercent(value <= 1 ? value : value / 100) : value)
|
||||
? (typeof value === 'number' ? formatPercent(value) : value)
|
||||
: value
|
||||
setLocalValue(restoreValue)
|
||||
return
|
||||
|
|
@ -1325,7 +1325,7 @@ const ConfigItem = ({ label, config, onUpdate, disabled }) => {
|
|||
if (isNaN(numValue)) {
|
||||
// 如果输入无效,恢复原值
|
||||
const restoreValue = isPercentKey
|
||||
? (typeof value === 'number' ? formatPercent(value <= 1 ? value : value / 100) : value)
|
||||
? (typeof value === 'number' ? formatPercent(value) : value)
|
||||
: value
|
||||
setLocalValue(restoreValue)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -638,7 +638,7 @@ const GlobalConfig = () => {
|
|||
|
||||
return {
|
||||
key,
|
||||
value: (key.includes('PERCENT') || key.includes('PCT')) && !PCT_LIKE_KEYS.has(key) ? value / 100 : value,
|
||||
value,
|
||||
type,
|
||||
category,
|
||||
description: `预设方案配置项:${key}`
|
||||
|
|
@ -646,7 +646,7 @@ const GlobalConfig = () => {
|
|||
}
|
||||
return {
|
||||
key,
|
||||
value: (key.includes('PERCENT') || key.includes('PCT')) && !PCT_LIKE_KEYS.has(key) ? value / 100 : value,
|
||||
value,
|
||||
type: config.type,
|
||||
category: config.category,
|
||||
description: config.description
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user