代码拉取完成,页面将自动刷新
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/pandas/stat"
"strconv"
"time"
)
// 获取财务数据
func getFinanceInfo(securityCode, featureDate string) (capital, totalCapital float64, ipoDate, updateDate string) {
basicDate := uint32(stat.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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。