mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-18 18:04:32 +08:00
fix: leverage validation bug and limit grid leverage to 1-5
- Fix Go range loop copy issue in validateDecisions (leverage auto-adjust was modifying copy, not original) - Limit grid leverage from 1-20 to 1-5 for safer grid trading
This commit is contained in:
@@ -1767,8 +1767,8 @@ func compactArrayOpen(s string) string {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
func validateDecisions(decisions []Decision, accountEquity float64, btcEthLeverage, altcoinLeverage int, btcEthPosRatio, altcoinPosRatio float64) error {
|
func validateDecisions(decisions []Decision, accountEquity float64, btcEthLeverage, altcoinLeverage int, btcEthPosRatio, altcoinPosRatio float64) error {
|
||||||
for i, decision := range decisions {
|
for i := range decisions {
|
||||||
if err := validateDecision(&decision, accountEquity, btcEthLeverage, altcoinLeverage, btcEthPosRatio, altcoinPosRatio); err != nil {
|
if err := validateDecision(&decisions[i], accountEquity, btcEthLeverage, altcoinLeverage, btcEthPosRatio, altcoinPosRatio); err != nil {
|
||||||
return fmt.Errorf("decision #%d validation failed: %w", i+1, err)
|
return fmt.Errorf("decision #%d validation failed: %w", i+1, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function GridConfigEditor({
|
|||||||
totalInvestment: { zh: '投资金额 (USDT)', en: 'Investment (USDT)' },
|
totalInvestment: { zh: '投资金额 (USDT)', en: 'Investment (USDT)' },
|
||||||
totalInvestmentDesc: { zh: '网格策略的总投资金额', en: 'Total investment for grid strategy' },
|
totalInvestmentDesc: { zh: '网格策略的总投资金额', en: 'Total investment for grid strategy' },
|
||||||
leverage: { zh: '杠杆倍数', en: 'Leverage' },
|
leverage: { zh: '杠杆倍数', en: 'Leverage' },
|
||||||
leverageDesc: { zh: '交易使用的杠杆倍数 (1-20)', en: 'Leverage for trading (1-20)' },
|
leverageDesc: { zh: '交易使用的杠杆倍数 (1-5)', en: 'Leverage for trading (1-5)' },
|
||||||
|
|
||||||
// Grid parameters
|
// Grid parameters
|
||||||
gridCount: { zh: '网格数量', en: 'Grid Count' },
|
gridCount: { zh: '网格数量', en: 'Grid Count' },
|
||||||
@@ -171,7 +171,7 @@ export function GridConfigEditor({
|
|||||||
onChange={(e) => updateField('leverage', parseInt(e.target.value) || 5)}
|
onChange={(e) => updateField('leverage', parseInt(e.target.value) || 5)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
min={1}
|
min={1}
|
||||||
max={20}
|
max={5}
|
||||||
className="w-full px-3 py-2 rounded"
|
className="w-full px-3 py-2 rounded"
|
||||||
style={inputStyle}
|
style={inputStyle}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user