1、合约止盈止损单在减仓单成交之后再取消
This commit is contained in:
@ -555,50 +555,6 @@ func (e FutRestApi) OrderPlace(orm *gorm.DB, params FutOrderPlace) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClosePositionB 平仓B对应的交易对
|
||||
// bApiUserInfo B 账户api-user信息
|
||||
// symbol 需要平仓的交易对
|
||||
// closeType 平仓模式 ALL = 全平 reduceOnly = 只减仓
|
||||
// func (e FutRestApi) ClosePositionB(orm *gorm.DB, bApiUserInfo *DbModels.LineApiUser, symbol string, closeType string) error {
|
||||
// if bApiUserInfo == nil {
|
||||
// return errors.New("缺失平仓账户信息")
|
||||
// }
|
||||
// if symbol == "" {
|
||||
// return errors.New("缺失平仓交易对信息")
|
||||
// }
|
||||
// risks, err := e.GetPositionV3(bApiUserInfo, symbol)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// for _, risk := range risks {
|
||||
// if risk.Symbol == strings.ToUpper(symbol) {
|
||||
// //持仓数量
|
||||
// positionAmt, _ := decimal.NewFromString(risk.PositionAmt)
|
||||
// side := "BUY"
|
||||
// if positionAmt.GreaterThan(decimal.Zero) {
|
||||
// side = "SELL"
|
||||
// }
|
||||
// var closeAmt decimal.Decimal
|
||||
// if strings.ToUpper(closeType) == "ALL" { //全部平仓
|
||||
// closeAmt = positionAmt
|
||||
// } else {
|
||||
// //如果是只减仓的话 数量=仓位数量*比例
|
||||
// closeAmt = positionAmt.Mul(decimal.NewFromFloat(reduceOnlyRate))
|
||||
// }
|
||||
|
||||
// err = e.ClosePosition(symbol, closeAmt, side, *bApiUserInfo, "MARKET", "", decimal.Zero)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// orm.Model(&DbModels.LinePreOrder{}).Where("api_id = ? AND symbol = ?", bApiUserInfo.Id, symbol).Updates(map[string]interface{}{
|
||||
// "status": "6",
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
// 获取合约 持仓价格、数量
|
||||
// symbol:交易对
|
||||
// side:方向
|
||||
|
||||
Reference in New Issue
Block a user