mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 09:11:03 +08:00
fix: consistent safe type helpers in auto_trader, log emergency exit errors
- Replace all raw pos["key"].(type) assertions with posFloat64/posString/posInt64 helpers across auto_trader_decision, auto_trader_grid, auto_trader_grid_orders, auto_trader_grid_regime, auto_trader_loop, auto_trader_orders, auto_trader_risk - Add posInt64 helper for int64 extraction (createdTime etc) - Fix emergencyExit: log CloseLong/CloseShort errors instead of silently dropping - Fix emergencyExit: log GetPositions error on failure - Upgrade closeAllPositions log level from Infof to Warnf for close failures - Zero raw type assertions remaining in auto_trader_* files
This commit is contained in:
@@ -245,9 +245,9 @@ func (at *AutoTrader) GetGridRiskInfo() *GridRiskInfo {
|
||||
var currentPositionValue float64
|
||||
var currentPositionSize float64
|
||||
for _, pos := range positions {
|
||||
if sym, _ := pos["symbol"].(string); sym == gridConfig.Symbol {
|
||||
size, _ := pos["positionAmt"].(float64)
|
||||
entry, _ := pos["entryPrice"].(float64)
|
||||
if posString(pos, "symbol") == gridConfig.Symbol {
|
||||
size := posFloat64(pos, "positionAmt")
|
||||
entry := posFloat64(pos, "entryPrice")
|
||||
currentPositionValue = math.Abs(size * entry)
|
||||
currentPositionSize = size
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user