|
@@ -756,7 +756,7 @@ type ErmcpExposurePostion struct {
|
|
|
DiffHedgeQty float64 `json:"diffhedgeqty" xorm:"'DiffHedgeQty'"` // 套保品种变动量=持仓变动量*期货合约单位*期货品种系数
|
|
DiffHedgeQty float64 `json:"diffhedgeqty" xorm:"'DiffHedgeQty'"` // 套保品种变动量=持仓变动量*期货合约单位*期货品种系数
|
|
|
AGREEUNIT string `json:"agreeunit"` // 合约单位
|
|
AGREEUNIT string `json:"agreeunit"` // 合约单位
|
|
|
CONVERTRATIO float64 `json:"convertratio"` // 期货品种系数(折算系数)
|
|
CONVERTRATIO float64 `json:"convertratio"` // 期货品种系数(折算系数)
|
|
|
- ACCOUNTID int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 资金账号(只有外部账号才有值, 内部账号是根据userid汇总的)
|
|
|
|
|
|
|
+ ACCOUNTID int64 `json:"-" xorm:"'ACCOUNTID'"` // 资金账号(只有外部账号才有值, 内部账号是根据userid汇总的)
|
|
|
HEDGEACCOUNTCODE string `json:"hedgeaccountcode" xorm:"'HEDGEACCOUNTCODE'"` // 对冲账号(只有外部账号才有值)
|
|
HEDGEACCOUNTCODE string `json:"hedgeaccountcode" xorm:"'HEDGEACCOUNTCODE'"` // 对冲账号(只有外部账号才有值)
|
|
|
|
|
|
|
|
MIDDLEGOODSNAME string `json:"middlegoodsname" xorm:"'MIDDLEGOODSNAME'"` // 套保商品名称
|
|
MIDDLEGOODSNAME string `json:"middlegoodsname" xorm:"'MIDDLEGOODSNAME'"` // 套保商品名称
|
|
@@ -826,10 +826,24 @@ func (r *ErmcpExposurePostion) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 合并处理
|
|
// 合并处理
|
|
|
|
|
+ LOOP1:
|
|
|
for i := range sPostion {
|
|
for i := range sPostion {
|
|
|
if val, ok := sGoods[sPostion[i].HEDGEGOODSID]; ok {
|
|
if val, ok := sGoods[sPostion[i].HEDGEGOODSID]; ok {
|
|
|
d := ErmcpExposurePostion{}
|
|
d := ErmcpExposurePostion{}
|
|
|
d.ParseFromHedgePos(val, &sPostion[i])
|
|
d.ParseFromHedgePos(val, &sPostion[i])
|
|
|
|
|
+ // 如果已存在此合约,则把相关数据合并
|
|
|
|
|
+ for j, item := range sData {
|
|
|
|
|
+ if item.GOODSID == d.GOODSID {
|
|
|
|
|
+ srcData := &sData[j]
|
|
|
|
|
+ srcData.YdQty += d.YdQty
|
|
|
|
|
+ srcData.CurQty += d.CurQty
|
|
|
|
|
+ srcData.DiffQty += d.DiffQty
|
|
|
|
|
+ srcData.DiffHedgeQty += d.DiffHedgeQty
|
|
|
|
|
+ srcData.CurHedgeQty += d.CurHedgeQty
|
|
|
|
|
+
|
|
|
|
|
+ continue LOOP1
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
sData = append(sData, d)
|
|
sData = append(sData, d)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -840,11 +854,25 @@ func (r *ErmcpExposurePostion) GetDataEx() (interface{}, error) {
|
|
|
if err1 != nil || sPostion == nil || len(sPostion) == 0 {
|
|
if err1 != nil || sPostion == nil || len(sPostion) == 0 {
|
|
|
return sData, err1
|
|
return sData, err1
|
|
|
}
|
|
}
|
|
|
|
|
+ LOOP2:
|
|
|
// 合并处理
|
|
// 合并处理
|
|
|
for i := range sPostion {
|
|
for i := range sPostion {
|
|
|
if val, ok := sGoods[sPostion[i].GOODSID]; ok {
|
|
if val, ok := sGoods[sPostion[i].GOODSID]; ok {
|
|
|
d := ErmcpExposurePostion{}
|
|
d := ErmcpExposurePostion{}
|
|
|
d.ParseFromPos(val, &sPostion[i])
|
|
d.ParseFromPos(val, &sPostion[i])
|
|
|
|
|
+ // 如果已存在此合约,则把相关数据合并
|
|
|
|
|
+ for j, item := range sData {
|
|
|
|
|
+ if item.GOODSID == d.GOODSID {
|
|
|
|
|
+ srcData := &sData[j]
|
|
|
|
|
+ srcData.YdQty += d.YdQty
|
|
|
|
|
+ srcData.CurQty += d.CurQty
|
|
|
|
|
+ srcData.DiffQty += d.DiffQty
|
|
|
|
|
+ srcData.DiffHedgeQty += d.DiffHedgeQty
|
|
|
|
|
+ srcData.CurHedgeQty += d.CurHedgeQty
|
|
|
|
|
+
|
|
|
|
|
+ continue LOOP2
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
sData = append(sData, d)
|
|
sData = append(sData, d)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|