gitee.com/quant1x/engine@v1.8.4/datasource/base/tdx_xdxr.go (about) 1 package base 2 3 import ( 4 "gitee.com/quant1x/engine/cache" 5 "gitee.com/quant1x/exchange" 6 "gitee.com/quant1x/gotdx" 7 "gitee.com/quant1x/gotdx/quotes" 8 "gitee.com/quant1x/gox/api" 9 "gitee.com/quant1x/gox/logger" 10 ) 11 12 // UpdateXdxrInfo 除权除息数据 13 func UpdateXdxrInfo(securityCode string) { 14 securityCode = exchange.CorrectSecurityCode(securityCode) 15 tdxApi := gotdx.GetTdxApi() 16 xdxrInfos, err := tdxApi.GetXdxrInfo(securityCode) 17 if err != nil { 18 logger.Errorf("获取除权除息数据失败", err) 19 return 20 } 21 //slices.SortFunc(xdxrInfos, func(a, b quotes.XdxrInfo) int { 22 // if a.Date == b.Date { 23 // return 0 24 // } else if a.Date > b.Date { 25 // return 1 26 // } else { 27 // return -1 28 // } 29 //}) 30 if len(xdxrInfos) > 0 { 31 filename := cache.XdxrFilename(securityCode) 32 _ = api.SlicesToCsv(filename, xdxrInfos) 33 } 34 } 35 36 // GetCacheXdxrList 获取除权除息的数据列表 37 func GetCacheXdxrList(securityCode string) []quotes.XdxrInfo { 38 securityCode = exchange.CorrectSecurityCode(securityCode) 39 filename := cache.XdxrFilename(securityCode) 40 list := []quotes.XdxrInfo{} 41 _ = api.CsvToSlices(filename, &list) 42 return list 43 }