1
This commit is contained in:
202
app/admin/apis/spider_listen_symbol.go
Normal file
202
app/admin/apis/spider_listen_symbol.go
Normal file
@ -0,0 +1,202 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
type SpiderListenSymbol struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// GetPage 获取交易对监听列表
|
||||
// @Summary 获取交易对监听列表
|
||||
// @Description 获取交易对监听列表
|
||||
// @Tags 交易对监听
|
||||
// @Param symbol query string false "交易对"
|
||||
// @Param pageSize query int false "页条数"
|
||||
// @Param pageIndex query int false "页码"
|
||||
// @Success 200 {object} response.Response{data=response.Page{list=[]models.SpiderListenSymbol}} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/spider-listen-symbol [get]
|
||||
// @Security Bearer
|
||||
func (e SpiderListenSymbol) GetPage(c *gin.Context) {
|
||||
req := dto.SpiderListenSymbolGetPageReq{}
|
||||
s := service.SpiderListenSymbol{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
list := make([]models.SpiderListenSymbol, 0)
|
||||
var count int64
|
||||
|
||||
err = s.GetPage(&req, p, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取交易对监听失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// Get 获取交易对监听
|
||||
// @Summary 获取交易对监听
|
||||
// @Description 获取交易对监听
|
||||
// @Tags 交易对监听
|
||||
// @Param id path int false "id"
|
||||
// @Success 200 {object} response.Response{data=models.SpiderListenSymbol} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/spider-listen-symbol/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e SpiderListenSymbol) Get(c *gin.Context) {
|
||||
req := dto.SpiderListenSymbolGetReq{}
|
||||
s := service.SpiderListenSymbol{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
var object models.SpiderListenSymbol
|
||||
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
err = s.Get(&req, p, &object)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取交易对监听失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(object, "查询成功")
|
||||
}
|
||||
|
||||
// Insert 创建交易对监听
|
||||
// @Summary 创建交易对监听
|
||||
// @Description 创建交易对监听
|
||||
// @Tags 交易对监听
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SpiderListenSymbolInsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
|
||||
// @Router /api/v1/spider-listen-symbol [post]
|
||||
// @Security Bearer
|
||||
func (e SpiderListenSymbol) Insert(c *gin.Context) {
|
||||
req := dto.SpiderListenSymbolInsertReq{}
|
||||
s := service.SpiderListenSymbol{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
req.SetCreateBy(user.GetUserId(c))
|
||||
|
||||
if err := req.Valid(); err != nil {
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
|
||||
err = s.Insert(&req)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("创建交易对监听失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(req.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// Update 修改交易对监听
|
||||
// @Summary 修改交易对监听
|
||||
// @Description 修改交易对监听
|
||||
// @Tags 交易对监听
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param id path int true "id"
|
||||
// @Param data body dto.SpiderListenSymbolUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
|
||||
// @Router /api/v1/spider-listen-symbol/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e SpiderListenSymbol) Update(c *gin.Context) {
|
||||
req := dto.SpiderListenSymbolUpdateReq{}
|
||||
s := service.SpiderListenSymbol{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
if err := req.Valid(); err != nil {
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
|
||||
err = s.Update(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("修改交易对监听失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "修改成功")
|
||||
}
|
||||
|
||||
// Delete 删除交易对监听
|
||||
// @Summary 删除交易对监听
|
||||
// @Description 删除交易对监听
|
||||
// @Tags 交易对监听
|
||||
// @Param data body dto.SpiderListenSymbolDeleteReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
|
||||
// @Router /api/v1/spider-listen-symbol [delete]
|
||||
// @Security Bearer
|
||||
func (e SpiderListenSymbol) Delete(c *gin.Context) {
|
||||
s := service.SpiderListenSymbol{}
|
||||
req := dto.SpiderListenSymbolDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.Remove(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("删除交易对监听失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "删除成功")
|
||||
}
|
||||
30
app/admin/models/spider_listen_symbol.go
Normal file
30
app/admin/models/spider_listen_symbol.go
Normal file
@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
|
||||
"go-admin/common/models"
|
||||
|
||||
)
|
||||
|
||||
type SpiderListenSymbol struct {
|
||||
models.Model
|
||||
|
||||
Symbol string `json:"symbol" gorm:"type:varchar(255);comment:交易对"`
|
||||
Coin string `json:"coin" gorm:"type:varchar(255);comment:代币"`
|
||||
Currency string `json:"currency" gorm:"type:varchar(255);comment:计价货币"`
|
||||
models.ModelTime
|
||||
models.ControlBy
|
||||
}
|
||||
|
||||
func (SpiderListenSymbol) TableName() string {
|
||||
return "spider_listen_symbol"
|
||||
}
|
||||
|
||||
func (e *SpiderListenSymbol) Generate() models.ActiveRecord {
|
||||
o := *e
|
||||
return &o
|
||||
}
|
||||
|
||||
func (e *SpiderListenSymbol) GetId() interface{} {
|
||||
return e.Id
|
||||
}
|
||||
27
app/admin/router/spider_listen_symbol.go
Normal file
27
app/admin/router/spider_listen_symbol.go
Normal file
@ -0,0 +1,27 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
|
||||
"go-admin/app/admin/apis"
|
||||
"go-admin/common/middleware"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
func init() {
|
||||
routerCheckRole = append(routerCheckRole, registerSpiderListenSymbolRouter)
|
||||
}
|
||||
|
||||
// registerSpiderListenSymbolRouter
|
||||
func registerSpiderListenSymbolRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.SpiderListenSymbol{}
|
||||
r := v1.Group("/spider-listen-symbol").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
r.GET("", actions.PermissionAction(), api.GetPage)
|
||||
r.GET("/:id", actions.PermissionAction(), api.Get)
|
||||
r.POST("", api.Insert)
|
||||
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
||||
r.DELETE("", api.Delete)
|
||||
}
|
||||
}
|
||||
121
app/admin/service/dto/spider_listen_symbol.go
Normal file
121
app/admin/service/dto/spider_listen_symbol.go
Normal file
@ -0,0 +1,121 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SpiderListenSymbolGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Symbol string `form:"symbol" search:"type:contains;column:symbol;table:spider_listen_symbol" comment:"交易对"`
|
||||
SpiderListenSymbolOrder
|
||||
}
|
||||
|
||||
type SpiderListenSymbolOrder struct {
|
||||
Id string `form:"idOrder" search:"type:order;column:id;table:spider_listen_symbol"`
|
||||
Symbol string `form:"symbolOrder" search:"type:order;column:symbol;table:spider_listen_symbol"`
|
||||
Coin string `form:"coinOrder" search:"type:order;column:coin;table:spider_listen_symbol"`
|
||||
Currency string `form:"currencyOrder" search:"type:order;column:currency;table:spider_listen_symbol"`
|
||||
CreatedAt string `form:"createdAtOrder" search:"type:order;column:created_at;table:spider_listen_symbol"`
|
||||
UpdatedAt string `form:"updatedAtOrder" search:"type:order;column:updated_at;table:spider_listen_symbol"`
|
||||
DeletedAt string `form:"deletedAtOrder" search:"type:order;column:deleted_at;table:spider_listen_symbol"`
|
||||
CreateBy string `form:"createByOrder" search:"type:order;column:create_by;table:spider_listen_symbol"`
|
||||
UpdateBy string `form:"updateByOrder" search:"type:order;column:update_by;table:spider_listen_symbol"`
|
||||
}
|
||||
|
||||
func (m *SpiderListenSymbolGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type SpiderListenSymbolInsertReq struct {
|
||||
Id int `json:"-" comment:"主键"` // 主键
|
||||
Symbol string `json:"symbol" comment:"交易对"`
|
||||
Coin string `json:"coin" comment:"代币"`
|
||||
Currency string `json:"currency" comment:"计价货币"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolInsertReq) Valid() error {
|
||||
|
||||
if s.Coin == "" {
|
||||
return errors.New("代币不能为空")
|
||||
}
|
||||
|
||||
if s.Coin == "" {
|
||||
return errors.New("代币不能为空")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolInsertReq) Generate(model *models.SpiderListenSymbol) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{Id: s.Id}
|
||||
}
|
||||
|
||||
model.Coin = strings.ToUpper(s.Coin)
|
||||
model.Currency = strings.ToUpper(s.Currency)
|
||||
model.Symbol = s.Coin + s.Currency
|
||||
model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolInsertReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SpiderListenSymbolUpdateReq struct {
|
||||
Id int `uri:"id" comment:"主键"` // 主键
|
||||
Symbol string `json:"symbol" comment:"交易对"`
|
||||
Coin string `json:"coin" comment:"代币"`
|
||||
Currency string `json:"currency" comment:"计价货币"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolUpdateReq) Valid() error {
|
||||
|
||||
if s.Coin == "" {
|
||||
return errors.New("代币不能为空")
|
||||
}
|
||||
|
||||
if s.Coin == "" {
|
||||
return errors.New("代币不能为空")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolUpdateReq) Generate(model *models.SpiderListenSymbol) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{Id: s.Id}
|
||||
}
|
||||
// model.Symbol = s.Symbol
|
||||
model.Coin = strings.ToUpper(s.Coin)
|
||||
model.Currency = strings.ToUpper(s.Currency)
|
||||
model.Symbol = s.Coin + s.Currency
|
||||
model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// SpiderListenSymbolGetReq 功能获取请求参数
|
||||
type SpiderListenSymbolGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// SpiderListenSymbolDeleteReq 功能删除请求参数
|
||||
type SpiderListenSymbolDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SpiderListenSymbolDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
@ -1693,7 +1693,7 @@ func (e *LinePreOrder) CalculateBreakEvenRatio(req *dto.CalculateBreakEevenRatio
|
||||
if req.AddPositionType == 1 {
|
||||
addPositionBuyPrice = req.BuyPrice.Mul(req.AddPositionVal.Div(decimal.NewFromInt(100).Truncate(4))).Truncate(2)
|
||||
} else {
|
||||
addPositionBuyPrice = req.BuyPrice.Add(req.AddPositionVal).Truncate(2)
|
||||
addPositionBuyPrice = req.AddPositionVal.Truncate(2)
|
||||
}
|
||||
|
||||
var percentDiff decimal.Decimal
|
||||
@ -1707,7 +1707,7 @@ func (e *LinePreOrder) CalculateBreakEvenRatio(req *dto.CalculateBreakEevenRatio
|
||||
}
|
||||
|
||||
totalAmount := req.RemainingQuantity.Add(addPositionAmount)
|
||||
lossAmountU := req.Price.Mul(percentDiff.Div(decimal.NewFromInt(100).Truncate(4))).Mul(req.RemainingQuantity).Truncate(int32(tradeSet.AmountDigit))
|
||||
lossAmountU := req.Price.Mul(percentDiff.Div(decimal.NewFromInt(100).Truncate(4))).Mul(req.RemainingQuantity).Truncate(int32(tradeSet.PriceDigit))
|
||||
|
||||
//计算减仓数量
|
||||
if req.ReducePercent.Cmp(decimal.NewFromInt(0)) > 0 {
|
||||
|
||||
109
app/admin/service/spider_listen_symbol.go
Normal file
109
app/admin/service/spider_listen_symbol.go
Normal file
@ -0,0 +1,109 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/go-admin-team/go-admin-core/sdk/service"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
)
|
||||
|
||||
type SpiderListenSymbol struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// GetPage 获取SpiderListenSymbol列表
|
||||
func (e *SpiderListenSymbol) GetPage(c *dto.SpiderListenSymbolGetPageReq, p *actions.DataPermission, list *[]models.SpiderListenSymbol, count *int64) error {
|
||||
var err error
|
||||
var data models.SpiderListenSymbol
|
||||
|
||||
err = e.Orm.Model(&data).
|
||||
Scopes(
|
||||
cDto.MakeCondition(c.GetNeedSearch()),
|
||||
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
|
||||
actions.Permission(data.TableName(), p),
|
||||
).
|
||||
Find(list).Limit(-1).Offset(-1).
|
||||
Count(count).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("SpiderListenSymbolService GetPage error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get 获取SpiderListenSymbol对象
|
||||
func (e *SpiderListenSymbol) Get(d *dto.SpiderListenSymbolGetReq, p *actions.DataPermission, model *models.SpiderListenSymbol) error {
|
||||
var data models.SpiderListenSymbol
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).
|
||||
First(model, d.GetId()).Error
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
err = errors.New("查看对象不存在或无权查看")
|
||||
e.Log.Errorf("Service GetSpiderListenSymbol error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Insert 创建SpiderListenSymbol对象
|
||||
func (e *SpiderListenSymbol) Insert(c *dto.SpiderListenSymbolInsertReq) error {
|
||||
var err error
|
||||
var data models.SpiderListenSymbol
|
||||
c.Generate(&data)
|
||||
err = e.Orm.Create(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("SpiderListenSymbolService Insert error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update 修改SpiderListenSymbol对象
|
||||
func (e *SpiderListenSymbol) Update(c *dto.SpiderListenSymbolUpdateReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var data = models.SpiderListenSymbol{}
|
||||
e.Orm.Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).First(&data, c.GetId())
|
||||
c.Generate(&data)
|
||||
|
||||
db := e.Orm.Save(&data)
|
||||
if err = db.Error; err != nil {
|
||||
e.Log.Errorf("SpiderListenSymbolService Save error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove 删除SpiderListenSymbol
|
||||
func (e *SpiderListenSymbol) Remove(d *dto.SpiderListenSymbolDeleteReq, p *actions.DataPermission) error {
|
||||
var data models.SpiderListenSymbol
|
||||
|
||||
db := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).Delete(&data, d.GetId())
|
||||
if err := db.Error; err != nil {
|
||||
e.Log.Errorf("Service RemoveSpiderListenSymbol error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权删除该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -404,6 +404,7 @@ func handleFutMainOrderFilled(db *gorm.DB, preOrder *models.LinePreOrder) {
|
||||
logger.Errorf("修改止盈止损数量失败 订单号:%s err:%v", order.OrderSn, err)
|
||||
}
|
||||
|
||||
logger.Errorf("止盈止损 下单数量:%v", num)
|
||||
switch order.OrderType {
|
||||
case 1: // 止盈
|
||||
processFutTakeProfitOrder(db, futApi, order, num)
|
||||
@ -446,13 +447,14 @@ func processFutReduceOrder(order DbModels.LinePreOrder, price, num decimal.Decim
|
||||
// 处理止盈订单
|
||||
func processFutTakeProfitOrder(db *gorm.DB, futApi FutRestApi, order models.LinePreOrder, num decimal.Decimal) {
|
||||
price, _ := decimal.NewFromString(order.Price)
|
||||
tradeSet, _ := GetTradeSet(order.Symbol, 1)
|
||||
|
||||
params := FutOrderPlace{
|
||||
ApiId: order.ApiId,
|
||||
Symbol: order.Symbol,
|
||||
Side: order.Site,
|
||||
Price: price,
|
||||
Quantity: num,
|
||||
Price: price.Truncate(int32(tradeSet.PriceDigit)),
|
||||
Quantity: num.Truncate(int32(tradeSet.AmountDigit)),
|
||||
OrderType: "TAKE_PROFIT",
|
||||
Profit: price,
|
||||
NewClientOrderId: order.OrderSn,
|
||||
@ -477,12 +479,14 @@ func processFutTakeProfitOrder(db *gorm.DB, futApi FutRestApi, order models.Line
|
||||
// 处理止损订单
|
||||
// order 止损单
|
||||
func processFutStopLossOrder(db *gorm.DB, order models.LinePreOrder, price, num decimal.Decimal) error {
|
||||
tradeSet, _ := GetTradeSet(order.Symbol, 1)
|
||||
|
||||
params := FutOrderPlace{
|
||||
ApiId: order.ApiId,
|
||||
Symbol: order.Symbol,
|
||||
Side: order.Site,
|
||||
Price: price,
|
||||
Quantity: num,
|
||||
Price: price.Truncate(int32(tradeSet.PriceDigit)),
|
||||
Quantity: num.Truncate(int32(tradeSet.AmountDigit)),
|
||||
OrderType: "STOP",
|
||||
StopPrice: price,
|
||||
NewClientOrderId: order.OrderSn,
|
||||
|
||||
Reference in New Issue
Block a user