|
|
@@ -322,8 +322,21 @@ func QueryTSData(c *gin.Context) {
|
|
|
// FIXME: - 由于mtp2.0目前未同步外部交易所品种的当前交易日,
|
|
|
// 故通道交易的品种目前只能在交易系统的外部市场中获
|
|
|
// 取统一的交易日,后期应要求服务端同步外部数据
|
|
|
- marketRun, err := models.GetMarketRun(int(market.Marketid))
|
|
|
- if marketRun == nil {
|
|
|
+ // 2021.06.30 业务更新:15、97和99市场的行情交易日要从商品盘面中获取
|
|
|
+ quoteTradeDate := ""
|
|
|
+ if market.Trademode == 15 || market.Trademode == 97 || market.Trademode == 99 {
|
|
|
+ if quoteDays, err := models.GetQuoteDays("'" + req.GoodsCode + "'"); err == nil {
|
|
|
+ if len(quoteDays) > 0 {
|
|
|
+ quoteTradeDate = time.Unix(quoteDays[0].Exchangedate, 0).Format("20060102")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if marketRun, err := models.GetMarketRun(int(market.Marketid)); err == nil {
|
|
|
+ quoteTradeDate = marketRun.Tradedate2
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(quoteTradeDate) == 0 {
|
|
|
logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
|
|
|
appG.Response(http.StatusBadRequest, e.ERROR_GET_MARKETRUN_FAILED, nil)
|
|
|
return
|
|
|
@@ -332,7 +345,7 @@ func QueryTSData(c *gin.Context) {
|
|
|
// 获取目标品种的开休市计划
|
|
|
var runSteps []map[string]interface{}
|
|
|
// 通道交易外部市场开休市计划表 - QuoteSourceGroupRunStep; 其它市场的 - MarketRunStepDetail
|
|
|
- if market.Trademode == 15 {
|
|
|
+ if market.Trademode == 15 || market.Trademode == 97 || market.Trademode == 99 {
|
|
|
// 外部市场
|
|
|
sourceRunSteps, err := models.FindQuoteSourceGroupRunSteps(*goods)
|
|
|
if err != nil {
|
|
|
@@ -396,7 +409,7 @@ func QueryTSData(c *gin.Context) {
|
|
|
queryTSDataRsp := QueryTSDataRsp{
|
|
|
GoodsCode: goods.Goodscode,
|
|
|
OutGoodsCode: goods.Outgoodscode,
|
|
|
- TradeDate: marketRun.Tradedate2,
|
|
|
+ TradeDate: quoteTradeDate,
|
|
|
DecimalPlace: int(goods.Decimalplace),
|
|
|
PreSettle: preSettle,
|
|
|
}
|
|
|
@@ -405,7 +418,7 @@ func QueryTSData(c *gin.Context) {
|
|
|
// 这里有一个知识点:TRADEWEEKDAY 与 STARTWEEKDAY,以及 TRADEWEEKDAY 与 ENDWEEKDAY 之间相差最多一天(管理端限制),
|
|
|
// 所以目前并不支持正真的周五夜盘模式。我们在实现时不用做得太复杂。
|
|
|
// 当前交易日(周几)对应的开休市计划
|
|
|
- tradeDate, err := time.ParseInLocation("20060102", marketRun.Tradedate2, time.Local)
|
|
|
+ tradeDate, err := time.ParseInLocation("20060102", quoteTradeDate, time.Local)
|
|
|
if err != nil {
|
|
|
logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
|
|
|
appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
@@ -436,7 +449,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.Tradedate2, curWeekRunSteps[0]["starttime"].(string)), time.Local)
|
|
|
+ queryTSDataRsp.StartTime, _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", quoteTradeDate, curWeekRunSteps[0]["starttime"].(string)), time.Local)
|
|
|
if startInterval != 0 {
|
|
|
duration, _ := time.ParseDuration(fmt.Sprintf("%dh", startInterval*24))
|
|
|
queryTSDataRsp.StartTime = queryTSDataRsp.StartTime.Add(duration)
|
|
|
@@ -444,7 +457,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.Tradedate2, curWeekRunSteps[index]["endtime"].(string)), time.Local)
|
|
|
+ queryTSDataRsp.EndTime, _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", quoteTradeDate, curWeekRunSteps[index]["endtime"].(string)), time.Local)
|
|
|
if endInterval != 0 {
|
|
|
duration, _ := time.ParseDuration(fmt.Sprintf("%dh", endInterval*24))
|
|
|
queryTSDataRsp.EndTime = queryTSDataRsp.EndTime.Add(duration)
|
|
|
@@ -623,14 +636,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.Tradedate2, v["starttime"].(string)), time.Local)
|
|
|
+ v["start"], _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", quoteTradeDate, 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.Tradedate2, v["endtime"].(string)), time.Local)
|
|
|
+ v["end"], _ = time.ParseInLocation(timeFormat, fmt.Sprintf("%s %s", quoteTradeDate, v["endtime"].(string)), time.Local)
|
|
|
if endInterval != 0 {
|
|
|
duration, _ := time.ParseDuration(fmt.Sprintf("%dh", endInterval*24))
|
|
|
v["end"] = v["end"].(time.Time).Add(duration)
|