diff --git a/cmd/money/main.go b/cmd/money/main.go index 57730a7..f3aba38 100644 --- a/cmd/money/main.go +++ b/cmd/money/main.go @@ -1,6 +1,8 @@ package main import ( + "fmt" + "git.apinb.com/dataset/stock/internal/config" "git.apinb.com/dataset/stock/internal/impl" "git.apinb.com/dataset/stock/internal/logic/a" @@ -17,5 +19,6 @@ func main() { // 创建实现层 impl.NewImpl() a.NewApiClient() - a.GetTushareMoneyFlow() + lastTradeDay := a.GetTradeDateBy(1, false)[0] + fmt.Println(lastTradeDay) } diff --git a/internal/cron/boot.go b/internal/cron/boot.go index 1ca291b..30f7ce8 100644 --- a/internal/cron/boot.go +++ b/internal/cron/boot.go @@ -1,6 +1,7 @@ package cron import ( + "log" "os" "time" @@ -14,7 +15,7 @@ func Boot() { os.MkdirAll("./markdata/", 0755) } - UpdateTask() + //UpdateTask() scheduler := cron.New() // 每天运行3次来更新数据 @@ -30,6 +31,10 @@ func Boot() { func UpdateTask() { a.NewApiClient() + if a.ReturnLastTradeDay() != time.Now().Format("20060102") { + log.Println("Today Not Trade Day.") + return + } // 获取股票列表 a.GetStockBasic() // 更新资金流向 diff --git a/internal/logic/a/new.go b/internal/logic/a/new.go index ea0d91f..c77aed5 100644 --- a/internal/logic/a/new.go +++ b/internal/logic/a/new.go @@ -40,6 +40,10 @@ func GetTradeDateBy(max int, asc bool) []string { return days } +func ReturnLastTradeDay() string { + return GetTradeDateBy(1, false)[0] +} + func ReturnLastDay() (string, string) { now := time.Now() end := now.Format("20060102")