This commit is contained in:
薇薇安 2026-02-13 23:29:33 +08:00
parent 213e31142c
commit f8058083e3
4 changed files with 23 additions and 20 deletions

View File

@ -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()

View File

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

View File

@ -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

View File

@ -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