1、主单增加减仓、加仓状态
2、bug修复
This commit is contained in:
@ -625,6 +625,10 @@ func (e LinePreOrder) CalculateBreakEevenRatio(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.Symbol == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// data := dto.CalculateBreakEvenRatioResp{}
|
||||
_, err = s.GenerateOrder(&req)
|
||||
if err != nil {
|
||||
|
||||
@ -183,7 +183,7 @@ func (s *LinePreOrderDeleteReq) GetId() interface{} {
|
||||
type LineAddPreOrderReq struct {
|
||||
ExchangeType string `json:"exchange_type" vd:"len($)>0"` //交易所类型
|
||||
OrderType int `json:"order_type"` //订单类型
|
||||
Symbol string `json:"symbol" vd:"len($)>0"` //交易对
|
||||
Symbol string `json:"symbol"` //交易对
|
||||
ApiUserId string `json:"api_id" ` //下单用户
|
||||
Site string `json:"site" ` //购买方向
|
||||
BuyPrice string `json:"buy_price" vd:"$>0"` //购买金额 U
|
||||
@ -341,15 +341,15 @@ func (req LineBatchAddPreOrderReq) CheckParams() error {
|
||||
return errors.New("加仓单下跌价格不能为空")
|
||||
}
|
||||
|
||||
if v.ReduceNumRatio.IsZero() || v.ReduceNumRatio.Cmp(decimal.Zero) > 0 {
|
||||
if v.ReduceNumRatio.IsZero() || v.ReduceNumRatio.Cmp(decimal.NewFromInt(100)) > 0 {
|
||||
return errors.New("减仓数量不正确")
|
||||
}
|
||||
|
||||
if v.ReducePriceRatio.IsZero() || v.ReducePriceRatio.Cmp(decimal.Zero) > 0 {
|
||||
if v.ReducePriceRatio.IsZero() || v.ReducePriceRatio.Cmp(decimal.NewFromInt(100)) > 0 {
|
||||
return errors.New("减仓下跌价格不正确")
|
||||
}
|
||||
|
||||
if v.ReduceTakeProfitRatio.IsZero() || v.ReduceTakeProfitRatio.Cmp(decimal.Zero) > 0 {
|
||||
if v.ReduceTakeProfitRatio.IsZero() || v.ReduceTakeProfitRatio.Cmp(decimal.NewFromInt(100)) > 0 {
|
||||
return errors.New("减仓后止盈价格不正确")
|
||||
}
|
||||
}
|
||||
@ -371,8 +371,8 @@ type LeverReq struct {
|
||||
Symbol string `json:"symbol"`
|
||||
Leverage int `json:"leverage"`
|
||||
GroupId int `json:"group_id"`
|
||||
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
||||
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
||||
ExchangeType string `json:"exchangeType"` //交易所类型 字典exchange_type
|
||||
}
|
||||
|
||||
func (c LeverReq) CheckParams() error {
|
||||
@ -387,11 +387,11 @@ func (c LeverReq) CheckParams() error {
|
||||
|
||||
type MarginTypeReq struct {
|
||||
ApiUserIds string `json:"api_user_ids"`
|
||||
Symbol string `json:"symbol"` // 交易对
|
||||
MarginType string `json:"margin_type"` //全仓 CROSSED 逐仓 ISOLATED
|
||||
GroupId int `json:"group_id"` // 交易对组id
|
||||
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
||||
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||
Symbol string `json:"symbol"` // 交易对
|
||||
MarginType string `json:"margin_type"` //全仓 CROSSED 逐仓 ISOLATED
|
||||
GroupId int `json:"group_id"` // 交易对组id
|
||||
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
||||
ExchangeType string `json:"exchangeType"` //交易所类型 字典exchange_type
|
||||
}
|
||||
|
||||
type CancelOpenOrderReq struct {
|
||||
@ -399,7 +399,7 @@ type CancelOpenOrderReq struct {
|
||||
Symbol string `json:"symbol"`
|
||||
OrderSn string `json:"order_sn"`
|
||||
OrderType int `json:"order_type"`
|
||||
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||
ExchangeType string `json:"exchangeType"` //交易所类型 字典exchange_type
|
||||
}
|
||||
|
||||
type GetChildOrderReq struct {
|
||||
|
||||
@ -323,7 +323,7 @@ func (e *LinePreOrder) AddPreOrder(req *dto.LineAddPreOrderReq, p *actions.DataP
|
||||
|
||||
//获取交易对
|
||||
tradeSet, _ := helper.GetObjString[models2.TradeSet](helper.DefaultRedis, key)
|
||||
orderCount := e.CheckRepeatOrder(req.OrderType, id, req.Site, tradeSet.Coin)
|
||||
orderCount := e.CheckRepeatOrder(req.SymbolType, id, req.Site, tradeSet.Coin)
|
||||
if orderCount > 0 {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%s 获取交易对:%s 该交易对已存在,请勿重复下单", id, req.Symbol))
|
||||
continue
|
||||
@ -571,6 +571,7 @@ func (e *LinePreOrder) AddPreOrder(req *dto.LineAddPreOrderReq, p *actions.DataP
|
||||
stopOrder.MainId = AddOrder.Id
|
||||
stopOrder.OrderType = 4
|
||||
stopOrder.Status = 0
|
||||
stopOrder.BuyPrice = "0"
|
||||
stopOrder.Rate = req.ReducePriceRatio.String()
|
||||
stopNum := utility.StrToDecimal(AddOrder.Num).Mul(req.ReduceNumRatio.Div(decimal.NewFromInt(100)).Truncate(4))
|
||||
stopOrder.Num = stopNum.Truncate(int32(tradeSet.AmountDigit)).String()
|
||||
@ -807,9 +808,9 @@ func makeReduceTakeAndStoploss(parentOrder *models.LinePreOrder, ext models.Line
|
||||
}
|
||||
|
||||
// CheckRepeatOrder 检查重复下单 检查基础货币
|
||||
func (e *LinePreOrder) CheckRepeatOrder(orderType int, apiUserId, site, baseCoin string) int64 {
|
||||
func (e *LinePreOrder) CheckRepeatOrder(symbolType int, apiUserId, site, baseCoin string) int64 {
|
||||
var count int64
|
||||
e.Orm.Model(&models.LinePreOrder{}).Where("api_id = ? AND pid=0 AND symbol like ? AND order_type = ? AND site = ? AND `status` IN (1,5,6)", apiUserId, baseCoin+"%", orderType, site).Count(&count)
|
||||
e.Orm.Model(&models.LinePreOrder{}).Where("api_id = ? AND pid=0 AND symbol like ? AND symbol_type = ? AND site = ? AND `status` IN (1,5,6)", apiUserId, baseCoin+"%", symbolType, site).Count(&count)
|
||||
return count
|
||||
}
|
||||
|
||||
@ -897,6 +898,7 @@ func (e *LinePreOrder) AddBatchPreOrder(batchReq *dto.LineBatchAddPreOrderReq, p
|
||||
req.Price = batchReq.Price
|
||||
req.Profit = batchReq.Profit
|
||||
req.Ext = batchReq.Ext
|
||||
req.SymbolType = batchReq.SymbolType
|
||||
// req.StopPrice = batchReq.StopPrice
|
||||
req.ReducePriceRatio = batchReq.ReducePriceRatio
|
||||
req.PriceType = batchReq.PriceType
|
||||
@ -1176,6 +1178,8 @@ func (e *LinePreOrder) ClearAll() error {
|
||||
"stop_loss_markt",
|
||||
"_PreSpotOrderList_",
|
||||
"_PreFutOrderList_",
|
||||
"spot_reduce_list",
|
||||
"futures_reduce_list",
|
||||
}
|
||||
err = helper.DefaultRedis.DeleteKeysByPrefix(prefixs...)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user