gitee.com/quant1x/engine@v1.8.4/cache/cache_filename.go (about)

     1  package cache
     2  
     3  import (
     4  	"fmt"
     5  	"gitee.com/quant1x/exchange"
     6  	"gitee.com/quant1x/gox/api"
     7  )
     8  
     9  const (
    10  	FilenameDate = "20060102" // 缓存文件相关的日期格式
    11  )
    12  
    13  // XdxrFilename XDXR缓存路径
    14  func XdxrFilename(code string) string {
    15  	cacheId := CacheId(code)
    16  	length := len(cacheId)
    17  	xdxrPath := fmt.Sprintf("%s/%s/%s.csv", GetXdxrPath(), cacheId[:length-3], cacheId)
    18  	return xdxrPath
    19  }
    20  
    21  // KLineFilename 基础K线缓存路径
    22  func KLineFilename(code string) string {
    23  	cacheId := CacheId(code)
    24  	length := len(cacheId)
    25  	filepath := fmt.Sprintf("%s/%s/%s.csv", GetDayPath(), cacheId[:length-3], cacheId)
    26  	return filepath
    27  }
    28  
    29  // WideFilename 宽表据缓存路径
    30  func WideFilename(code string) string {
    31  	cacheId := CacheId(code)
    32  	length := len(cacheId)
    33  	filepath := fmt.Sprintf("%s/%s/%s.csv", GetWidePath(), cacheId[:length-3], cacheId)
    34  	return filepath
    35  }
    36  
    37  func MinuteFilename(code, date string) string {
    38  	date = exchange.FixTradeDate(date, FilenameDate)
    39  	cacheId := CacheId(code)
    40  	filename := fmt.Sprintf("%s/%s/%s/%s.csv", GetMinutePath(), date[0:4], date, cacheId)
    41  	return filename
    42  }
    43  
    44  // Top10HoldersFilename 前十大流通股股东缓存文件名
    45  func Top10HoldersFilename(code, date string) string {
    46  	idPath := CacheIdPath(code)
    47  	q, _, _ := api.GetQuarterByDate(date)
    48  	filename := fmt.Sprintf("%s/%s/%s.csv", GetHoldingPath(), q, idPath)
    49  	return filename
    50  }
    51  
    52  func quarterlyCachePath(date string) string {
    53  	q, _, _ := api.GetQuarterByDate(date)
    54  	path := fmt.Sprintf("%s/%s", GetQuarterlyPath(), q)
    55  	return path
    56  }
    57  
    58  // QuarterlyReportFilename 季报存储路径
    59  //
    60  //	info
    61  //	  |-- YYYYQ1
    62  //	        |--  sh600105.report
    63  //	  |-- YYYYQ2
    64  //	  |-- YYYYQ3
    65  //	  |-- YYYYQ4
    66  //	Deprecated: 不推荐使用
    67  func QuarterlyReportFilename(code, date string) string {
    68  	idPath := CacheIdPath(code)
    69  	path := quarterlyCachePath(date)
    70  	filename := fmt.Sprintf("%s/%s.report", path, idPath)
    71  	return filename
    72  }
    73  
    74  func quarterlyFilename(date, keyword string) string {
    75  	path := quarterlyCachePath(date)
    76  	filename := fmt.Sprintf("%s/%s.csv", path, keyword)
    77  	return filename
    78  }
    79  
    80  // ReportsFilename 报告数据文件名
    81  func ReportsFilename(date string) string {
    82  	return quarterlyFilename(date, "reports")
    83  }
    84  
    85  // PreviewReportFilename 业绩预告文件名
    86  func PreviewReportFilename(date string) string {
    87  	return quarterlyFilename(date, "preview")
    88  }
    89  
    90  // TransFilename 历史成交数据文件比较多, 目录结构${tick}/${YYYY}/${YYYYMMDD}/${CacheIdPath}
    91  func TransFilename(code, date string) string {
    92  	date = exchange.FixTradeDate(date, FilenameDate)
    93  	cacheId := CacheId(code)
    94  	tickPath := fmt.Sprintf("%s/%s/%s/%s.csv", GetTransPath(), date[0:4], date, cacheId)
    95  	return tickPath
    96  }
    97  
    98  // FundFlowFilename 通过证券代码获取资金流向的缓存文件路径
    99  func FundFlowFilename(securityCode string) string {
   100  	cacheId := CacheId(securityCode)
   101  	length := len(cacheId)
   102  	filepath := fmt.Sprintf("%s/%s/%s.csv", GetFundFlowPath(), cacheId[:length-3], cacheId)
   103  	return filepath
   104  }
   105  
   106  // SnapshotFilename 快照数据文件
   107  func SnapshotFilename(securityCode string) string {
   108  	cacheId := CacheId(securityCode)
   109  	length := len(cacheId)
   110  	filepath := fmt.Sprintf("%s/%s/%s.csv", GetSnapshotPath(), cacheId[:length-3], cacheId)
   111  	return filepath
   112  }