gitee.com/quant1x/engine@v1.8.4/datasource/base/tdx_minutes.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/runtime"
    10  )
    11  
    12  // GetMinutes 获取分时数据
    13  func GetMinutes(securityCode, date string) (list []quotes.MinuteTime) {
    14  	tdxApi := gotdx.GetTdxApi()
    15  	u32Date := exchange.ToUint32Date(date)
    16  	hs, err := tdxApi.GetHistoryMinuteTimeData(securityCode, u32Date)
    17  	if err != nil || hs.Count == 0 {
    18  		return
    19  	}
    20  	list = append(list, hs.List...)
    21  	_ = hs
    22  	return
    23  }
    24  
    25  // UpdateMinutes 更新指定日期的个股分时数据
    26  func UpdateMinutes(securityCode, date string) {
    27  	defer runtime.IgnorePanic("update-minutes: code=%s, date=%s", securityCode, date)
    28  	list := GetMinutes(securityCode, date)
    29  	if len(list) > 0 {
    30  		filename := cache.MinuteFilename(securityCode, date)
    31  		_ = api.SlicesToCsv(filename, list)
    32  	}
    33  }