|
@@ -1,25 +1,33 @@
|
|
|
package pcsg
|
|
|
|
|
|
import (
|
|
|
+ "eta/eta_bridge/global"
|
|
|
"eta/eta_bridge/utils"
|
|
|
+ "fmt"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
+const (
|
|
|
+ TaskKey0000 = "IDpcsgDailySnap0000"
|
|
|
+ SubOneDayTaskKey = "IDpcsgDailySnap0330" // 日期-1的key
|
|
|
+)
|
|
|
+
|
|
|
// PythonBloombergGeneralData 通用数据格式(有空改成Map吧...然后做成配置方便加新字段...)
|
|
|
type PythonBloombergGeneralData struct {
|
|
|
- NAME string `json:"NAME" description:"指标名称, 可能为null"`
|
|
|
- IDENTIFIER string `json:"IDENTIFIER" description:"指标编码"`
|
|
|
- PX_LAST_EOD *float64 `json:"PX_LAST_EOD" description:"数据值, 可能为null"`
|
|
|
- PX_VOLUME_EOD *float64 `json:"PX_VOLUME_EOD" description:"数据值, 可能为null"`
|
|
|
- PX_LAST *float64 `json:"PX_LAST" description:"数据值, 可能为null"`
|
|
|
- PX_VOLUME *float64 `json:"PX_VOLUME" description:"数据值, 可能为null"`
|
|
|
- LAST_UPDATE_DATE_EOD string `json:"LAST_UPDATE_DATE_EOD" description:"数据日期, 可能为null"`
|
|
|
- DATE string `json:"DATE" description:"数据日期, 可能为null"`
|
|
|
- PX_SETTLE *float64 `json:"PX_SETTLE" description:"数据值, 可能为null"`
|
|
|
- PX_SETTLE_LAST_DT string `json:"PX_SETTLE_LAST_DT" description:"数据日期, 可能为null"`
|
|
|
- OPEN_INT *float64 `json:"OPEN_INT"`
|
|
|
- OPEN_INT_DATE string `json:"OPEN_INT_DATE"`
|
|
|
+ NAME string `json:"NAME" description:"指标名称, 可能为null"`
|
|
|
+ IDENTIFIER string `json:"IDENTIFIER" description:"指标编码"`
|
|
|
+ PX_LAST_EOD *float64 `json:"PX_LAST_EOD" description:"数据值, 可能为null"`
|
|
|
+ PX_VOLUME_EOD *float64 `json:"PX_VOLUME_EOD" description:"数据值, 可能为null"`
|
|
|
+ PX_LAST *float64 `json:"PX_LAST" description:"数据值, 可能为null"`
|
|
|
+ PX_VOLUME *float64 `json:"PX_VOLUME" description:"数据值, 可能为null"`
|
|
|
+ LAST_UPDATE_DATE_EOD string `json:"LAST_UPDATE_DATE_EOD" description:"数据日期"`
|
|
|
+ DATE string `json:"DATE" description:"数据日期"`
|
|
|
+ PX_SETTLE *float64 `json:"PX_SETTLE" description:"数据值, 可能为null"`
|
|
|
+ PX_SETTLE_LAST_DT string `json:"PX_SETTLE_LAST_DT" description:"数据日期"`
|
|
|
+ OPEN_INT *float64 `json:"OPEN_INT"`
|
|
|
+ OPEN_INT_DATE string `json:"OPEN_INT_DATE"`
|
|
|
+ DL_SNAPSHOT_START_TIME string `json:"DL_SNAPSHOT_START_TIME" description:"数据日期"`
|
|
|
}
|
|
|
|
|
|
// PythonBloombergGeneralResult API响应体
|
|
@@ -48,7 +56,7 @@ type BaseFromBloombergApiIndexData struct {
|
|
|
Value float64 `description:"数据值"`
|
|
|
}
|
|
|
|
|
|
-func FormatPythonBloombergGeneralData2Base(origin PythonBloombergGeneralData, frequency string) (item BaseFromBloombergApiIndexAndData) {
|
|
|
+func FormatPythonBloombergGeneralData2Base(origin PythonBloombergGeneralData, frequency, taskKey string) (item BaseFromBloombergApiIndexAndData) {
|
|
|
if origin.IDENTIFIER == "" {
|
|
|
return
|
|
|
}
|
|
@@ -85,6 +93,18 @@ func FormatPythonBloombergGeneralData2Base(origin PythonBloombergGeneralData, fr
|
|
|
dataTime, _ = time.ParseInLocation(utils.FormatDate, origin.OPEN_INT_DATE, time.Local)
|
|
|
val = origin.OPEN_INT
|
|
|
}
|
|
|
+ if (taskKey == TaskKey0000 || taskKey == SubOneDayTaskKey) && origin.DL_SNAPSHOT_START_TIME != "" && origin.PX_LAST != nil {
|
|
|
+ d, e := time.ParseInLocation("2006-01-02T15:04:05", origin.DL_SNAPSHOT_START_TIME, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ global.LOG.Info(fmt.Sprintf("DL_SNAPSHOT_START_TIME日期解析失败, %s", origin.DL_SNAPSHOT_START_TIME))
|
|
|
+ }
|
|
|
+ dataTime = d
|
|
|
+ // 这个任务日期需要-1
|
|
|
+ if taskKey == SubOneDayTaskKey {
|
|
|
+ dataTime = dataTime.AddDate(0, 0, -1)
|
|
|
+ }
|
|
|
+ val = origin.PX_LAST
|
|
|
+ }
|
|
|
if !dataTime.IsZero() && val != nil {
|
|
|
item.Data = append(item.Data, BaseFromBloombergApiIndexData{
|
|
|
DataTime: dataTime,
|