mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
修复未交易(停牌等情况)超过一年复权数据不对的bug,例000633
This commit is contained in:
@@ -114,15 +114,11 @@ func GetTHSDayKline(code string, _type uint8) ([]*Kline, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
total := conv.Int(m["total"])
|
total := conv.Int(m["total"])
|
||||||
|
sortYears := conv.Interfaces(m["sortYear"])
|
||||||
priceFactor := conv.Float64(m["priceFactor"])
|
priceFactor := conv.Float64(m["priceFactor"])
|
||||||
prices := strings.Split(conv.String(m["price"]), ",")
|
prices := strings.Split(conv.String(m["price"]), ",")
|
||||||
dates := strings.Split(conv.String(m["dates"]), ",")
|
dates := strings.Split(conv.String(m["dates"]), ",")
|
||||||
volumes := strings.Split(conv.String(m["volumn"]), ",")
|
volumes := strings.Split(conv.String(m["volumn"]), ",")
|
||||||
start := conv.String(m["start"])
|
|
||||||
t, err := time.Parse("20060102", start)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
//好像到了22点,总数量会比实际多1
|
//好像到了22点,总数量会比实际多1
|
||||||
if total == len(dates)+1 && total == len(volumes)+1 {
|
if total == len(dates)+1 && total == len(volumes)+1 {
|
||||||
@@ -133,17 +129,27 @@ func GetTHSDayKline(code string, _type uint8) ([]*Kline, error) {
|
|||||||
return nil, fmt.Errorf("total=%d prices=%d dates=%d volumns=%d", total, len(prices), len(dates), len(volumes))
|
return nil, fmt.Errorf("total=%d prices=%d dates=%d volumns=%d", total, len(prices), len(dates), len(volumes))
|
||||||
}
|
}
|
||||||
|
|
||||||
ls := []*Kline(nil)
|
mYear := make(map[int][]string)
|
||||||
|
index := 0
|
||||||
year := t.Year()
|
for i, v := range sortYears {
|
||||||
lastDate := ""
|
if ls := conv.Ints(v); len(ls) == 2 {
|
||||||
for i := 0; i < total; i++ {
|
year := conv.Int(ls[0])
|
||||||
//当日前变小时(12xx变01xx),说明过了1年,除非该股票停牌了1年多则数据错误
|
length := conv.Int(ls[1])
|
||||||
if dates[i] < lastDate {
|
if i == len(sortYears)-1 {
|
||||||
year++
|
mYear[year] = dates[index:]
|
||||||
|
break
|
||||||
}
|
}
|
||||||
lastDate = dates[i]
|
mYear[year] = dates[index : index+length]
|
||||||
x, err := time.Parse("0102", dates[i])
|
index += length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ls := []*Kline(nil)
|
||||||
|
i := 0
|
||||||
|
nowYear := time.Now().Year()
|
||||||
|
for year := 1990; year <= nowYear; year++ {
|
||||||
|
for _, d := range mYear[year] {
|
||||||
|
x, err := time.Parse("0102", d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -158,6 +164,8 @@ func GetTHSDayKline(code string, _type uint8) ([]*Kline, error) {
|
|||||||
Close: protocol.Price(conv.Float64(prices[i*4+3])*1000/priceFactor) + low,
|
Close: protocol.Price(conv.Float64(prices[i*4+3])*1000/priceFactor) + low,
|
||||||
Volume: (conv.Int64(volumes[i]) + 50) / 100,
|
Volume: (conv.Int64(volumes[i]) + 50) / 100,
|
||||||
})
|
})
|
||||||
|
i++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ls, nil
|
return ls, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user