代码拉取完成,页面将自动刷新
package factors
import (
"gitee.com/quant1x/engine/datasource/dfcf"
"gitee.com/quant1x/gotdx/proto"
"gitee.com/quant1x/gox/api"
"gitee.com/quant1x/gox/logger"
"strings"
"time"
)
type companyNotice struct {
Increase int
Reduce int
Risk int
RiskKeywords string
}
// 上市公司公告
func getOneNotice(securityCode, currentDate string) (notice companyNotice) {
if !proto.AssertStockBySecurityCode(securityCode) {
return
}
now, _ := api.ParseTime(currentDate)
now = now.AddDate(0, -1, 0)
beginDate := now.Format(time.DateOnly)
endDate := currentDate
//list, pages, err := dfcf.StockNotices(securityCode, beginDate, endDate, 1)
//if pages < 1 {
// return
//}
pagesCount := 1
var tmpNotice *dfcf.NoticeDetail = nil
for pageNo := 1; pageNo < pagesCount+1; pageNo++ {
list, pages, err := dfcf.StockNotices(securityCode, beginDate, endDate, pageNo)
if err != nil || pages < 1 {
logger.Errorf("notice: code=%s, %s=>%s, %s", securityCode, beginDate, endDate, err)
break
}
if pagesCount < pages {
pagesCount = pages
}
count := len(list)
if count == 0 {
break
}
for _, v := range list {
if tmpNotice != nil {
tmpNotice.Name = v.Name
if tmpNotice.NoticeDate < v.NoticeDate {
tmpNotice.DisplayTime = v.DisplayTime
tmpNotice.NoticeDate = v.NoticeDate
}
// 使用最近的标题
tmpNotice.Title = v.Title
keywords := tmpNotice.Keywords
if len(v.Keywords) > 0 {
if len(keywords) == 0 {
keywords += v.Keywords
} else {
keywords += "," + v.Keywords
}
}
tmpArr := strings.Split(keywords, ",")
//api.Unique(api.StringSlice{P: &tmpArr})
tmpArr = api.Unique(tmpArr)
tmpNotice.Keywords = strings.Join(tmpArr, ",")
tmpNotice.Increase += v.Increase
tmpNotice.Reduce += v.Reduce
tmpNotice.HolderChange += v.HolderChange
tmpNotice.Risk += v.Risk
} else {
tmpNotice = &v
}
}
if count < dfcf.EastmoneyNoticesPageSize {
break
}
}
if tmpNotice != nil {
notice.Increase = tmpNotice.Increase
notice.Reduce = tmpNotice.Reduce
notice.Risk = tmpNotice.Risk
notice.RiskKeywords = tmpNotice.Keywords
}
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。