浏览代码

Merge branch 'feature/pscg_edb' of eta_server/eta_bridge into master

xyxie 3 月之前
父节点
当前提交
003950a82b
共有 2 个文件被更改,包括 49 次插入2 次删除
  1. 32 0
      models/pcsg/bloomberg.go
  2. 17 2
      services/index_data/pcsg_bloomberg.go

+ 32 - 0
models/pcsg/bloomberg.go

@@ -194,3 +194,35 @@ func FormatPythonBloombergDailyRun11Data2Base(origin PythonBloombergGeneralData,
 	items = append(items, item, itemHDD, itemCDD)
 	return
 }
+
+func FormatPythonBloombergDailyRunHistV1Data2Base(origin PythonBloombergGeneralData, frequency, taskKey string) (item BaseFromBloombergApiIndexAndData) {
+	if origin.IDENTIFIER == "" {
+		return
+	}
+
+	item.IndexCode = strings.TrimSpace(origin.IDENTIFIER)
+	if item.IndexCode == "TZT1 COMB Comdty" {
+		item.IndexCode = "TZT1 COMB V Comdty"
+	}
+	item.IndexName = strings.TrimSpace(origin.NAME)
+	item.Frequency = frequency
+	item.Unit = "无"
+	item.Data = make([]BaseFromBloombergApiIndexData, 0)
+
+	// 数据来源的值和日期对应字段不同
+	var dataTime time.Time
+	var val *float64
+
+	if origin.DATE != "" && origin.PX_VOLUME != nil {
+		dataTime, _ = time.ParseInLocation(utils.FormatDate, origin.DATE, time.Local)
+		val = origin.PX_VOLUME
+	}
+
+	if !dataTime.IsZero() && val != nil {
+		item.Data = append(item.Data, BaseFromBloombergApiIndexData{
+			DataTime: dataTime,
+			Value:    *val,
+		})
+	}
+	return
+}

+ 17 - 2
services/index_data/pcsg_bloomberg.go

@@ -20,15 +20,30 @@ func GetPCSGBloombergGeneralIndex(taskKey, frequency string) (indexes []pcsg.Bas
 		return
 	}
 	for _, v := range apiData {
-		if taskKey == "IDpcsgDailyRun11" {
+		switch taskKey {
+		case "IDpcsgDailyRun11":
 			tList := pcsg.FormatPythonBloombergDailyRun11Data2Base(v, frequency, taskKey)
 			indexes = append(indexes, tList...)
-		} else {
+		case "IDpcsgDailyRunHistV1":
+			t := pcsg.FormatPythonBloombergDailyRunHistV1Data2Base(v, frequency, taskKey)
+			if t.IndexCode != "" {
+				indexes = append(indexes, t)
+			}
+		default:
 			t := pcsg.FormatPythonBloombergGeneralData2Base(v, frequency, taskKey)
 			if t.IndexCode != "" {
 				indexes = append(indexes, t)
 			}
 		}
+		/*if taskKey == "IDpcsgDailyRun11" {
+			tList := pcsg.FormatPythonBloombergDailyRun11Data2Base(v, frequency, taskKey)
+			indexes = append(indexes, tList...)
+		} else {
+			t := pcsg.FormatPythonBloombergGeneralData2Base(v, frequency, taskKey)
+			if t.IndexCode != "" {
+				indexes = append(indexes, t)
+			}
+		}*/
 	}
 	return
 }