Bladeren bron

敞口变动量-0.00问题修改

zou.yingbin 4 jaren geleden
bovenliggende
commit
ea34513df1
5 gewijzigde bestanden met toevoegingen van 36 en 42 verwijderingen
  1. 4 8
      docs/docs.go
  2. 4 8
      docs/swagger.json
  3. 3 6
      docs/swagger.yaml
  4. 1 1
      models/ermcp3.go
  5. 24 19
      models/ermcpExposure.go

+ 4 - 8
docs/docs.go

@@ -17217,6 +17217,10 @@ var doc = `{
                     "description": "期初销售合同已定价数量",
                     "type": "number"
                 },
+                "OriTotalSpotQty": {
+                    "description": "期初现货总量",
+                    "type": "number"
+                },
                 "SellFutureQty": {
                     "description": "卖出期货数量",
                     "type": "number"
@@ -17301,14 +17305,6 @@ var doc = `{
                     "description": "应套保量",
                     "type": "number"
                 },
-                "oriTotalFutuQty": {
-                    "description": "期初期货数量=期初买入期货数量-期初卖出期货数量",
-                    "type": "number"
-                },
-                "oriTotalSpotQty": {
-                    "description": "期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)",
-                    "type": "number"
-                },
                 "oriarbitrageqty": {
                     "description": "期初套利量",
                     "type": "number"

+ 4 - 8
docs/swagger.json

@@ -17201,6 +17201,10 @@
                     "description": "期初销售合同已定价数量",
                     "type": "number"
                 },
+                "OriTotalSpotQty": {
+                    "description": "期初现货总量",
+                    "type": "number"
+                },
                 "SellFutureQty": {
                     "description": "卖出期货数量",
                     "type": "number"
@@ -17285,14 +17289,6 @@
                     "description": "应套保量",
                     "type": "number"
                 },
-                "oriTotalFutuQty": {
-                    "description": "期初期货数量=期初买入期货数量-期初卖出期货数量",
-                    "type": "number"
-                },
-                "oriTotalSpotQty": {
-                    "description": "期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)",
-                    "type": "number"
-                },
                 "oriarbitrageqty": {
                     "description": "期初套利量",
                     "type": "number"

+ 3 - 6
docs/swagger.yaml

@@ -2254,6 +2254,9 @@ definitions:
       OriSellPricedQty:
         description: 期初销售合同已定价数量
         type: number
+      OriTotalSpotQty:
+        description: 期初现货总量
+        type: number
       SellFutureQty:
         description: 卖出期货数量
         type: number
@@ -2317,12 +2320,6 @@ definitions:
       needhedgeqty:
         description: 应套保量
         type: number
-      oriTotalFutuQty:
-        description: 期初期货数量=期初买入期货数量-期初卖出期货数量
-        type: number
-      oriTotalSpotQty:
-        description: 期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)
-        type: number
       oriarbitrageqty:
         description: 期初套利量
         type: number

+ 1 - 1
models/ermcp3.go

