1
This commit is contained in:
@ -26,6 +26,7 @@ import (
|
|||||||
|
|
||||||
"go-admin/app/admin/models"
|
"go-admin/app/admin/models"
|
||||||
"go-admin/app/admin/service/dto"
|
"go-admin/app/admin/service/dto"
|
||||||
|
"go-admin/app/admin/service/messages"
|
||||||
"go-admin/common/actions"
|
"go-admin/common/actions"
|
||||||
cDto "go-admin/common/dto"
|
cDto "go-admin/common/dto"
|
||||||
)
|
)
|
||||||
@ -1378,13 +1379,10 @@ func (e *LinePreOrder) SetBinanceMarginType(req *dto.MarginTypeReq, users []mode
|
|||||||
"marginType": req.MarginType,
|
"marginType": req.MarginType,
|
||||||
"symbol": s,
|
"symbol": s,
|
||||||
}
|
}
|
||||||
resp, _, err := client.SendFuturesRequestAuth("/fapi/v1/marginType", "POST", params)
|
_, _, err := client.SendFuturesRequestAuth("/fapi/v1/marginType", "POST", params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var dataMap map[string]interface{}
|
var dataMap map[string]interface{}
|
||||||
if err := sonic.Unmarshal(resp, &dataMap); err != nil {
|
if err := sonic.Unmarshal([]byte(err.Error()), &dataMap); err != nil {
|
||||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -1393,8 +1391,25 @@ func (e *LinePreOrder) SetBinanceMarginType(req *dto.MarginTypeReq, users []mode
|
|||||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
|
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if code.(float64) != 200 {
|
if code.(float64) != 200 {
|
||||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
|
var msg string
|
||||||
|
codeInt := utility.ToInt(code)
|
||||||
|
|
||||||
|
if codeInt == -4046 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if val, ok := messages.BinanceFutureMessage[codeInt]; ok {
|
||||||
|
msg = val
|
||||||
|
} else {
|
||||||
|
msg = dataMap["message"].(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, msg))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// *errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
app/admin/service/messages/binance_message.go
Normal file
7
app/admin/service/messages/binance_message.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package messages
|
||||||
|
|
||||||
|
var BinanceFutureMessage = map[int]string{
|
||||||
|
-4168: "多资产模式下无法使用逐仓",
|
||||||
|
-4167: "因有交易对在逐仓模式,无法切换多资产模式",
|
||||||
|
-4046: "不需要切换仓位模式。",
|
||||||
|
}
|
||||||
@ -45,7 +45,7 @@ func GetSpotSymbols() (map[string]models.TradeSet, []string, error) {
|
|||||||
tradeSet.MaxQty = utility.StringAsFloat(filter.MaxQty)
|
tradeSet.MaxQty = utility.StringAsFloat(filter.MaxQty)
|
||||||
case "MARKET_LOT_SIZE":
|
case "MARKET_LOT_SIZE":
|
||||||
tradeSet.MarketMinQty = utility.StringAsFloat(filter.MinQty)
|
tradeSet.MarketMinQty = utility.StringAsFloat(filter.MinQty)
|
||||||
tradeSet.MarketMinQty = utility.StringAsFloat(filter.MaxQty)
|
tradeSet.MarketMaxQty = utility.StringAsFloat(filter.MaxQty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user