Roc 1 year ago
parent
commit
5fdaa438e8
1 changed files with 14 additions and 9 deletions
  1. 14 9
      logic/profit_chart_info.go

+ 14 - 9
logic/profit_chart_info.go

@@ -562,7 +562,7 @@ func ProfitChartChartData(baseDataList []*models.EdbDataList, futureGoodEdbInfoM
 
 // getFutureGoodEdbInfoList 获取适用的指标列表
 func getProfitFutureGoodEdbInfoList(earliestDateTime time.Time, zlFutureGoodEdbInfo *future_good.FutureGoodEdbInfo, tmpFutureGoodEdbInfoList []*future_good.FutureGoodEdbInfo, isAllChina bool, monthNum int) (futureGoodEdbInfoDateMap map[string]*future_good.FutureGoodEdbInfo, newMaxN int, err error) {
-	maxM := 32 //最大32期合约
+	maxN := 36 //最大36期合约
 	futureGoodEdbInfoList := make([]*future_good.FutureGoodEdbInfo, 0)
 	futureGoodEdbInfoDateMap = make(map[string]*future_good.FutureGoodEdbInfo)
 
@@ -580,12 +580,14 @@ func getProfitFutureGoodEdbInfoList(earliestDateTime time.Time, zlFutureGoodEdbI
 
 		lenFutureGoodEdbInfoList := len(futureGoodEdbInfoList)
 		//futureGoodEdbInfoList
-		if isAllChina {
-			// 如果全是国内指标,那么只需要拼上多出的几期合约即可
-			maxM = lenFutureGoodEdbInfoList + monthNum
-		}
-
-		for i := 1; i < maxM; i++ {
+		//if isAllChina {
+		//	// 如果全是国内指标,那么只需要拼上多出的几期合约即可
+		//	maxN = lenFutureGoodEdbInfoList + monthNum
+		//}
+		// 如果全是国内指标,那么只需要拼上多出的几期合约即可
+		maxN = lenFutureGoodEdbInfoList + monthNum
+
+		for i := 1; i < maxN; i++ {
 			k := i % lenFutureGoodEdbInfoList
 			futureGoodEdbInfoDateMap[earliestDateTime.AddDate(0, i, 0).Format(utils.FormatYearMonthDate)] = futureGoodEdbInfoList[k]
 			if i > newMaxN {
@@ -593,13 +595,16 @@ func getProfitFutureGoodEdbInfoList(earliestDateTime time.Time, zlFutureGoodEdbI
 			}
 		}
 
+		//需求池604,只要是国内合约,最大必须是12期
+		newMaxN = 12
+
 		return
 	}
 
 	for _, v := range tmpFutureGoodEdbInfoList {
 		//海外的连续日期,目前
 		if v.FutureGoodEdbType == 2 {
-			if v.Month <= maxM {
+			if v.Month <= newMaxN {
 				futureGoodEdbInfoDateMap[earliestDateTime.AddDate(0, v.Month, 0).Format(utils.FormatYearMonthDate)] = v
 				if v.Month > newMaxN {
 					newMaxN = v.Month
@@ -620,7 +625,7 @@ func getProfitFutureGoodEdbInfoList(earliestDateTime time.Time, zlFutureGoodEdbI
 		subMonth := v.Month - int(earliestDateTime.Month())
 		// 如果(当前年-最新日期的年份) * 12个月 + (当前月-最新日期的月份) 小于总月份
 		tmpN := subYear*12 + subMonth
-		if tmpN < maxM {
+		if tmpN < newMaxN {
 			earliestDateTime = time.Date(v.Year, time.Month(v.Month), 0, 0, 0, 0, 0, time.Local)
 			futureGoodEdbInfoDateMap[earliestDateTime.Format(utils.FormatYearMonthDate)] = v
 			if tmpN > newMaxN {