@@ -1206,7 +1206,7 @@ func (r *Ermcp3AreaSpot) calc() {
 
 func (r *Ermcp3AreaSpot) buildSql() string {
 
-	// 2021.11.22  现货量都一样,取其中一条即可, 加distinctf去重, by deng.yinping
+	// 2021.11.22  现货量都一样,取其中一条即可, 加distinct去重, by deng.yinping
 	var sqlId utils.SQLVal = `
 select distinct t.AREAUSERID,
        t.ORIBUYPLANQTY,

+ 24 - 19
models/ermcpExposure.go

@@ -55,32 +55,36 @@ type ErmcpRealExposureModel struct {
 	ORITOTALFUTUREQTY     float64 `json:"oritotalfutureqty"  xorm:"'ORITOTALFUTUREQTY'"`         // 期初期货总量
 	ORINEEDHEDGEEXPOSOURE float64 `json:"orineedhedgeexposoure"  xorm:"'ORINEEDHEDGEEXPOSOURE'"` // 期初套保敞口
 	ORITOTALEXPOSURE      float64 `json:"oritotalexposure"  xorm:"'ORITOTALEXPOSURE'"`           // 期初总敞口
+	ORITOTALSPOTQTY       float64 `json:"OriTotalSpotQty"  xorm:"'ORITOTALSPOTQTY'"`             // 期初现货总量
 
-	ENUMDICNAME     string  // 单位名称
-	OriTotalSpotQty float64 // 期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)
-	OriTotalFutuQty float64 // 期初期货数量=期初买入期货数量-期初卖出期货数量
-	DiffSpotQty     float64 // 变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动
-	DiffFutuQty     float64 // 变动量(期货总量) 平安:保值净持仓量今日变动
+	ENUMDICNAME string   // 单位名称
+	DiffSpotQty SFLOAT64 // 变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动
+	DiffFutuQty SFLOAT64 // 变动量(期货总量) 平安:保值净持仓量今日变动
 
-	DiffHedgeQty     float64 // 套保变动量
-	DiffArbitrageQty float64 // 套利变动量
-	DiffSpotHedgeQty float64 // 变动量(现货应套保总量) 平安:应套保量今日变动
-	DiffExposoureQty float64 // 变动量(套保敞口)
-	DiffQty          float64 // 变动量(总敞口) 平安:净敞口今日变动
+	DiffHedgeQty     SFLOAT64 // 套保变动量
+	DiffArbitrageQty SFLOAT64 // 套利变动量
+	DiffSpotHedgeQty SFLOAT64 // 变动量(现货应套保总量) 平安:应套保量今日变动
+	DiffExposoureQty SFLOAT64 // 变动量(套保敞口)
+	DiffQty          SFLOAT64 // 变动量(总敞口) 平安:净敞口今日变动
 
 }
 
 // calc 计算相关字段
 func (r *ErmcpRealExposureModel) calc() {
-	r.OriTotalSpotQty = (r.OriSellPlanQty - r.OriSellPricedQty) - (r.OriBuyPlanQty - r.OriBuyPricedQty)
-	r.OriTotalFutuQty = r.OriBuyFutureQty - r.OriSellFutureQty
-	r.DiffSpotQty = r.TotalSpotQty - r.OriTotalSpotQty
-	r.DiffFutuQty = r.TotalFutureQty - r.ORITOTALFUTUREQTY
-	r.DiffHedgeQty = r.HEDGEQTY - r.ORIHEDGEQTY
-	r.DiffArbitrageQty = r.ARBITRAGEQTY - r.ORIARBITRAGEQTY
-	r.DiffSpotHedgeQty = r.TotalNeedHedgeQty - r.ORITOTALNEEDHEDGEQTY
-	r.DiffExposoureQty = r.NeedHedgeExposoure - r.ORINEEDHEDGEEXPOSOURE
-	r.DiffQty = r.TotalExposure - r.ORITOTALEXPOSURE
+	r.DiffSpotQty.Set(r.TotalSpotQty - r.ORITOTALSPOTQTY)
+	r.DiffSpotQty.Round(2)
+	r.DiffFutuQty.Set(r.TotalFutureQty - r.ORITOTALFUTUREQTY)
+	r.DiffFutuQty.Round(2)
+	r.DiffHedgeQty.Set(r.HEDGEQTY - r.ORIHEDGEQTY)
+	r.DiffHedgeQty.Round(2)
+	r.DiffArbitrageQty.Set(r.ARBITRAGEQTY - r.ORIARBITRAGEQTY)
+	r.DiffArbitrageQty.Round(2)
+	r.DiffSpotHedgeQty.Set(r.TotalNeedHedgeQty - r.ORITOTALNEEDHEDGEQTY)
+	r.DiffSpotHedgeQty.Round(2)
+	r.DiffExposoureQty.Set(r.NeedHedgeExposoure - r.ORINEEDHEDGEEXPOSOURE)
+	r.DiffExposoureQty.Round(2)
+	r.DiffQty.Set(r.TotalExposure - r.ORITOTALEXPOSURE)
+	r.DiffQty.Round(2)
 
 	if r.ENUMDICNAME == "" {
 		r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODSUNITID)
@@ -123,6 +127,7 @@ func (r *ErmcpRealExposureModel) buildSql() string {
 		"       t.oritotalfutureqty," +
 		"       t.orineedhedgeexposoure," +
 		"       t.oritotalexposure," +
+		"       t.ORITOTALSPOTQTY," +
 		"       g.needarbitrageratio" +
 		"  from ermcp_areaexposure t" +
 		"  left join erms_middlegoods g" +