Forráskód Böngészése

分时图数据使用行情交易日(TradeDate2)作为查询条件

zhou.xiaoning 4 éve
szülő
commit
bc276f588e
1 módosított fájl, 8 hozzáadás és 7 törlés
  1. 8 7
      controllers/quote/history.go

+ 8 - 7
controllers/quote/history.go

@@ -256,7 +256,7 @@ type QueryTSDataRsp struct {
 	TradeDate    string        `json:"tradeDate"`    // 交易日
 	StartTime    time.Time     `json:"startTime"`    // 开始时间
 	EndTime      time.Time     `json:"endTime"`      // 结束时间
-	PreSettle    float64       `json:"preSettle"`    // 昨结
+	PreSettle    float64       `json:"preSettle"`    // 昨结
 	HistoryDatas []HistoryData `json:"historyDatas"` // 历史数据
 }
 
@@ -374,10 +374,11 @@ func QueryTSData(c *gin.Context) {
 	}
 
 	// 构建返回数据
+	// 注意:这里使用的是 marketRun.Tradedate2 行情交易日
 	queryTSDataRsp := QueryTSDataRsp{
 		GoodsCode:    goods.Goodscode,
 		OutGoodsCode: goods.Outgoodscode,
-		TradeDate:    marketRun.Tradedate,
+		TradeDate:    marketRun.Tradedate2,
 		DecimalPlace: int(goods.Decimalplace),
 		PreSettle:    preSettle,
 	}
@@ -386,7 +387,7 @@ func QueryTSData(c *gin.Context) {
 	// 这里有一个知识点:TRADEWEEKDAY 与 STARTWEEKDAY,以及 TRADEWEEKDAY 与 ENDWEEKDAY 之间相差最多一天(管理端限制),
 	//                所以目前并不支持正真的周五夜盘模式。我们在实现时不用做得太复杂。
 	// 当前交易日(周几)对应的开休市计划
-	tradeDate, err := time.ParseInLocation("20060102", marketRun.Tradedate, time.Local)
+	tradeDate, err := time.ParseInLocation("20060102", marketRun.Tradedate2, time.Local)
 	if err != nil {
 		logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
@@ -417,7 +418,7 @@ func QueryTSData(c *gin.Context) {
 	timeFormat := "20060102 15:04"
 	// 开始时间
 	startInterval := getTradeDay(int(curWeekRunSteps[0]["tradeweekday"].(float64)), int(curWeekRunSteps[0]["startweekday"].(float64)))
-	queryTSDataRsp.StartTime, _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate, curWeekRunSteps[0]["starttime"].(string)), time.Local)
+	queryTSDataRsp.StartTime, _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate2, curWeekRunSteps[0]["starttime"].(string)), time.Local)
 	if startInterval != 0 {
 		duration, _ := time.ParseDuration(fmt.Sprintf("%dh", startInterval*24))
 		queryTSDataRsp.StartTime = queryTSDataRsp.StartTime.Add(duration)
@@ -425,7 +426,7 @@ func QueryTSData(c *gin.Context) {
 	// 结束时间
 	index := len(curWeekRunSteps) - 1
 	endInterval := getTradeDay(int(curWeekRunSteps[index]["tradeweekday"].(float64)), int(curWeekRunSteps[index]["endweekday"].(float64)))
-	queryTSDataRsp.EndTime, _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate, curWeekRunSteps[index]["endtime"].(string)), time.Local)
+	queryTSDataRsp.EndTime, _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate2, curWeekRunSteps[index]["endtime"].(string)), time.Local)
 	if endInterval != 0 {
 		duration, _ := time.ParseDuration(fmt.Sprintf("%dh", endInterval*24))
 		queryTSDataRsp.EndTime = queryTSDataRsp.EndTime.Add(duration)
@@ -601,14 +602,14 @@ func QueryTSData(c *gin.Context) {
 	for _, v := range curWeekRunSteps {
 		// 开始时间
 		startInterval := getTradeDay(int(v["tradeweekday"].(float64)), int(v["startweekday"].(float64)))
-		v["start"], _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate, v["starttime"].(string)), time.Local)
+		v["start"], _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate2, v["starttime"].(string)), time.Local)
 		if startInterval != 0 {
 			duration, _ := time.ParseDuration(fmt.Sprintf("%dh", startInterval*24))
 			v["start"] = v["start"].(time.Time).Add(duration)
 		}
 		// 结束时间
 		endInterval := getTradeDay(int(v["tradeweekday"].(float64)), int(v["endweekday"].(float64)))
-		v["end"], _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate, v["endtime"].(string)), time.Local)
+		v["end"], _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", marketRun.Tradedate2, v["endtime"].(string)), time.Local)
 		if endInterval != 0 {
 			duration, _ := time.ParseDuration(fmt.Sprintf("%dh", endInterval*24))
 			v["end"] = v["end"].(time.Time).Add(duration)