Files
stock/internal/cron/boot.go
2026-02-12 20:23:42 +08:00

52 lines
979 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package cron
import (
"os"
"time"
"git.apinb.com/bsm-sdk/core/utils"
"git.apinb.com/dataset/stock/internal/logic/a"
"github.com/robfig/cron/v3"
)
func Boot() {
if !utils.PathExists("./markdata/") {
os.MkdirAll("./markdata/", 0755)
}
UpdateTask()
scheduler := cron.New()
// 每天运行3次来更新数据
scheduler.AddFunc("0 18 * * *", func() {
UpdateTask()
})
// 新增每天6点12点18点运行一次
scheduler.AddFunc("0 6,12,23 * * *", func() {
UpdateFinaTask()
})
scheduler.Start()
}
func UpdateTask() {
a.NewApiClient()
// 获取股票列表
a.GetStockBasic()
// 更新资金流向
a.GetTushareMoneyFlow()
// 获取股票日线
a.GetStockDaily()
// 获取股票指标
a.GetStockIndicator()
// 生成Markdown文件
a.GenMarkData()
// start strategy
utils.HttpGet("http://localhost:13499/start/strategy", time.Minute*60*3)
}
func UpdateFinaTask() {
a.NewApiClient()
// 获取股票财务指标数据
a.GetFinaIndicator()
}