1、累计亏损
This commit is contained in:
@ -422,8 +422,8 @@ func savePosition(db *gorm.DB, preOrder *DbModels.LinePreOrder) positiondto.Posi
|
||||
SymbolType: preOrder.SymbolType,
|
||||
Symbol: preOrder.Symbol,
|
||||
Price: utility.StrToDecimal(preOrder.Price),
|
||||
Side: preOrder.Site,
|
||||
Quantity: utility.StrToDecimal(preOrder.Num),
|
||||
// Side: preOrder.Site,
|
||||
Quantity: utility.StrToDecimal(preOrder.Num),
|
||||
}
|
||||
|
||||
switch {
|
||||
@ -436,8 +436,16 @@ func savePosition(db *gorm.DB, preOrder *DbModels.LinePreOrder) positiondto.Posi
|
||||
}
|
||||
|
||||
//减仓单 数量为负
|
||||
if preOrder.OrderType == 4 {
|
||||
if preOrder.OrderType != 0 {
|
||||
if preOrder.Site == "BUY" {
|
||||
positionReq.Side = "SELL"
|
||||
} else {
|
||||
positionReq.Side = "BUY"
|
||||
}
|
||||
|
||||
positionReq.Quantity = positionReq.Quantity.Mul(decimal.NewFromInt(-1))
|
||||
} else {
|
||||
positionReq.Side = preOrder.Site
|
||||
}
|
||||
|
||||
positionData, err := positionManage.SavePosition(&positionReq, global.EXCHANGE_BINANCE)
|
||||
@ -453,9 +461,9 @@ func getOpenPositionMainOrderId(db *gorm.DB, newId, apiId, symbolType int, excha
|
||||
mainOrders := make([]DbModels.LinePreOrder, 0)
|
||||
|
||||
if err := db.Model(&DbModels.LinePreOrder{}).
|
||||
Where("api_id =? AND status>4 AND status<7 AND symbol=? AND symbol_type =? AND side= ? AND exchange_type=? AND id!=?",
|
||||
Where("api_id =? AND status>4 AND status<7 AND symbol=? AND symbol_type =? AND site= ? AND exchange_type=? AND id!=?",
|
||||
apiId, symbol, symbolType, side, exchangeType, newId).
|
||||
Select("id", "order_sn").Find(&mainOrders).Error; err != nil {
|
||||
Select("id", "main_id", "order_sn").Find(&mainOrders).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user