This commit is contained in:
2025-02-10 18:21:44 +08:00
parent 7d906caadd
commit 7da62d8f7e
10 changed files with 511 additions and 58 deletions

View File

@ -24,7 +24,7 @@ type LinePreOrder struct {
Num string `json:"num" gorm:"type:decimal(18,8);omitempty;comment:购买数量"`
BuyPrice string `json:"buyPrice" gorm:"type:decimal(18,8);omitempty;comment:购买金额"`
SymbolType int `json:"symbolType" gorm:"type:int;comment:交易对类型:1=现货;2=合约"`
OrderCategory int `json:"orderCategory" gorm:"type:int;comment:订单类型: 1=主单 2=对冲单"`
OrderCategory int `json:"orderCategory" gorm:"type:int;comment:订单类型: 1=主单 2=对冲单 3-加仓单"`
Site string `json:"site" gorm:"type:enum('BUY','SELL');omitempty;comment:购买方向:BUY=买;SELL=卖"`
OrderSn string `json:"orderSn" gorm:"type:varchar(255);omitempty;comment:订单号"`
OrderType int `json:"orderType" gorm:"type:int;omitempty;comment:订单类型:0=主单 1=止盈 2=止损 3=平仓 4=减仓"`
@ -33,6 +33,7 @@ type LinePreOrder struct {
CoverType int `json:"coverType" gorm:"type:int unsigned;omitempty;comment:对冲类型 1= 现货对合约 2=合约对合约 3 合约对现货"`
ExpireTime time.Time `json:"expireTime" gorm:"comment:过期时间"`
MainOrderType string `json:"mainOrderType" gorm:"type:enum;comment:第一笔(主单类型) 限价LIMIT市价(MARKET)"`
LossAmount decimal.Decimal `json:"lossAmount" gorm:"type:decimal(15,2);comment:亏损金额U"`
Child []LinePreOrder `json:"child" gorm:"-"`
ApiName string `json:"api_name" gorm:"->"`
ChildNum int64 `json:"child_num" gorm:"->"`

View File

@ -12,10 +12,12 @@ type LinePreOrderExt struct {
MainOrderId int `json:"mainOrderId" gorm:"type:bigint;comment:主单id"`
OrderId int `json:"orderId" gorm:"type:bigint;comment:订单id"`
TakeProfitRatio decimal.Decimal `json:"takeProfitRatio" gorm:"type:decimal(10,2);comment:止盈百分比"`
ReduceOrderType string `json:"reduceOrderType" gorm:"type:varchar(20);comment:减仓类型 LIMIT-限价 MARKET-市价"`
ReducePriceRatio decimal.Decimal `json:"reducePriceRatio" gorm:"type:decimal(10,2);comment:减仓价格百分比"`
ReduceNumRatio decimal.Decimal `json:"reduceNumRatio" gorm:"type:decimal(10,2);comment:减仓数量百分比"`
ReduceTakeProfitRatio decimal.Decimal `json:"reduceTakeProfitRatio" gorm:"type:decimal(10,2);comment:减仓后止盈百分比"`
ReduceStopLossRatio decimal.Decimal `json:"reduceStopLossRatio" gorm:"type:decimal(10,2);comment:减仓后止损百分比"`
AddPositionOrderType string `json:"addPositionOrderType" gorm:"type:varchar(20);comment:加仓类型 LIMIT-限价 MARKET-市价"`
AddPositionPriceRatio decimal.Decimal `json:"addPositionPriceRatio" gorm:"type:decimal(10,2);comment:加仓价格百分比"`
AddPositionType int `json:"addPositionType" gorm:"type:int;comment:加仓类型 1-百分比 2-实际金额"`
AddPositionVal decimal.Decimal `json:"addPositionVal" gorm:"type:decimal(10,2);comment:加仓值"`

View File

@ -361,7 +361,8 @@ type PreOrderRedisList struct {
type StopLossRedisList struct {
Id int `json:"id"`
PId int `json:"pid"`
PId int `json:"pid"` //父级id
MainId int `json:"mainId"` //主单id
OrderTye int `json:"orderType"`
SymbolType int `json:"symbolType"`
OrderCategory int `json:"orderCategory"`

View File

@ -831,14 +831,16 @@ func (e *LinePreOrder) CancelOpenOrder(req *dto.CancelOpenOrderReq, errs *[]erro
// ClearAll 一键清除数据
func (e *LinePreOrder) ClearAll() error {
_, err := helper.DefaultRedis.BatchDeleteKeys([]string{rediskey.PreSpotOrderList, rediskey.PreFutOrderList,
rediskey.SpotStopLossList, rediskey.FuturesStopLossList, rediskey.SpotAddPositionList, rediskey.FuturesAddPositionList,
})
_, err := helper.DefaultRedis.BatchDeleteKeys([]string{rediskey.PreSpotOrderList, rediskey.PreFutOrderList})
if err != nil {
e.Log.Errorf("Service RemoveLinePreOrder error:%s \r\n", err)
return err
}
prefixs := []string{
"spot_stoploss_list",
"futures_stoploss_list",
"spot_add_position_list",
"futures_add_position_list",
"api_user_hold",
"spot_trigger_lock",
"fut_trigger_lock",
@ -861,6 +863,7 @@ func (e *LinePreOrder) ClearAll() error {
e.Log.Errorf("Service RemoveLinePreOrder error:%s \r\n", err)
return err
}
e.Orm.Model(&models.LinePreOrder{}).Exec("TRUNCATE TABLE line_pre_order") //订单表
e.Orm.Model(&models.LinePreOrder{}).Exec("TRUNCATE TABLE line_pre_order_status") //订单拓展状态
e.Orm.Model(&models.LinePreOrder{}).Exec("TRUNCATE TABLE line_pre_order_ext") //订单拓展配置