|
|
@@ -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" +
|