|
@@ -261,10 +261,10 @@ func GetProfitChartEdbData(baseEdbInfo *models.EdbInfo, zlFutureGoodEdbInfoList
|
|
|
// 特殊的商品期货合约(只有M+N的合约,没有固定日期的合约)
|
|
|
specialFutureGoodEdbInfoMap := make(map[int]map[int]*future_good.FutureGoodEdbInfo, 0)
|
|
|
|
|
|
- isAllChina := true // 是否都是国内的期货合约
|
|
|
+ hasChina := false // 是否包含国内的期货合约
|
|
|
for _, v := range zlFutureGoodEdbInfoList {
|
|
|
- if v.RegionType != "国内" {
|
|
|
- isAllChina = false
|
|
|
+ if v.RegionType == "国内" {
|
|
|
+ hasChina = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -283,7 +283,7 @@ func GetProfitChartEdbData(baseEdbInfo *models.EdbInfo, zlFutureGoodEdbInfoList
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- childFutureGoodEdbInfoMap, tmpMaxN, tmpErr := getProfitFutureGoodEdbInfoList(earliestDateTime, v, tmpFutureGoodEdbInfoList, isAllChina, monthNum)
|
|
|
+ childFutureGoodEdbInfoMap, tmpMaxN, tmpErr := getProfitFutureGoodEdbInfoList(earliestDateTime, v, tmpFutureGoodEdbInfoList, monthNum)
|
|
|
if tmpErr != nil {
|
|
|
err = tmpErr
|
|
|
return
|
|
@@ -322,6 +322,11 @@ func GetProfitChartEdbData(baseEdbInfo *models.EdbInfo, zlFutureGoodEdbInfoList
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 需求池604,只要包含了国内合约,最大必须是12期
|
|
|
+ if hasChina {
|
|
|
+ maxN = 12
|
|
|
+ }
|
|
|
+
|
|
|
// 找出所有的N值,并进行正序排列
|
|
|
dateList := make([]string, 0)
|
|
|
for _, n := range nMap {
|
|
@@ -567,7 +572,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) {
|
|
|
+func getProfitFutureGoodEdbInfoList(earliestDateTime time.Time, zlFutureGoodEdbInfo *future_good.FutureGoodEdbInfo, tmpFutureGoodEdbInfoList []*future_good.FutureGoodEdbInfo, monthNum int) (futureGoodEdbInfoDateMap map[string]*future_good.FutureGoodEdbInfo, newMaxN int, err error) {
|
|
|
maxN := 36 //最大36期合约
|
|
|
futureGoodEdbInfoList := make([]*future_good.FutureGoodEdbInfo, 0)
|
|
|
futureGoodEdbInfoDateMap = make(map[string]*future_good.FutureGoodEdbInfo)
|
|
@@ -632,7 +637,7 @@ func getProfitFutureGoodEdbInfoList(earliestDateTime time.Time, zlFutureGoodEdbI
|
|
|
// 如果(当前年-最新日期的年份) * 12个月 + (当前月-最新日期的月份) 小于总月份
|
|
|
tmpN := subYear*12 + subMonth
|
|
|
if tmpN < newMaxN {
|
|
|
- tmpDateTime := time.Date(v.Year, time.Month(v.Month), 0, 0, 0, 0, 0, time.Local)
|
|
|
+ tmpDateTime := time.Date(v.Year, time.Month(v.Month), 1, 0, 0, 0, 0, time.Local)
|
|
|
futureGoodEdbInfoDateMap[tmpDateTime.Format(utils.FormatYearMonthDate)] = v
|
|
|
if tmpN > newMaxN {
|
|
|
newMaxN = tmpN
|