// main.go package main import ( "encoding/binary" "log" "runtime" "time" "unsafe" "tickserver/client" "tickserver/server/market" ) var saddr1 = "115.29.207.108:19528" //115.231.103.7 var saddr2 = "115.29.207.108:19528" //115.236.75.194 var saddr3 = "115.29.207.108:19529" //127.0.0.1 var saddr4 = "115.29.207.108:9090" //115.29.207.108 var sizeofTick = int(unsafe.Sizeof(market.Tick{})) var sizeofCandle = int(unsafe.Sizeof(market.Candle{})) func main() { runtime.GOMAXPROCS(runtime.NumCPU()) client, err := client.NewClientSimple(saddr1, saddr2, saddr3, saddr4, "./tmp") if err != nil { log.Println("new client", err) return } insMap := client.GetInsMap() log.Println("ins len:", len(insMap)) //for k, v := range insMap { //log.Println("ins", k, v) //} ts := (time.Now().Unix() - 12*3600) * 1000 ts = 1439424300000 resp, err := client.GetHis("lmax_4001", market.M1, 100, ts, false) log.Println("GetHis.ts", ts, resp) if err != nil { log.Println("GetHis", err) } else { for { var candle market.Candle err = binary.Read(resp, binary.LittleEndian, &candle) if err != nil { log.Println("GetHis.Read", err) break } log.Println("GetHis.read", candle) } } respEx, err := client.GetHisEx("lmax_4001", market.M1, ts, 1439488920000, false) log.Println("GetHisEx.st.et", ts, 1439488920000, respEx) if err != nil { log.Println("GetHisEx", err) } else { for { var candle market.Candle err = binary.Read(respEx, binary.LittleEndian, &candle) if err != nil { log.Println("GetHisEx.Read", err) break } log.Println("GetHisEx.read", candle) } } ticks, err := client.GetLastTicks("lmax_4001", 100) if err != nil { log.Println("GetLastTicks", err) } else { for i, v := range ticks { log.Println("GetLastTicks.tick", i, v) } } candles, err := client.GetLastCandles("lmax_4001", market.M1, 100) if err != nil { log.Println("GetLastCandles", err) } else { for i, v := range candles { log.Println("GetLastCandles.candle", i, v) } } ticks, err = client.GetLastTicksByTime("lmax_4001", ticks[2].Timestamp, ticks[4].Timestamp) if err != nil { log.Println("GetLastTicksByTime", err) } else { for i, v := range ticks { log.Println("GetLastTicksByTime.tick", i, v) } } candles, err = client.GetLastCandlesByTime("lmax_4001", market.M1, candles[2].Timestamp, candles[4].Timestamp) if err != nil { log.Println("GetLastCandlesByTime", err) } else { for i, v := range candles { log.Println("GetLastCandlesByTime.candle", i, v) } } //select {} }