|
@@ -1322,3 +1322,48 @@ func RefreshBaseDataFromSource(wg *sync.WaitGroup, source int) (err error) {
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+// RefreshDataFromTradeAnalysis 刷新持仓分析指标
|
|
|
+func RefreshDataFromTradeAnalysis(wg *sync.WaitGroup) (err error) {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("持仓分析指标刷新开始: %s", time.Now().Format(utils.FormatDateTime)))
|
|
|
+ errMsgList := make([]string, 0)
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ tips := fmt.Sprintf("RefreshDataFromTradeAnalysis err: %v", err)
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ go alarm_msg.SendAlarmMsg(tips, 3)
|
|
|
+ }
|
|
|
+ if len(errMsgList) > 0 {
|
|
|
+ tips := fmt.Sprintf("RefreshDataFromTradeAnalysis ErrMsg: %s", strings.Join(errMsgList, "\n"))
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ go alarm_msg.SendAlarmMsg(tips, 3)
|
|
|
+ }
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND source = ? AND no_update = 0 `
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_TRADE_ANALYSIS)
|
|
|
+ items, e := data_manage.GetEdbInfoByCondition(condition, pars, 0)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("获取持仓分析指标失败, %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range items {
|
|
|
+ // 持仓分析指标只有日度
|
|
|
+ startDate := v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
|
|
|
+ resp, e := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
|
|
|
+ if e != nil {
|
|
|
+ errMsgList = append(errMsgList, fmt.Sprintf("EdbCode: %s, RefreshEdbData err: %v", v.EdbCode, e))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if resp.Ret != 200 {
|
|
|
+ errMsgList = append(errMsgList, fmt.Sprintf("EdbCode: %s, RefreshEdbData err: %v, errMsg: %s", v.EdbCode, e, resp.ErrMsg))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("持仓分析指标刷新结束: %s", time.Now().Format(utils.FormatDateTime)))
|
|
|
+ return err
|
|
|
+}
|