gitee.com/quant1x/engine@v1.8.4/factors/feature_f10_notice.go (about) 1 package factors 2 3 import ( 4 "gitee.com/quant1x/engine/datasource/dfcf" 5 "gitee.com/quant1x/exchange" 6 "gitee.com/quant1x/gox/api" 7 "gitee.com/quant1x/gox/logger" 8 "strings" 9 "time" 10 ) 11 12 type companyNotice struct { 13 Increase int 14 Reduce int 15 Risk int 16 RiskKeywords string 17 } 18 19 // 上市公司公告 20 func getOneNotice(securityCode, currentDate string) (notice companyNotice) { 21 if !exchange.AssertStockBySecurityCode(securityCode) { 22 return 23 } 24 now, _ := api.ParseTime(currentDate) 25 now = now.AddDate(0, -1, 0) 26 beginDate := now.Format(time.DateOnly) 27 endDate := currentDate 28 //list, pages, err := dfcf.StockNotices(securityCode, beginDate, endDate, 1) 29 //if pages < 1 { 30 // return 31 //} 32 pagesCount := 1 33 var tmpNotice *dfcf.NoticeDetail = nil 34 for pageNo := 1; pageNo < pagesCount+1; pageNo++ { 35 list, pages, err := dfcf.StockNotices(securityCode, beginDate, endDate, pageNo) 36 if err != nil || pages < 1 { 37 logger.Errorf("notice: code=%s, %s=>%s, %s", securityCode, beginDate, endDate, err) 38 break 39 } 40 if pagesCount < pages { 41 pagesCount = pages 42 } 43 44 count := len(list) 45 if count == 0 { 46 break 47 } 48 for _, v := range list { 49 if tmpNotice != nil { 50 tmpNotice.Name = v.Name 51 if tmpNotice.NoticeDate < v.NoticeDate { 52 tmpNotice.DisplayTime = v.DisplayTime 53 tmpNotice.NoticeDate = v.NoticeDate 54 } 55 // 使用最近的标题 56 tmpNotice.Title = v.Title 57 keywords := tmpNotice.Keywords 58 if len(v.Keywords) > 0 { 59 if len(keywords) == 0 { 60 keywords += v.Keywords 61 } else { 62 keywords += "," + v.Keywords 63 } 64 } 65 tmpArr := strings.Split(keywords, ",") 66 //api.Unique(api.StringSlice{P: &tmpArr}) 67 tmpArr = api.Unique(tmpArr) 68 tmpNotice.Keywords = strings.Join(tmpArr, ",") 69 tmpNotice.Increase += v.Increase 70 tmpNotice.Reduce += v.Reduce 71 tmpNotice.HolderChange += v.HolderChange 72 tmpNotice.Risk += v.Risk 73 } else { 74 tmpNotice = &v 75 } 76 } 77 if count < dfcf.EastmoneyNoticesPageSize { 78 break 79 } 80 } 81 if tmpNotice != nil { 82 notice.Increase = tmpNotice.Increase 83 notice.Reduce = tmpNotice.Reduce 84 notice.Risk = tmpNotice.Risk 85 notice.RiskKeywords = tmpNotice.Keywords 86 } 87 return 88 }