Merge branch '单边仓位_master' of http://120.25.162.35:82/hucan/exchange_go into 单边仓位_master

This commit is contained in:
daichao
2025-02-11 09:39:23 +08:00
12 changed files with 515 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

@ -14,6 +14,8 @@ type LineSystemSetting struct {
ProfitRate string `json:"profitRate" gorm:"type:decimal(10,2);comment:平仓盈利比例"`
CoverOrderTypeBRate string `json:"coverOrderTypeBRate" gorm:"type:decimal(10,2);comment:b账户限价补单的买入百分比"`
StopLossPremium decimal.Decimal `json:"stopLossPremium" gorm:"type:decimal(10,2);comment:限价止损溢价百分比"`
AddPositionPremium decimal.Decimal `json:"addPositionPremium" gorm:"type:decimal(10,2);comment:限价加仓溢价百分比`
ReducePremium decimal.Decimal `json:"reducePremium" gorm:"type:decimal(10,2);comment:限价减仓溢价百分比"`
models.ModelTime
models.ControlBy
}

View File

@ -362,7 +362,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

@ -63,6 +63,8 @@ type LineSystemSettingUpdateReq struct {
ProfitRate string `json:"profitRate" comment:"平仓盈利比例"`
CoverOrderTypeBRate string `json:"coverOrderTypeBRate" comment:"b账户限价补单的买入百分比"`
StopLossPremium decimal.Decimal `json:"stopLossPremium" comment:"限价止损溢价"`
AddPositionPremium decimal.Decimal `json:"addPositionPremium" comment:"限价加仓溢价"`
ReducePremium decimal.Decimal `json:"reducePremium" comment:"限价减仓溢价"`
common.ControlBy
}

View File

@ -850,14 +850,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",
@ -880,6 +882,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") //订单拓展配置