Bladeren bron

头寸持仓均价增加一位小数

zhou.xiaoning 2 jaren geleden
bovenliggende
commit
c963530d43
1 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 2 2
      controllers/order/order.go

+ 2 - 2
controllers/order/order.go

@@ -228,9 +228,9 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 				// #96004 改为固定3位小数
 				// #3524 又改为跟商品价格小数位走 2022.04.07
 				// 运维提出, 不要四舍五入, 改为去尾法 2022.04.26
-				tradePosition.AveragePrice, _ = decimal.NewFromFloat(averagePrice).Truncate(int32(v.Decimalplace)).Float64()
+				tradePosition.AveragePrice, _ = decimal.NewFromFloat(averagePrice).Truncate(int32(v.Decimalplace + 1)).Float64()
 				tradePosition.PositionPL, tradePosition.MarketAmount, tradePosition.LastPrice = fCalcPL(tradePosition.GoodsCode, tradePosition.BuyOrSell, tradePosition.CurPositionQTY,
-					tradePosition.AveragePrice, tradePosition.AgreeUnit, tradePosition.DecimalPlace)
+					tradePosition.AveragePrice, tradePosition.AgreeUnit, tradePosition.DecimalPlace+1)
 				if tradePosition.CurHolderAmount > 1e-10 {
 					tradePosition.PositionPLRate = tradePosition.PositionPL / tradePosition.CurHolderAmount
 					tradePosition.PositionPLRate, _ = strconv.ParseFloat(utils.FormatFloat(tradePosition.PositionPLRate, 4), 64)