code
This commit is contained in:
@ -464,7 +464,9 @@ func (e LinePreOrder) CancelOpenOrder(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
errs := make([]error, 0)
|
errs := make([]error, 0)
|
||||||
errStr := make([]string, 0)
|
errStr := make([]string, 0)
|
||||||
s.CancelOpenOrder(&req, &errs)
|
if req.ExchangeType == global.EXCHANGE_BINANCE {
|
||||||
|
s.CancelOpenOrder(&req, &errs)
|
||||||
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
for _, err2 := range errs {
|
for _, err2 := range errs {
|
||||||
errStr = append(errStr, err2.Error())
|
errStr = append(errStr, err2.Error())
|
||||||
@ -520,10 +522,13 @@ func (e LinePreOrder) ClosePosition(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
errs := make([]error, 0)
|
errs := make([]error, 0)
|
||||||
errStr := make([]string, 0)
|
errStr := make([]string, 0)
|
||||||
if req.CloseType == 1 {
|
|
||||||
s.SpotClosePosition(&req, &errs)
|
if req.ExchangeType == global.EXCHANGE_BINANCE {
|
||||||
} else {
|
if req.CloseType == 1 {
|
||||||
s.FutClosePosition(&req, &errs)
|
s.SpotClosePosition(&req, &errs)
|
||||||
|
} else {
|
||||||
|
s.FutClosePosition(&req, &errs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
for _, err2 := range errs {
|
for _, err2 := range errs {
|
||||||
|
|||||||
@ -198,7 +198,6 @@ type LineAddPreOrderReq struct {
|
|||||||
CoverType int `json:"cover_type"` //对冲类型 0=无对冲 1= 现货对合约 2=合约对合约 3 合约对现货
|
CoverType int `json:"cover_type"` //对冲类型 0=无对冲 1= 现货对合约 2=合约对合约 3 合约对现货
|
||||||
ExpireHour int `json:"expire_hour"` // 过期时间 单位小时
|
ExpireHour int `json:"expire_hour"` // 过期时间 单位小时
|
||||||
MainOrderType string `json:"main_order_type"` //主单类型:限价(LIMIT)或市价(MARKET)
|
MainOrderType string `json:"main_order_type"` //主单类型:限价(LIMIT)或市价(MARKET)
|
||||||
TakeProfitRatio decimal.Decimal `json:"take_profit"` //主单止盈比例
|
|
||||||
ReducePriceRatio decimal.Decimal `json:"reduce_price"` //主单减仓价格百分比
|
ReducePriceRatio decimal.Decimal `json:"reduce_price"` //主单减仓价格百分比
|
||||||
ReduceNumRatio decimal.Decimal `json:"reduce_num"` //主单减仓数量百分比
|
ReduceNumRatio decimal.Decimal `json:"reduce_num"` //主单减仓数量百分比
|
||||||
ReduceTakeProfitRatio decimal.Decimal `json:"reduce_take_profit"` //主单减仓后止盈价百分比
|
ReduceTakeProfitRatio decimal.Decimal `json:"reduce_take_profit"` //主单减仓后止盈价百分比
|
||||||
@ -255,7 +254,6 @@ type LineBatchAddPreOrderReq struct {
|
|||||||
CoverType int `json:"cover_type"` //对冲类型 1= 现货对合约 2=合约对合约 3 合约对现货
|
CoverType int `json:"cover_type"` //对冲类型 1= 现货对合约 2=合约对合约 3 合约对现货
|
||||||
ExpireHour int `json:"expire_hour"` // 过期时间 单位小时
|
ExpireHour int `json:"expire_hour"` // 过期时间 单位小时
|
||||||
MainOrderType string `json:"main_order_type"` //主单类型:限价(LIMIT)或市价(MARKET)
|
MainOrderType string `json:"main_order_type"` //主单类型:限价(LIMIT)或市价(MARKET)
|
||||||
TakeProfitRatio decimal.Decimal `json:"take_profit"` //主单止盈比例
|
|
||||||
ReducePriceRatio decimal.Decimal `json:"reduce_price"` //主单减仓价格百分比
|
ReducePriceRatio decimal.Decimal `json:"reduce_price"` //主单减仓价格百分比
|
||||||
ReduceNumRatio decimal.Decimal `json:"reduce_num"` //主单减仓数量百分比
|
ReduceNumRatio decimal.Decimal `json:"reduce_num"` //主单减仓数量百分比
|
||||||
ReduceTakeProfitRatio decimal.Decimal `json:"reduce_take_profit"` //主单减仓后止盈价百分比
|
ReduceTakeProfitRatio decimal.Decimal `json:"reduce_take_profit"` //主单减仓后止盈价百分比
|
||||||
@ -300,11 +298,12 @@ type QuickAddPreOrderReq struct {
|
|||||||
|
|
||||||
// LeverReq 设置杠杆请求
|
// LeverReq 设置杠杆请求
|
||||||
type LeverReq struct {
|
type LeverReq struct {
|
||||||
ApiUserIds string `json:"api_user_ids"`
|
ApiUserIds string `json:"api_user_ids"`
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
Leverage int `json:"leverage"`
|
Leverage int `json:"leverage"`
|
||||||
GroupId int `json:"group_id"`
|
GroupId int `json:"group_id"`
|
||||||
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
||||||
|
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c LeverReq) CheckParams() error {
|
func (c LeverReq) CheckParams() error {
|
||||||
@ -318,18 +317,20 @@ func (c LeverReq) CheckParams() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MarginTypeReq struct {
|
type MarginTypeReq struct {
|
||||||
ApiUserIds string `json:"api_user_ids"`
|
ApiUserIds string `json:"api_user_ids"`
|
||||||
Symbol string `json:"symbol"` // 交易对
|
Symbol string `json:"symbol"` // 交易对
|
||||||
MarginType string `json:"margin_type"` //全仓 CROSSED 逐仓 ISOLATED
|
MarginType string `json:"margin_type"` //全仓 CROSSED 逐仓 ISOLATED
|
||||||
GroupId int `json:"group_id"` // 交易对组id
|
GroupId int `json:"group_id"` // 交易对组id
|
||||||
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
IsAll int `json:"is_all"` // 1= 全部 0=不是全部
|
||||||
|
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||||
}
|
}
|
||||||
|
|
||||||
type CancelOpenOrderReq struct {
|
type CancelOpenOrderReq struct {
|
||||||
ApiId int `json:"api_id"`
|
ApiId int `json:"api_id"`
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
OrderSn string `json:"order_sn"`
|
OrderSn string `json:"order_sn"`
|
||||||
OrderType int `json:"order_type"`
|
OrderType int `json:"order_type"`
|
||||||
|
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetChildOrderReq struct {
|
type GetChildOrderReq struct {
|
||||||
@ -409,10 +410,11 @@ func (m *ManuallyCover) CheckParams() error {
|
|||||||
|
|
||||||
// ClosePosition 平仓请求
|
// ClosePosition 平仓请求
|
||||||
type ClosePosition struct {
|
type ClosePosition struct {
|
||||||
ApiId int `json:"api_id"` //api-user 用户id
|
ApiId int `json:"api_id"` //api-user 用户id
|
||||||
Symbol string `json:"symbol"` // 交易对
|
Symbol string `json:"symbol"` // 交易对
|
||||||
Rate string `json:"rate"` //限价平仓百分比
|
Rate string `json:"rate"` //限价平仓百分比
|
||||||
CloseType int `json:"close_type"` //现货平仓=1 合约平仓=2
|
CloseType int `json:"close_type"` //现货平仓=1 合约平仓=2
|
||||||
|
ExchangeType string `json:"exchange_type"` //交易所类型 字典exchange_type
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ClosePosition) CheckParams() error {
|
func (m *ClosePosition) CheckParams() error {
|
||||||
|
|||||||
@ -255,7 +255,7 @@ func (e *LinePreOrder) Remove(d *dto.LinePreOrderDeleteReq, p *actions.DataPermi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(ints) > 0 {
|
if len(ints) > 0 {
|
||||||
e.Orm.Model(&models.LinePreOrder{}).Where("pid >0 AND pid in ?", ints).Unscoped().Delete(&models.LinePreOrder{})
|
e.Orm.Model(&models.LinePreOrder{}).Where("main_id >0 AND main_id in ?", ints).Unscoped().Delete(&models.LinePreOrder{})
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ func (e *LinePreOrder) AddPreOrder(req *dto.LineAddPreOrderReq, p *actions.DataP
|
|||||||
//订单配置信息
|
//订单配置信息
|
||||||
preOrderExts := make([]models.LinePreOrderExt, 0)
|
preOrderExts := make([]models.LinePreOrderExt, 0)
|
||||||
defultExt := models.LinePreOrderExt{
|
defultExt := models.LinePreOrderExt{
|
||||||
TakeProfitRatio: req.TakeProfitRatio,
|
TakeProfitRatio: utility.StringToDecimal(req.Profit),
|
||||||
ReducePriceRatio: req.ReducePriceRatio,
|
ReducePriceRatio: req.ReducePriceRatio,
|
||||||
ReduceNumRatio: req.ReduceNumRatio,
|
ReduceNumRatio: req.ReduceNumRatio,
|
||||||
ReduceTakeProfitRatio: req.ReduceTakeProfitRatio,
|
ReduceTakeProfitRatio: req.ReduceTakeProfitRatio,
|
||||||
@ -441,6 +441,10 @@ func (e *LinePreOrder) AddPreOrder(req *dto.LineAddPreOrderReq, p *actions.DataP
|
|||||||
preOrderExts[index].MainOrderId = AddOrder.Id
|
preOrderExts[index].MainOrderId = AddOrder.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = tx.Model(&models.LinePreOrderExt{}).Create(&preOrderExts).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
list := dto.PreOrderRedisList{
|
list := dto.PreOrderRedisList{
|
||||||
Id: AddOrder.Id,
|
Id: AddOrder.Id,
|
||||||
Symbol: AddOrder.Symbol,
|
Symbol: AddOrder.Symbol,
|
||||||
@ -650,7 +654,7 @@ func (e *LinePreOrder) QuickAddPreOrder(quickReq *dto.QuickAddPreOrderReq, p *ac
|
|||||||
// Lever 设置杠杆
|
// Lever 设置杠杆
|
||||||
func (e *LinePreOrder) Lever(req *dto.LeverReq, p *actions.DataPermission, errs *[]error) {
|
func (e *LinePreOrder) Lever(req *dto.LeverReq, p *actions.DataPermission, errs *[]error) {
|
||||||
users := make([]models.LineApiUser, 0)
|
users := make([]models.LineApiUser, 0)
|
||||||
err := e.Orm.Model(&models.LineApiUser{}).Where("id in ? ", strings.Split(req.ApiUserIds, ",")).Find(&users).Error
|
err := e.Orm.Model(&models.LineApiUser{}).Where("id in ? AND exchange_type = ?", strings.Split(req.ApiUserIds, ","), req.ExchangeType).Find(&users).Error
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
*errs = append(*errs, errors.New(fmt.Sprintf("设置杠杆失败:%+v", err.Error())))
|
*errs = append(*errs, errors.New(fmt.Sprintf("设置杠杆失败:%+v", err.Error())))
|
||||||
return
|
return
|
||||||
@ -660,14 +664,14 @@ func (e *LinePreOrder) Lever(req *dto.LeverReq, p *actions.DataPermission, errs
|
|||||||
symbols = req.Symbol
|
symbols = req.Symbol
|
||||||
} else {
|
} else {
|
||||||
var symbolGroupInfo models.LineSymbolGroup
|
var symbolGroupInfo models.LineSymbolGroup
|
||||||
e.Orm.Model(&models.LineSymbolGroup{}).Where("id = ?", req.GroupId).Find(&symbolGroupInfo)
|
e.Orm.Model(&models.LineSymbolGroup{}).Where("id = ? AND exchange_type = ?", req.GroupId, req.ExchangeType).Find(&symbolGroupInfo)
|
||||||
symbols = symbolGroupInfo.Symbol
|
symbols = symbolGroupInfo.Symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.IsAll == 1 {
|
if req.IsAll == 1 {
|
||||||
lineSymbols := make([]models.LineSymbol, 0)
|
lineSymbols := make([]models.LineSymbol, 0)
|
||||||
futSymbols := make([]string, 0)
|
futSymbols := make([]string, 0)
|
||||||
e.Orm.Model(&models.LineSymbol{}).Where("type = '2' AND switch = '1'").Find(&lineSymbols)
|
e.Orm.Model(&models.LineSymbol{}).Where("type = '2' AND switch = '1' AND exchange_type = ?", req.ExchangeType).Find(&lineSymbols)
|
||||||
for _, symbol := range lineSymbols {
|
for _, symbol := range lineSymbols {
|
||||||
futSymbols = append(futSymbols, symbol.Symbol)
|
futSymbols = append(futSymbols, symbol.Symbol)
|
||||||
}
|
}
|
||||||
@ -676,6 +680,15 @@ func (e *LinePreOrder) Lever(req *dto.LeverReq, p *actions.DataPermission, errs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.ExchangeType == global.EXCHANGE_BINANCE {
|
||||||
|
e.SetBinanceLever(req, users, symbols, errs)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBinanceLever 设置币安杠杆
|
||||||
|
func (e *LinePreOrder) SetBinanceLever(req *dto.LeverReq, users []models.LineApiUser, symbols string, errs *[]error) {
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
var client *helper.BinanceClient
|
var client *helper.BinanceClient
|
||||||
if user.UserPass == "" {
|
if user.UserPass == "" {
|
||||||
@ -707,38 +720,10 @@ func (e *LinePreOrder) Lever(req *dto.LeverReq, p *actions.DataPermission, errs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarginType 设置仓位模式
|
// SetBinanceMarginType 设置币安保证金模式
|
||||||
func (e *LinePreOrder) MarginType(req *dto.MarginTypeReq, p *actions.DataPermission, errs *[]error) {
|
func (e *LinePreOrder) SetBinanceMarginType(req *dto.MarginTypeReq, users []models.LineApiUser, symbols string, errs *[]error) {
|
||||||
users := make([]models.LineApiUser, 0)
|
|
||||||
err := e.Orm.Model(&models.LineApiUser{}).Where("id in ? ", strings.Split(req.ApiUserIds, ",")).Find(&users).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
*errs = append(*errs, errors.New(fmt.Sprintf("设置杠杆失败:%+v", err.Error())))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var symbols string
|
|
||||||
if req.Symbol != "" {
|
|
||||||
symbols = req.Symbol
|
|
||||||
} else {
|
|
||||||
var symbolGroupInfo models.LineSymbolGroup
|
|
||||||
e.Orm.Model(&models.LineSymbolGroup{}).Where("id = ?", req.GroupId).Find(&symbolGroupInfo)
|
|
||||||
symbols = symbolGroupInfo.Symbol
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.IsAll == 1 {
|
|
||||||
lineSymbols := make([]models.LineSymbol, 0)
|
|
||||||
futSymbols := make([]string, 0)
|
|
||||||
e.Orm.Model(&models.LineSymbol{}).Where("type = '2' AND switch = '1'").Find(&lineSymbols)
|
|
||||||
for _, symbol := range lineSymbols {
|
|
||||||
futSymbols = append(futSymbols, symbol.Symbol)
|
|
||||||
}
|
|
||||||
if len(futSymbols) != 0 {
|
|
||||||
symbols = strings.Join(futSymbols, ",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
var client *helper.BinanceClient
|
var client *helper.BinanceClient
|
||||||
if user.UserPass == "" {
|
if user.UserPass == "" {
|
||||||
@ -776,6 +761,40 @@ func (e *LinePreOrder) MarginType(req *dto.MarginTypeReq, p *actions.DataPermiss
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarginType 设置仓位模式
|
||||||
|
func (e *LinePreOrder) MarginType(req *dto.MarginTypeReq, p *actions.DataPermission, errs *[]error) {
|
||||||
|
users := make([]models.LineApiUser, 0)
|
||||||
|
err := e.Orm.Model(&models.LineApiUser{}).Where("id in ? ", strings.Split(req.ApiUserIds, ",")).Find(&users).Error
|
||||||
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
*errs = append(*errs, errors.New(fmt.Sprintf("设置杠杆失败:%+v", err.Error())))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var symbols string
|
||||||
|
if req.Symbol != "" {
|
||||||
|
symbols = req.Symbol
|
||||||
|
} else {
|
||||||
|
var symbolGroupInfo models.LineSymbolGroup
|
||||||
|
e.Orm.Model(&models.LineSymbolGroup{}).Where("id = ?", req.GroupId).Find(&symbolGroupInfo)
|
||||||
|
symbols = symbolGroupInfo.Symbol
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.IsAll == 1 {
|
||||||
|
lineSymbols := make([]models.LineSymbol, 0)
|
||||||
|
futSymbols := make([]string, 0)
|
||||||
|
e.Orm.Model(&models.LineSymbol{}).Where("type = '2' AND switch = '1'").Find(&lineSymbols)
|
||||||
|
for _, symbol := range lineSymbols {
|
||||||
|
futSymbols = append(futSymbols, symbol.Symbol)
|
||||||
|
}
|
||||||
|
if len(futSymbols) != 0 {
|
||||||
|
symbols = strings.Join(futSymbols, ",")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.ExchangeType == global.EXCHANGE_BINANCE {
|
||||||
|
e.SetBinanceMarginType(req, users, symbols, errs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CancelOpenOrder 取消委托
|
// CancelOpenOrder 取消委托
|
||||||
func (e *LinePreOrder) CancelOpenOrder(req *dto.CancelOpenOrderReq, errs *[]error) {
|
func (e *LinePreOrder) CancelOpenOrder(req *dto.CancelOpenOrderReq, errs *[]error) {
|
||||||
newClientOrderIdList := make([]string, 0)
|
newClientOrderIdList := make([]string, 0)
|
||||||
@ -805,14 +824,14 @@ func (e *LinePreOrder) CancelOpenOrder(req *dto.CancelOpenOrderReq, errs *[]erro
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var orderList []models.LinePreOrder
|
var orderList []models.LinePreOrder
|
||||||
e.Orm.Model(&models.LinePreOrder{}).Where("api_id = ? AND pid = 0 status = '5' AND order_type = ?", req.ApiId, strconv.Itoa(req.OrderType)).Find(&orderList)
|
e.Orm.Model(&models.LinePreOrder{}).Where("api_id = ? AND main_id = 0 status = '5'", req.ApiId).Find(&orderList)
|
||||||
if len(orderList) <= 0 {
|
if len(orderList) <= 0 {
|
||||||
*errs = append(*errs, fmt.Errorf("没有可撤销的委托"))
|
*errs = append(*errs, fmt.Errorf("没有可撤销的委托"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, order := range orderList {
|
for _, order := range orderList {
|
||||||
|
|
||||||
if order.OrderType == global.SYMBOL_SPOT {
|
if order.SymbolType == global.SYMBOL_SPOT {
|
||||||
err := spotApi.CancelOpenOrderByOrderSn(apiUserInfo, req.Symbol, req.OrderSn)
|
err := spotApi.CancelOpenOrderByOrderSn(apiUserInfo, req.Symbol, req.OrderSn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
*errs = append(*errs, fmt.Errorf("取消委托失败:%+v", err.Error()))
|
*errs = append(*errs, fmt.Errorf("取消委托失败:%+v", err.Error()))
|
||||||
@ -1030,6 +1049,7 @@ func (e *LinePreOrder) SpotClosePosition(position *dto.ClosePosition, errs *[]er
|
|||||||
order := models.LinePreOrder{
|
order := models.LinePreOrder{
|
||||||
ExchangeType: global.EXCHANGE_BINANCE,
|
ExchangeType: global.EXCHANGE_BINANCE,
|
||||||
Pid: list.Id,
|
Pid: list.Id,
|
||||||
|
MainId: list.Id,
|
||||||
ApiId: list.ApiId,
|
ApiId: list.ApiId,
|
||||||
GroupId: "0",
|
GroupId: "0",
|
||||||
Symbol: list.Symbol,
|
Symbol: list.Symbol,
|
||||||
@ -1049,6 +1069,7 @@ func (e *LinePreOrder) SpotClosePosition(position *dto.ClosePosition, errs *[]er
|
|||||||
ExpireTime: time.Now().Add(time.Hour * 24 * 30),
|
ExpireTime: time.Now().Add(time.Hour * 24 * 30),
|
||||||
MainOrderType: list.MainOrderType,
|
MainOrderType: list.MainOrderType,
|
||||||
Child: nil,
|
Child: nil,
|
||||||
|
OrderCategory: 1,
|
||||||
}
|
}
|
||||||
err := e.Orm.Model(&models.LinePreOrder{}).Create(&order).Error
|
err := e.Orm.Model(&models.LinePreOrder{}).Create(&order).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1137,6 +1158,7 @@ func (e *LinePreOrder) FutClosePosition(position *dto.ClosePosition, errs *[]err
|
|||||||
order := models.LinePreOrder{
|
order := models.LinePreOrder{
|
||||||
Pid: parentId,
|
Pid: parentId,
|
||||||
ApiId: list.ApiId,
|
ApiId: list.ApiId,
|
||||||
|
MainId: list.Id,
|
||||||
GroupId: "0",
|
GroupId: "0",
|
||||||
Symbol: list.Symbol,
|
Symbol: list.Symbol,
|
||||||
QuoteSymbol: list.QuoteSymbol,
|
QuoteSymbol: list.QuoteSymbol,
|
||||||
@ -1155,6 +1177,7 @@ func (e *LinePreOrder) FutClosePosition(position *dto.ClosePosition, errs *[]err
|
|||||||
ExpireTime: time.Now().Add(24 * 30 * time.Hour),
|
ExpireTime: time.Now().Add(24 * 30 * time.Hour),
|
||||||
MainOrderType: list.MainOrderType,
|
MainOrderType: list.MainOrderType,
|
||||||
Child: nil,
|
Child: nil,
|
||||||
|
OrderCategory: 1,
|
||||||
}
|
}
|
||||||
err = e.Orm.Model(&models.LinePreOrder{}).Create(&order).Error
|
err = e.Orm.Model(&models.LinePreOrder{}).Create(&order).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1190,7 +1213,7 @@ func (e *LinePreOrder) FutClosePosition(position *dto.ClosePosition, errs *[]err
|
|||||||
// ClearUnTriggered 清除待触发的交易对
|
// ClearUnTriggered 清除待触发的交易对
|
||||||
func (e *LinePreOrder) ClearUnTriggered() error {
|
func (e *LinePreOrder) ClearUnTriggered() error {
|
||||||
var orderLists []models.LinePreOrder
|
var orderLists []models.LinePreOrder
|
||||||
e.Orm.Model(&models.LinePreOrder{}).Where("pid = 0 AND status = '0'").Find(&orderLists).Unscoped().Delete(&models.LinePreOrder{})
|
e.Orm.Model(&models.LinePreOrder{}).Where("main_id = 0 AND pid = 0 AND status = '0'").Find(&orderLists).Unscoped().Delete(&models.LinePreOrder{})
|
||||||
|
|
||||||
for _, order := range orderLists {
|
for _, order := range orderLists {
|
||||||
redisList := dto.PreOrderRedisList{
|
redisList := dto.PreOrderRedisList{
|
||||||
@ -1212,7 +1235,7 @@ func (e *LinePreOrder) ClearUnTriggered() error {
|
|||||||
key := fmt.Sprintf(rediskey.PreSpotOrderList, order.ExchangeType)
|
key := fmt.Sprintf(rediskey.PreSpotOrderList, order.ExchangeType)
|
||||||
helper.DefaultRedis.LRem(key, string(marshal))
|
helper.DefaultRedis.LRem(key, string(marshal))
|
||||||
}
|
}
|
||||||
e.Orm.Model(&models.LinePreOrder{}).Where("pid = ?", order.Id).Unscoped().Delete(&models.LinePreOrder{})
|
e.Orm.Model(&models.LinePreOrder{}).Where("main_id = ?", order.Id).Unscoped().Delete(&models.LinePreOrder{})
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -31,7 +31,6 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.17.0
|
github.com/prometheus/client_golang v1.17.0
|
||||||
github.com/qiniu/go-sdk/v7 v7.18.2
|
github.com/qiniu/go-sdk/v7 v7.18.2
|
||||||
github.com/redis/go-redis/v9 v9.3.0
|
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/rs/xid v1.2.1
|
github.com/rs/xid v1.2.1
|
||||||
github.com/shirou/gopsutil/v3 v3.23.10
|
github.com/shirou/gopsutil/v3 v3.23.10
|
||||||
@ -143,6 +142,7 @@ require (
|
|||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.45.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
|
github.com/redis/go-redis/v9 v9.3.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/shamsher31/goimgext v1.0.0 // indirect
|
github.com/shamsher31/goimgext v1.0.0 // indirect
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
|
|||||||
Reference in New Issue
Block a user