|
@@ -145,146 +145,6 @@ func FormatCompanyTradeData2EdbMappings(companyTradeData []*tradeAnalysisModel.C
|
|
|
}
|
|
|
|
|
|
func GetWarehouseTradeData(exchange, classifyName string, contracts, companies []string, predictRatio float64) (companyTradeData []*tradeAnalysisModel.ContractCompanyTradeData, err error) {
|
|
|
- // 各原始数据表期货公司名称不一致
|
|
|
- //companyMap := make(map[string]string)
|
|
|
- //{
|
|
|
- // ob := new(tradeAnalysisModel.TradeFuturesCompany)
|
|
|
- // list, e := ob.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
|
|
|
- // if e != nil {
|
|
|
- // err = fmt.Errorf("获取期货公司名称失败: %v", e)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // switch exchange {
|
|
|
- // case "zhengzhou":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.ZhengzhouName
|
|
|
- // }
|
|
|
- // case "dalian":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.DalianName
|
|
|
- // }
|
|
|
- // case "shanghai":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.ShanghaiName
|
|
|
- // }
|
|
|
- // case "cffex":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.CffexName
|
|
|
- // }
|
|
|
- // case "ine":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.IneName
|
|
|
- // }
|
|
|
- // case "guangzhou":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.GuangzhouName
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //var queryCompanies []string
|
|
|
- //for _, v := range companies {
|
|
|
- // if v == tradeAnalysisModel.TradeFuturesCompanyTop20 {
|
|
|
- // queryCompanies = append(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20)
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // companyName, ok := companyMap[v]
|
|
|
- // if !ok {
|
|
|
- // utils.FileLog.Info(fmt.Sprintf("交易所%s公司名称映射不存在: %s", exchange, v))
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // queryCompanies = append(queryCompanies, companyName)
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 郑商所/广期所查询方式不一样
|
|
|
- //var tradeAnalysis TradeAnalysisInterface
|
|
|
- //switch exchange {
|
|
|
- //case tradeAnalysisModel.TradeExchangeZhengzhou:
|
|
|
- // tradeAnalysis = &ZhengzhouTradeAnalysis{}
|
|
|
- //case tradeAnalysisModel.TradeExchangeGuangzhou:
|
|
|
- // tradeAnalysis = &GuangzhouTradeAnalysis{}
|
|
|
- //default:
|
|
|
- // tradeAnalysis = &BaseTradeAnalysis{}
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 获取多单/空单原始数据
|
|
|
- ////originList, e := tradeAnalysis.GetTradeDataByClassifyAndCompany(exchange, []string{classifyName}, contracts, queryCompanies, time.Time{}, time.Time{})
|
|
|
- ////if e != nil {
|
|
|
- //// err = fmt.Errorf("获取多空单原始数据失败, %v", e)
|
|
|
- //// return
|
|
|
- ////}
|
|
|
- //originList, _, lastOriginList, e := tradeAnalysis.GetTradeDataByContracts(exchange, []string{classifyName}, contracts, queryCompanies, time.Time{}, time.Time{})
|
|
|
- //if e != nil {
|
|
|
- // err = fmt.Errorf("获取多空单原始数据失败, %v", e)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //keyItems := make(map[string]*tradeAnalysisModel.ContractCompanyTradeData)
|
|
|
- //keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
- //keyDateDataExist := make(map[string]bool)
|
|
|
- //for _, v := range originList {
|
|
|
- // // Rank999-对应的是TOP20
|
|
|
- // companyName := v.CompanyName
|
|
|
- // //if v.Rank == 999 {
|
|
|
- // // companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
|
|
|
- // //}
|
|
|
- //
|
|
|
- // k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
|
|
|
- // if keyItems[k] == nil {
|
|
|
- // keyItems[k] = new(tradeAnalysisModel.ContractCompanyTradeData)
|
|
|
- // keyItems[k].CompanyName = companyName
|
|
|
- // keyItems[k].ClassifyType = v.ClassifyType
|
|
|
- // keyItems[k].DataList = make([]*tradeAnalysisModel.ContractCompanyTradeDataList, 0)
|
|
|
- // }
|
|
|
- //
|
|
|
- // kd := fmt.Sprintf("%s-%s", k, v.DataTime.Format(utils.FormatDate))
|
|
|
- // if keyDateData[kd] == nil {
|
|
|
- // keyDateData[kd] = new(tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
- // keyDateData[kd].Date = v.DataTime
|
|
|
- // }
|
|
|
- // if v.ValType == 1 {
|
|
|
- // keyDateData[kd].BuyVal = v.Val
|
|
|
- // keyDateData[kd].BuyValType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // keyDateData[kd].BuyChange = v.ValChange
|
|
|
- // keyDateData[kd].BuyChangeType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // }
|
|
|
- // if v.ValType == 2 {
|
|
|
- // keyDateData[kd].SoldVal = v.Val
|
|
|
- // keyDateData[kd].SoldValType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // keyDateData[kd].SoldChange = v.ValChange
|
|
|
- // keyDateData[kd].SoldChangeType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // }
|
|
|
- // if !keyDateDataExist[kd] {
|
|
|
- // keyItems[k].DataList = append(keyItems[k].DataList, keyDateData[kd])
|
|
|
- // keyDateDataExist[kd] = true
|
|
|
- // }
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 获取[合约]每日的末位多空单
|
|
|
- //contractLastBuyDateVal := make(map[string]map[time.Time]int)
|
|
|
- //contractLastSoldDateVal := make(map[string]map[time.Time]int)
|
|
|
- //{
|
|
|
- // //lastOriginList, e := tradeAnalysis.GetLastTradeDataByClassify(exchange, []string{classifyName}, contracts)
|
|
|
- // //if e != nil {
|
|
|
- // // err = fmt.Errorf("获取末位多空单原始数据失败, %v", e)
|
|
|
- // // return
|
|
|
- // //}
|
|
|
- // for _, v := range lastOriginList {
|
|
|
- // if v.ValType == 1 {
|
|
|
- // if contractLastBuyDateVal[v.ClassifyType] == nil {
|
|
|
- // contractLastBuyDateVal[v.ClassifyType] = make(map[time.Time]int)
|
|
|
- // }
|
|
|
- // contractLastBuyDateVal[v.ClassifyType][v.DataTime] = v.Val
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if contractLastSoldDateVal[v.ClassifyType] == nil {
|
|
|
- // contractLastSoldDateVal[v.ClassifyType] = make(map[time.Time]int)
|
|
|
- // }
|
|
|
- // contractLastSoldDateVal[v.ClassifyType][v.DataTime] = v.Val
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //func GetContractCompanyTradeData(exchange string, classifyNames, contracts, companies []string, startDate, endDate time.Time) (contractTradeData map[string]*tradeAnalysisModel.ContractCompanyTradeData, lastBuyVal, lastSoldVal map[string]map[time.Time]int, err error)
|
|
|
-
|
|
|
// 获取合约持仓数据
|
|
|
contractTradeData, lastBuyVal, lastSoldVal, e := GetContractCompanyTradeData(exchange, []string{classifyName}, contracts, companies, time.Time{}, time.Time{})
|
|
|
if e != nil {
|
|
@@ -698,144 +558,6 @@ func GetTopContractRank(exchange string, classifyNames []string, dataDate time.T
|
|
|
|
|
|
// GetTableTradeData 获取多空分析表格持仓数据
|
|
|
func GetTableTradeData(exchange string, classifyNames, contracts, companies []string, predictRatio float64, startDate, endDate time.Time, contractType int) (companyTradeData []*tradeAnalysisModel.ContractCompanyTradeData, err error) {
|
|
|
- // 各原始数据表期货公司名称不一致
|
|
|
- //companyMap := make(map[string]string)
|
|
|
- //{
|
|
|
- // ob := new(tradeAnalysisModel.TradeFuturesCompany)
|
|
|
- // list, e := ob.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
|
|
|
- // if e != nil {
|
|
|
- // err = fmt.Errorf("获取期货公司名称失败: %v", e)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // switch exchange {
|
|
|
- // case "zhengzhou":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.ZhengzhouName
|
|
|
- // }
|
|
|
- // case "dalian":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.DalianName
|
|
|
- // }
|
|
|
- // case "shanghai":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.ShanghaiName
|
|
|
- // }
|
|
|
- // case "cffex":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.CffexName
|
|
|
- // }
|
|
|
- // case "ine":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.IneName
|
|
|
- // }
|
|
|
- // case "guangzhou":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.GuangzhouName
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //var queryCompanies []string
|
|
|
- //for _, v := range companies {
|
|
|
- // if v == tradeAnalysisModel.TradeFuturesCompanyTop20 {
|
|
|
- // queryCompanies = append(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20)
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // companyName, ok := companyMap[v]
|
|
|
- // if !ok {
|
|
|
- // utils.FileLog.Info(fmt.Sprintf("交易所%s公司名称映射不存在: %s", exchange, v))
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // queryCompanies = append(queryCompanies, companyName)
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 郑商所/广期所查询方式不一样
|
|
|
- //var tradeAnalysis TradeAnalysisInterface
|
|
|
- //switch exchange {
|
|
|
- //case tradeAnalysisModel.TradeExchangeZhengzhou:
|
|
|
- // tradeAnalysis = &ZhengzhouTradeAnalysis{}
|
|
|
- //case tradeAnalysisModel.TradeExchangeGuangzhou:
|
|
|
- // tradeAnalysis = &GuangzhouTradeAnalysis{}
|
|
|
- //default:
|
|
|
- // tradeAnalysis = &BaseTradeAnalysis{}
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 获取多单/空单原始数据, 取基准时间前后五天的数据, 填充数据后, 取出基准日期作为结果
|
|
|
- ////originList, e := tradeAnalysis.GetTradeDataByClassifyAndCompany(exchange, classifyNames, contracts, queryCompanies, baseDate.AddDate(0, 0, -5), baseDate.AddDate(0, 0, 5))
|
|
|
- ////if e != nil {
|
|
|
- //// err = fmt.Errorf("获取多空单原始数据失败, %v", e)
|
|
|
- //// return
|
|
|
- ////}
|
|
|
- //originList, _, lastOriginList, e := tradeAnalysis.GetTradeDataByContracts(exchange, classifyNames, contracts, queryCompanies, baseDate.AddDate(0, 0, -5), baseDate.AddDate(0, 0, 5))
|
|
|
- //if e != nil {
|
|
|
- // err = fmt.Errorf("获取多空单原始数据失败, %v", e)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //keyItems := make(map[string]*tradeAnalysisModel.ContractCompanyTradeData)
|
|
|
- //keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
- //keyDateDataExist := make(map[string]bool)
|
|
|
- //for _, v := range originList {
|
|
|
- // // Rank999-对应的是TOP20
|
|
|
- // companyName := v.CompanyName
|
|
|
- // //if v.Rank == 999 {
|
|
|
- // // companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
|
|
|
- // //}
|
|
|
- //
|
|
|
- // k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
|
|
|
- // if keyItems[k] == nil {
|
|
|
- // keyItems[k] = new(tradeAnalysisModel.ContractCompanyTradeData)
|
|
|
- // keyItems[k].CompanyName = companyName
|
|
|
- // keyItems[k].ClassifyType = v.ClassifyType
|
|
|
- // keyItems[k].DataList = make([]*tradeAnalysisModel.ContractCompanyTradeDataList, 0)
|
|
|
- // }
|
|
|
- //
|
|
|
- // kd := fmt.Sprintf("%s-%s", k, v.DataTime.Format(utils.FormatDate))
|
|
|
- // if keyDateData[kd] == nil {
|
|
|
- // keyDateData[kd] = new(tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
- // keyDateData[kd].Date = v.DataTime
|
|
|
- // }
|
|
|
- // if v.ValType == 1 {
|
|
|
- // keyDateData[kd].BuyVal = v.Val
|
|
|
- // keyDateData[kd].BuyValType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // keyDateData[kd].BuyChange = v.ValChange
|
|
|
- // keyDateData[kd].BuyChangeType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // }
|
|
|
- // if v.ValType == 2 {
|
|
|
- // keyDateData[kd].SoldVal = v.Val
|
|
|
- // keyDateData[kd].SoldValType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // keyDateData[kd].SoldChange = v.ValChange
|
|
|
- // keyDateData[kd].SoldChangeType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // }
|
|
|
- // if !keyDateDataExist[kd] {
|
|
|
- // keyItems[k].DataList = append(keyItems[k].DataList, keyDateData[kd])
|
|
|
- // keyDateDataExist[kd] = true
|
|
|
- // }
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 获取[合约]每日的末位多空单
|
|
|
- //contractLastBuyDateVal := make(map[string]map[time.Time]int)
|
|
|
- //contractLastSoldDateVal := make(map[string]map[time.Time]int)
|
|
|
- //{
|
|
|
- // //lastOriginList, e := tradeAnalysis.GetLastTradeDataByClassify(exchange, classifyNames, contracts)
|
|
|
- // //if e != nil {
|
|
|
- // // err = fmt.Errorf("获取末位多空单原始数据失败, %v", e)
|
|
|
- // // return
|
|
|
- // //}
|
|
|
- // for _, v := range lastOriginList {
|
|
|
- // if v.ValType == 1 {
|
|
|
- // if contractLastBuyDateVal[v.ClassifyType] == nil {
|
|
|
- // contractLastBuyDateVal[v.ClassifyType] = make(map[time.Time]int)
|
|
|
- // }
|
|
|
- // contractLastBuyDateVal[v.ClassifyType][v.DataTime] = v.Val
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if contractLastSoldDateVal[v.ClassifyType] == nil {
|
|
|
- // contractLastSoldDateVal[v.ClassifyType] = make(map[time.Time]int)
|
|
|
- // }
|
|
|
- // contractLastSoldDateVal[v.ClassifyType][v.DataTime] = v.Val
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
// 获取合约持仓数据
|
|
|
contractTradeData, lastBuyVal, lastSoldVal, e := GetContractCompanyTradeData(exchange, classifyNames, contracts, companies, startDate, endDate)
|
|
|
if e != nil {
|
|
@@ -950,149 +672,6 @@ func GetTableTradeData(exchange string, classifyNames, contracts, companies []st
|
|
|
|
|
|
// GetCorrelationTableTradeData 获取相关性表格持仓数据
|
|
|
func GetCorrelationTableTradeData(exchange string, classifyNames, contracts, companies []string, predictRatio float64) (tradeData []*tradeAnalysisModel.ContractCompanyTradeData, err error) {
|
|
|
- // 各原始数据表期货公司名称不一致
|
|
|
- //companyMap := make(map[string]string)
|
|
|
- //{
|
|
|
- // ob := new(tradeAnalysisModel.TradeFuturesCompany)
|
|
|
- // list, e := ob.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
|
|
|
- // if e != nil {
|
|
|
- // err = fmt.Errorf("获取期货公司名称失败: %v", e)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // switch exchange {
|
|
|
- // case "zhengzhou":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.ZhengzhouName
|
|
|
- // }
|
|
|
- // case "dalian":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.DalianName
|
|
|
- // }
|
|
|
- // case "shanghai":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.ShanghaiName
|
|
|
- // }
|
|
|
- // case "cffex":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.CffexName
|
|
|
- // }
|
|
|
- // case "ine":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.IneName
|
|
|
- // }
|
|
|
- // case "guangzhou":
|
|
|
- // for _, v := range list {
|
|
|
- // companyMap[v.CompanyName] = v.GuangzhouName
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //var queryCompanies []string
|
|
|
- //for _, v := range companies {
|
|
|
- // if v == tradeAnalysisModel.TradeFuturesCompanyTop20 {
|
|
|
- // queryCompanies = append(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20)
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // companyName, ok := companyMap[v]
|
|
|
- // if !ok {
|
|
|
- // utils.FileLog.Info(fmt.Sprintf("交易所%s公司名称映射不存在: %s", exchange, v))
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // queryCompanies = append(queryCompanies, companyName)
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 郑商所/广期所查询方式不一样
|
|
|
- //var tradeAnalysis TradeAnalysisInterface
|
|
|
- //switch exchange {
|
|
|
- //case tradeAnalysisModel.TradeExchangeZhengzhou:
|
|
|
- // tradeAnalysis = &ZhengzhouTradeAnalysis{}
|
|
|
- //case tradeAnalysisModel.TradeExchangeGuangzhou:
|
|
|
- // tradeAnalysis = &GuangzhouTradeAnalysis{}
|
|
|
- //default:
|
|
|
- // tradeAnalysis = &BaseTradeAnalysis{}
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 获取多单/空单原始数据
|
|
|
- ////originList, e := tradeAnalysis.GetTradeDataByClassifyAndCompany(exchange, classifyNames, contracts, queryCompanies, time.Time{}, time.Time{})
|
|
|
- ////if e != nil {
|
|
|
- //// err = fmt.Errorf("获取多空单原始数据失败, %v", e)
|
|
|
- //// return
|
|
|
- ////}
|
|
|
- //originList, _, lastOriginList, e := tradeAnalysis.GetTradeDataByContracts(exchange, classifyNames, contracts, queryCompanies, time.Time{}, time.Time{})
|
|
|
- //if e != nil {
|
|
|
- // err = fmt.Errorf("获取多空单原始数据失败, %v", e)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //// [合约-期货公司]数据分组
|
|
|
- //keyItems := make(map[string]*tradeAnalysisModel.ContractCompanyTradeData)
|
|
|
- //{
|
|
|
- // keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
- // keyDateDataExist := make(map[string]bool)
|
|
|
- // for _, v := range originList {
|
|
|
- // // Rank999-对应的是TOP20
|
|
|
- // companyName := v.CompanyName
|
|
|
- // if v.Rank == 999 {
|
|
|
- // companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
|
|
|
- // }
|
|
|
- //
|
|
|
- // k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
|
|
|
- // if keyItems[k] == nil {
|
|
|
- // keyItems[k] = new(tradeAnalysisModel.ContractCompanyTradeData)
|
|
|
- // keyItems[k].Exchange = exchange
|
|
|
- // keyItems[k].CompanyName = companyName
|
|
|
- // keyItems[k].ClassifyName = v.ClassifyName
|
|
|
- // keyItems[k].ClassifyType = v.ClassifyType
|
|
|
- // keyItems[k].DataList = make([]*tradeAnalysisModel.ContractCompanyTradeDataList, 0)
|
|
|
- // }
|
|
|
- //
|
|
|
- // kd := fmt.Sprintf("%s-%s", k, v.DataTime.Format(utils.FormatDate))
|
|
|
- // if keyDateData[kd] == nil {
|
|
|
- // keyDateData[kd] = new(tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
- // keyDateData[kd].Date = v.DataTime
|
|
|
- // }
|
|
|
- // if v.ValType == 1 {
|
|
|
- // keyDateData[kd].BuyVal = v.Val
|
|
|
- // keyDateData[kd].BuyValType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // keyDateData[kd].BuyChange = v.ValChange
|
|
|
- // keyDateData[kd].BuyChangeType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // }
|
|
|
- // if v.ValType == 2 {
|
|
|
- // keyDateData[kd].SoldVal = v.Val
|
|
|
- // keyDateData[kd].SoldValType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // keyDateData[kd].SoldChange = v.ValChange
|
|
|
- // keyDateData[kd].SoldChangeType = tradeAnalysisModel.TradeDataTypeOrigin
|
|
|
- // }
|
|
|
- // if !keyDateDataExist[kd] {
|
|
|
- // keyItems[k].DataList = append(keyItems[k].DataList, keyDateData[kd])
|
|
|
- // keyDateDataExist[kd] = true
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //
|
|
|
- //// 获取[合约]每日的末位多空单
|
|
|
- //contractLastBuyDateVal := make(map[string]map[time.Time]int)
|
|
|
- //contractLastSoldDateVal := make(map[string]map[time.Time]int)
|
|
|
- //{
|
|
|
- // //lastOriginList, e := tradeAnalysis.GetLastTradeDataByClassify(exchange, classifyNames, contracts)
|
|
|
- // //if e != nil {
|
|
|
- // // err = fmt.Errorf("获取末位多空单原始数据失败, %v", e)
|
|
|
- // // return
|
|
|
- // //}
|
|
|
- // for _, v := range lastOriginList {
|
|
|
- // if v.ValType == 1 {
|
|
|
- // if contractLastBuyDateVal[v.ClassifyType] == nil {
|
|
|
- // contractLastBuyDateVal[v.ClassifyType] = make(map[time.Time]int)
|
|
|
- // }
|
|
|
- // contractLastBuyDateVal[v.ClassifyType][v.DataTime] = v.Val
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if contractLastSoldDateVal[v.ClassifyType] == nil {
|
|
|
- // contractLastSoldDateVal[v.ClassifyType] = make(map[time.Time]int)
|
|
|
- // }
|
|
|
- // contractLastSoldDateVal[v.ClassifyType][v.DataTime] = v.Val
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
// 获取合约持仓数据
|
|
|
contractTradeData, lastBuyVal, lastSoldVal, e := GetContractCompanyTradeData(exchange, classifyNames, contracts, companies, time.Time{}, time.Time{})
|
|
|
if e != nil {
|
|
@@ -1245,11 +824,7 @@ func GetContractCompanyTradeData(exchange string, classifyNames, contracts, comp
|
|
|
keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
|
|
|
keyDateDataExist := make(map[string]bool)
|
|
|
for _, v := range originList {
|
|
|
- // Rank999-对应的是TOP20
|
|
|
companyName := v.CompanyName
|
|
|
- //if v.Rank == 999 {
|
|
|
- // companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
|
|
|
- //}
|
|
|
|
|
|
k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
|
|
|
if contractTradeData[k] == nil {
|