1\交易对返回价格
This commit is contained in:
@ -199,7 +199,7 @@ func handleMainReduceFilled(db *gorm.DB, preOrder *DbModels.LinePreOrder) {
|
||||
takeProfitOrder.Rate = ext.ReduceTakeProfitRatio.String()
|
||||
//止盈需要累加之前的亏损
|
||||
if totalLossAmountU.Cmp(decimal.Zero) > 0 {
|
||||
percent := totalLossAmountU.Div(totalNum).Div(price).Sub(decimal.NewFromInt(1)).Abs()
|
||||
percent := totalLossAmountU.Div(totalNum).Div(price).Abs()
|
||||
takeProfitOrder.Rate = percent.Mul(decimal.NewFromInt(100)).Add(ext.ReduceTakeProfitRatio).Truncate(2).String()
|
||||
}
|
||||
|
||||
@ -252,6 +252,12 @@ func handleMainReduceFilled(db *gorm.DB, preOrder *DbModels.LinePreOrder) {
|
||||
}
|
||||
}
|
||||
|
||||
for _, item := range orders {
|
||||
if item.OrderType == 2 {
|
||||
processStopLossOrder(item)
|
||||
}
|
||||
}
|
||||
|
||||
//计算实际亏损
|
||||
if parentOrder.Price != "" {
|
||||
parentPrice := utility.StrToDecimal(parentOrder.Price)
|
||||
@ -734,7 +740,7 @@ func makeSpotTakeAndReduce(preOrder *DbModels.LinePreOrder, db *gorm.DB, tradeSe
|
||||
|
||||
//止盈需要累加之前的亏损
|
||||
if totalLossAmountU.Cmp(decimal.Zero) > 0 {
|
||||
percent := totalLossAmountU.Div(num).Div(price).Sub(decimal.NewFromInt(1)).Abs()
|
||||
percent := totalLossAmountU.Div(num).Div(price).Abs()
|
||||
profitOrder.Rate = percent.Mul(decimal.NewFromInt(100)).Add(ext.TakeProfitRatio).Truncate(2).String()
|
||||
}
|
||||
|
||||
@ -874,6 +880,7 @@ func processStopLossOrder(order models.LinePreOrder) error {
|
||||
price := utility.StrToDecimal(order.Price)
|
||||
stopLoss := dto.StopLossRedisList{
|
||||
Id: order.Id,
|
||||
MainId: order.MainId,
|
||||
PId: order.Pid,
|
||||
ApiId: order.ApiId,
|
||||
OrderTye: order.OrderType,
|
||||
|
||||
Reference in New Issue
Block a user