// // // package main import ( "flag" "fmt" "log" "strings" "time" "tickserver/server/market" ) // var file = flag.String("", "", "open .TK or .Mn file") func main() { flag.Parse() n := flag.NArg() if n != 1 { log.Println("must input file name", n) return } file := flag.Arg(0) filelow := strings.ToLower(file) if strings.Contains(filelow, ".tk") { log.Fatal(readTickFile(file)) } readCandleFile(file) } func readTickFile(file string) error { ticks, err := market.ReadTickFile(file) if err != nil { return err } for _, x := range ticks { log.Printf("%s: %+v\n", market.GetTime(x.Timestamp).String(), x) } log.Println("totle:", len(ticks)) return nil } func readCandleFile(file string) error { candles, err := market.ReadCandleFile(file) if err != nil { return err } for _, x := range candles { t := time.Unix(x.Timestamp/1000, 0) fmt.Printf("%04d%02d%02d %02d:%02d:%02d %v\n", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), x) } return nil }