2 Star 7 Fork 11

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
feature_f10_notice.go 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-29 08:11 . F10的公告信息只处理证券代码
package factors
import (
"gitee.com/quant1x/engine/datasets/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})
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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.7.3

搜索帮助