|
@@ -14,11 +14,21 @@ import (
|
|
|
// InitPositionTask 统计今日交易所的持仓分析数据
|
|
|
func InitPositionTask(cont context.Context) (err error) {
|
|
|
exchanges := []string{"zhengzhou", "dalian", "shanghai", "cffex", "ine", "guangzhou"} //郑商所,大商所,上期所,中金所,上期能源,广期所
|
|
|
- for i := 2; i >= 0; i-- {
|
|
|
- startDate := time.Now().AddDate(0, 0, -i).Format(utils.FormatDate)
|
|
|
- endDate := startDate
|
|
|
- for _, v := range exchanges {
|
|
|
- exchange := v
|
|
|
+ for _, v := range exchanges {
|
|
|
+ exchange := v
|
|
|
+ startDateT, e := data_manage.GetTradePositionTopLastedDataTime(exchange)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println("InitPositionTask: 获取最后一条数据失败:" + e.Error())
|
|
|
+ utils.FileLog.Info("InitPositionTask: 获取最后一条数据失败:" + e.Error())
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 从最新数据的两天开始更新
|
|
|
+ startDateT = startDateT.AddDate(0, 0, -2)
|
|
|
+
|
|
|
+ todayDateT, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
|
|
|
+ for ; startDateT.Before(todayDateT) || startDateT.Equal(todayDateT); startDateT = startDateT.AddDate(0, 0, 1) {
|
|
|
+ startDate := startDateT.Format(utils.FormatDate)
|
|
|
+ endDate := startDate
|
|
|
err = nil
|
|
|
fmt.Println("InitPositionTask: 启动:" + exchange)
|
|
|
utils.FileLog.Info("InitPositionTask: 启动:" + exchange)
|