Selaa lähdekoodia

Merge branch 'master' of 192.168.30.132:MTP2.0/MTP20_IF

zou.yingbin 4 vuotta sitten
vanhempi
commit
f41db238fc
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. 12 0
      controllers/ermcp/qryOrder.go

+ 12 - 0
controllers/ermcp/qryOrder.go

@@ -124,6 +124,7 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				item.Outgoodscode = goods.Outgoodscode
 				item.Goodsname = goods.Goodsname
 				item.Agreeunit = goods.Agreeunit
+				item.Decimalplace = goods.Decimalplace
 				// 获取对应外部交易所名称
 				exchange, err := models.GetExternalexchangeByGoodsGroupID(int(goods.Goodsgroupid))
 				if err != nil {
@@ -164,10 +165,12 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				// 盯市浮盈【实时行情更新】(MTP:浮动盈亏、持仓盈亏) 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.PositionPL = (item.Last - item.PositionAveragePrice) * float64(v.Curbuyposition) * goods.Agreeunit
+					item.PositionPL, _ = strconv.ParseFloat(utils.FormatFloat(item.PositionPL, 2), 64)
 				}
 				// 逐笔浮盈【实时行情更新】(MTP:开仓盈亏、平仓盈亏) 买方向 = (最新价 - 开仓均价) * 买期末头寸 * 合约单位;卖方向 = (开仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.OpenPL = (item.Last - item.OpenAveragePrice) * float64(v.Curbuyposition) * goods.Agreeunit
+					item.OpenPL, _ = strconv.ParseFloat(utils.FormatFloat(item.OpenPL, 2), 64)
 				}
 				// 持仓盈亏比例 = 持仓盈亏 / 开仓成本
 				if item.PositionPL != 0 && v.Buyopencost != 0 {
@@ -208,6 +211,7 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				item.Outgoodscode = goods.Outgoodscode
 				item.Goodsname = goods.Goodsname
 				item.Agreeunit = goods.Agreeunit
+				item.Decimalplace = goods.Decimalplace
 				// 获取对应外部交易所名称
 				exchange, err := models.GetExternalexchangeByGoodsGroupID(int(goods.Goodsgroupid))
 				if err != nil {
@@ -248,10 +252,12 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				// 盯市浮盈【实时行情更新】(MTP:浮动盈亏、持仓盈亏) 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.PositionPL = (item.PositionAveragePrice - item.Last) * float64(v.Cursellposition) * goods.Agreeunit
+					item.PositionPL, _ = strconv.ParseFloat(utils.FormatFloat(item.PositionPL, 2), 64)
 				}
 				// 逐笔浮盈【实时行情更新】(MTP:开仓盈亏、平仓盈亏) 买方向 = (最新价 - 开仓均价) * 买期末头寸 * 合约单位;卖方向 = (开仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.OpenPL = (item.OpenAveragePrice - item.Last) * float64(v.Cursellposition) * goods.Agreeunit
+					item.OpenPL, _ = strconv.ParseFloat(utils.FormatFloat(item.OpenPL, 2), 64)
 				}
 				// 持仓盈亏比例 = 持仓盈亏 / 开仓成本
 				if item.PositionPL != 0 && v.Sellopencost != 0 {
@@ -314,6 +320,7 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				item.Outgoodscode = goods.Outgoodscode
 				item.Goodsname = goods.Goodsname
 				item.Agreeunit = goods.Agreeunit
+				item.Decimalplace = goods.Decimalplace
 				// 获取对应外部交易所名称
 				exchange, err := models.GetExternalexchangeByGoodsGroupID(int(goods.Goodsgroupid))
 				if err != nil {
@@ -361,10 +368,12 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				// 盯市浮盈【实时行情更新】(MTP:浮动盈亏、持仓盈亏) 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.PositionPL = (item.Last - item.PositionAveragePrice) * float64(v.Buycurpositionqty) * goods.Agreeunit
+					item.PositionPL, _ = strconv.ParseFloat(utils.FormatFloat(item.PositionPL, 2), 64)
 				}
 				// 逐笔浮盈【实时行情更新】(MTP:开仓盈亏、平仓盈亏) 买方向 = (最新价 - 开仓均价) * 买期末头寸 * 合约单位;卖方向 = (开仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.OpenPL = (item.Last - item.OpenAveragePrice) * float64(v.Buycurpositionqty) * goods.Agreeunit
+					item.OpenPL, _ = strconv.ParseFloat(utils.FormatFloat(item.OpenPL, 2), 64)
 				}
 				// 持仓盈亏比例 = 持仓盈亏 / 开仓成本
 				if item.PositionPL != 0 && item.OpenCost != 0 {
@@ -415,6 +424,7 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				item.Outgoodscode = goods.Outgoodscode
 				item.Goodsname = goods.Goodsname
 				item.Agreeunit = goods.Agreeunit
+				item.Decimalplace = goods.Decimalplace
 				// 获取对应外部交易所名称
 				exchange, err := models.GetExternalexchangeByGoodsGroupID(int(goods.Goodsgroupid))
 				if err != nil {
@@ -462,10 +472,12 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				// 盯市浮盈【实时行情更新】(MTP:浮动盈亏、持仓盈亏) 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.PositionPL = (item.PositionAveragePrice - item.Last) * float64(v.Sellcurpositionqty) * goods.Agreeunit
+					item.PositionPL, _ = strconv.ParseFloat(utils.FormatFloat(item.PositionPL, 2), 64)
 				}
 				// 逐笔浮盈【实时行情更新】(MTP:开仓盈亏、平仓盈亏) 买方向 = (最新价 - 开仓均价) * 买期末头寸 * 合约单位;卖方向 = (开仓均价 - 最新价) * 卖期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.OpenPL = (item.OpenAveragePrice - item.Last) * float64(v.Sellcurpositionqty) * goods.Agreeunit
+					item.OpenPL, _ = strconv.ParseFloat(utils.FormatFloat(item.OpenPL, 2), 64)
 				}
 				// 持仓盈亏比例 = 持仓盈亏 / 开仓成本
 				if item.PositionPL != 0 && item.OpenCost != 0 {