mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
增加同花顺复权数据计算复权因子
This commit is contained in:
32
example/GetKlineDayFactor/main.go
Normal file
32
example/GetKlineDayFactor/main.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/injoyai/logs"
|
||||
"github.com/injoyai/tdx"
|
||||
"github.com/injoyai/tdx/extend"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
c, err := tdx.DialDefault()
|
||||
logs.PanicErr(err)
|
||||
|
||||
ks, fs, err := extend.GetTHSDayKlineFactorFull("000001", c)
|
||||
logs.PanicErr(err)
|
||||
|
||||
m := map[int64]*extend.THSFactor{}
|
||||
for _, v := range fs {
|
||||
m[v.Date] = v
|
||||
}
|
||||
|
||||
for _, v := range ks[0] {
|
||||
logs.Debugf("%s 不复权:%.2f 前复权:%.2f 后复权:%.2f \n",
|
||||
time.Unix(v.Date, 0).Format(time.DateOnly),
|
||||
v.Close.Float64(),
|
||||
v.Close.Float64()*m[v.Date].QFactor,
|
||||
v.Close.Float64()*m[v.Date].HFactor,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user