fix bug
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ func main() {
|
|||||||
impl.NewImpl()
|
impl.NewImpl()
|
||||||
|
|
||||||
a.NewApiClient()
|
a.NewApiClient()
|
||||||
code := "002463.SZ"
|
code := "300541.SZ"
|
||||||
end := time.Now().Format("20060102")
|
end := time.Now().Format("20060102")
|
||||||
|
|
||||||
var start string = "20230101"
|
var start string = "20230101"
|
||||||
@@ -38,6 +39,7 @@ func main() {
|
|||||||
"end_date": end,
|
"end_date": end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("GetStockDaily", code, start, end)
|
||||||
fields := []string{}
|
fields := []string{}
|
||||||
reply, err := a.TushareClient.Daily(params, fields)
|
reply, err := a.TushareClient.Daily(params, fields)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -72,6 +74,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(records) > 0 {
|
if len(records) > 0 {
|
||||||
impl.DBService.CreateInBatches(records, 100)
|
fmt.Println("Created", len(records))
|
||||||
|
//impl.DBService.CreateInBatches(records, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ func Boot() {
|
|||||||
os.MkdirAll("./markdata/", 0755)
|
os.MkdirAll("./markdata/", 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateTask()
|
||||||
|
|
||||||
scheduler := cron.New()
|
scheduler := cron.New()
|
||||||
// 每天运行3次来更新数据
|
// 每天运行3次来更新数据
|
||||||
scheduler.AddFunc("0 18 * * *", func() {
|
scheduler.AddFunc("0 18 * * *", func() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -32,7 +33,13 @@ func GetStockDaily() {
|
|||||||
reply, err := TushareClient.Daily(params, fields)
|
reply, err := TushareClient.Daily(params, fields)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERROR", "GetStockDaily", err)
|
log.Println("ERROR", "GetStockDaily", err)
|
||||||
return
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(reply.Data.Items) == 0 {
|
||||||
|
json, _ := json.Marshal(reply)
|
||||||
|
log.Println("ERROR", "GetStockDailyReply", string(json))
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
records := make([]*models.StockDaily, 0)
|
records := make([]*models.StockDaily, 0)
|
||||||
@@ -65,7 +72,7 @@ func GetStockDaily() {
|
|||||||
impl.DBService.CreateInBatches(records, 50)
|
impl.DBService.CreateInBatches(records, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(200 * time.Microsecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func GetFinaIndicator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(200 * time.Microsecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,6 @@ func GetStockIndicator() {
|
|||||||
impl.DBService.CreateInBatches(records, 100)
|
impl.DBService.CreateInBatches(records, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(200 * time.Microsecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user