2 Star 7 Fork 11

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
feature_f10_utils.go 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-11 09:21 . 数据插件增加get接口
package factors
import (
"gitee.com/quant1x/engine/datasets/base"
"gitee.com/quant1x/gotdx"
"gitee.com/quant1x/gotdx/proto"
"gitee.com/quant1x/gotdx/quotes"
"gitee.com/quant1x/gotdx/trading"
"gitee.com/quant1x/gox/logger"
"gitee.com/quant1x/pandas/stat"
"strconv"
"time"
)
// 获取财务数据
func getFinanceInfo(securityCode, featureDate string) (capital, totalCapital float64, ipoDate, updateDate string) {
basicDate := uint32(stat.AnyToInt64(proto.MARKET_CN_FIRST_DATE))
for i := 0; i < quotes.DefaultRetryTimes; i++ {
securityCode := proto.CorrectSecurityCode(securityCode)
tdxApi := gotdx.GetTdxApi()
info, err := tdxApi.GetFinanceInfo(securityCode)
if err != nil {
logger.Error(err)
gotdx.ReOpen()
}
if info != nil {
if info.LiuTongGuBen > 0 && info.ZongGuBen > 0 {
capital = info.LiuTongGuBen
totalCapital = info.ZongGuBen
}
if info.IPODate >= basicDate {
ipoDate = strconv.FormatInt(int64(info.IPODate), 10)
ipoDate = trading.FixTradeDate(ipoDate)
} else {
ipoDate = getIpoDate(securityCode, featureDate)
}
if info.UpdatedDate >= basicDate {
updateDate = strconv.FormatInt(int64(info.UpdatedDate), 10)
updateDate = trading.FixTradeDate(updateDate)
}
break
} else if i+1 < quotes.DefaultRetryTimes {
time.Sleep(time.Millisecond * 10)
}
}
return
}
func getIpoDate(securityCode, featureDate string) (ipoDate string) {
// IPO日期不存在, 从日K线第一条记录获取
kls := base.CheckoutKLines(securityCode, featureDate)
if len(kls) > 0 {
ipoDate = kls[0].Date
}
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.6.8

搜索帮助