fix(grid): improve GridRiskPanel layout and fix liquidation data

- Make panel collapsible with summary badges when collapsed
- Use compact 2-column grid layout for detailed info
- Fix auth token key (token -> auth_token)
- Only calculate liquidation distance when position exists
This commit is contained in:
tinkle-community
2026-01-18 18:19:15 +08:00
parent e198498f3a
commit e5f69bfea6
2 changed files with 229 additions and 266 deletions

View File

@@ -1443,11 +1443,11 @@ func (at *AutoTrader) GetGridRiskInfo() *GridRiskInfo {
recommendedLeverage = min(leverage, 2)
}
// Calculate liquidation distance
liquidationDistance := 100.0 / float64(leverage) * 0.9 // ~90% of theoretical max
// Calculate liquidation distance and price only when there's a position
var liquidationDistance float64
var liquidationPrice float64
if currentPositionSize != 0 && currentPrice > 0 {
liquidationDistance = 100.0 / float64(leverage) * 0.9 // ~90% of theoretical max
if currentPositionSize > 0 {
// Long position: liquidation below entry
liquidationPrice = currentPrice * (1 - liquidationDistance/100)