2 Star 3 Fork 10

王布衣 / engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
feature_f10_utils.go 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-02-12 22:53 . 适配新版本的pandas
package factors
import (
"gitee.com/quant1x/engine/datasource/base"
"gitee.com/quant1x/exchange"
"gitee.com/quant1x/gotdx"
"gitee.com/quant1x/gotdx/quotes"
"gitee.com/quant1x/gox/logger"
"gitee.com/quant1x/num"
"strconv"
"time"
)
// 获取财务数据
func getFinanceInfo(securityCode, featureDate string) (capital, totalCapital float64, ipoDate, updateDate string) {
basicDate := uint32(num.AnyToInt64(exchange.MARKET_CN_FIRST_DATE))
for i := 0; i < quotes.DefaultRetryTimes; i++ {
securityCode := exchange.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 = exchange.FixTradeDate(ipoDate)
} else {
ipoDate = getIpoDate(securityCode, featureDate)
}
if info.UpdatedDate >= basicDate {
updateDate = strconv.FormatInt(int64(info.UpdatedDate), 10)
updateDate = exchange.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
}
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.8.4

搜索帮助