gitee.com/quant1x/engine@v1.8.4/trader/orders.go (about) 1 package trader 2 3 import ( 4 "gitee.com/quant1x/exchange" 5 "gitee.com/quant1x/gox/api" 6 "path/filepath" 7 "strings" 8 ) 9 10 // GetOrderFilename 获得订单文件名 11 // 12 // qmt/账户id/orders.yyyy-mm-dd 13 func GetOrderFilename(date ...string) string { 14 var tradeDate string 15 if len(date) > 0 { 16 tradeDate = exchange.FixTradeDate(date[0]) 17 } else { 18 tradeDate = exchange.LastTradeDate() 19 } 20 filename := filepath.Join(traderQmtOrderPath, "orders."+tradeDate) 21 return filename 22 } 23 24 // GetOrderList 获取指定日期的订单列表 25 func GetOrderList(date string) []OrderDetail { 26 filename := GetOrderFilename(date) 27 var list []OrderDetail 28 _ = api.CsvToSlices(filename, &list) 29 return list 30 } 31 32 // GetLocalOrderDates 获取本地订单日期列表 33 func GetLocalOrderDates() (list []string) { 34 prefix := "orders." 35 pattern := filepath.Join(traderQmtOrderPath, prefix+"*") 36 files, err := filepath.Glob(pattern) 37 if err != nil || len(files) == 0 { 38 return list 39 } 40 for _, filename := range files { 41 arr := strings.Split(filename, prefix) 42 if len(arr) != 2 { 43 continue 44 } 45 list = append(list, arr[1]) 46 } 47 return 48 }