调整普通用户配置项,去掉没用的

This commit is contained in:
薇薇安 2026-02-12 14:13:27 +08:00
parent 68f028f0fc
commit 42eab75e3e
2 changed files with 48 additions and 7 deletions

View File

@ -800,6 +800,10 @@ async def check_config_feasibility(
except Exception:
suggestions = []
max_open_positions = int(_tc("MAX_OPEN_POSITIONS", 3))
max_daily_entries = int(_tc("MAX_DAILY_ENTRIES", 8))
max_single_position_margin_usdt = round(available_balance * max_position_percent, 2)
return {
"feasible": is_feasible,
"account_balance": available_balance,
@ -809,7 +813,10 @@ async def check_config_feasibility(
"current_config": {
"min_margin_usdt": min_margin_usdt,
"min_position_percent": min_position_percent,
"max_position_percent": max_position_percent
"max_position_percent": max_position_percent,
"max_open_positions": max_open_positions,
"max_daily_entries": max_daily_entries,
"max_single_position_margin_usdt": max_single_position_margin_usdt,
},
"calculated_values": {
"required_position_value": base_result['required_position_value'],

View File

@ -42,6 +42,19 @@ const ConfigPanel = () => {
}
}
// USER_RISK_KNOBS
const USER_RISK_KNOBS_SET = new Set([
'MIN_MARGIN_USDT', 'MIN_POSITION_PERCENT', 'MAX_POSITION_PERCENT', 'MAX_TOTAL_POSITION_PERCENT',
'AUTO_TRADE_ENABLED', 'MAX_OPEN_POSITIONS', 'MAX_DAILY_ENTRIES',
'TOP_N_SYMBOLS', 'MIN_SIGNAL_STRENGTH', 'MIN_VOLUME_24H', 'MIN_VOLATILITY',
'SCAN_EXTRA_SYMBOLS_FOR_SUPPLEMENT', 'EXCLUDE_MAJOR_COINS', 'MAX_SCAN_SYMBOLS', 'SCAN_INTERVAL',
])
const USER_EDITABLE_KEYS = new Set([
...USER_RISK_KNOBS_SET,
'BINANCE_API_KEY', 'BINANCE_API_SECRET', 'USE_TESTNET',
])
const isKeyEditableForUser = (key) => USER_EDITABLE_KEYS.has(key)
const [credForm, setCredForm] = useState({ api_key: '', api_secret: '', use_testnet: false })
//
@ -521,8 +534,8 @@ const ConfigPanel = () => {
}
//
await loadConfigs()
//
if (['MIN_MARGIN_USDT', 'MIN_POSITION_PERCENT', 'MAX_POSITION_PERCENT', 'LEVERAGE'].includes(key)) {
// /
if (['MIN_MARGIN_USDT', 'MIN_POSITION_PERCENT', 'MAX_POSITION_PERCENT', 'MAX_OPEN_POSITIONS', 'MAX_DAILY_ENTRIES', 'LEVERAGE'].includes(key)) {
await checkFeasibility()
}
} catch (error) {
@ -811,6 +824,17 @@ const ConfigPanel = () => {
'api': 'API配置'
}
//
const visibleCategories = isAdmin
? configCategories
: Object.fromEntries(
Object.entries(configCategories).filter(([cat]) =>
Object.keys(configs).some(
(key) => configs[key]?.category === cat && isKeyEditableForUser(key)
)
)
)
return (
<div className="config-panel">
<div className="config-header">
@ -1047,6 +1071,15 @@ const ConfigPanel = () => {
)} |
最小保证金: <strong>{feasibilityCheck.current_config?.min_margin_usdt?.toFixed(2) || 'N/A'}</strong> USDT
</p>
<p>
最大单笔保证金: <strong>{feasibilityCheck.current_config?.max_single_position_margin_usdt != null ? feasibilityCheck.current_config.max_single_position_margin_usdt.toFixed(2) : 'N/A'}</strong> USDT
{feasibilityCheck.current_config?.max_open_positions != null && (
<> | 最多持仓: <strong>{feasibilityCheck.current_config.max_open_positions}</strong> </>
)}
{feasibilityCheck.current_config?.max_daily_entries != null && (
<> | 每日最多开仓: <strong>{feasibilityCheck.current_config.max_daily_entries}</strong> </>
)}
</p>
{!feasibilityCheck.feasible && (
<div className="warning-text">
<p>
@ -1148,17 +1181,18 @@ const ConfigPanel = () => {
</div>
)}
{/* 配置项禁用account时不显示 */}
{/* 配置项禁用account时不显示;普通用户只显示可编辑的风险旋钮与 API 配置 */}
{currentAccountMeta && currentAccountMeta.status === 'active' ? (
Object.entries(configCategories).map(([category, label]) => (
Object.entries(visibleCategories).map(([category, label]) => (
<section key={category} className="config-section">
<h3>{label}</h3>
<div className="config-grid">
{Object.entries(configs)
.filter(([key, config]) => {
if (config.category !== category) return false
//
if (key === 'BINANCE_API_KEY' || key === 'BINANCE_API_SECRET' || key === 'USE_TESTNET') return false
// api
if (key === 'BINANCE_API_KEY' || key === 'BINANCE_API_SECRET' || key === 'USE_TESTNET') return true
if (!isAdmin && !isKeyEditableForUser(key)) return false
return true
})
.map(([key, config]) => (