Esempio n. 1
0
func main() {
	var addr string
	var debug bool
	var outFile string
	var tickers string
	var day string
	var serviceId int64
	var header bool
	var compression string

	flag.StringVar(&addr, "host", "service.quantgo.com:4476", "host and port adderess of quantgo service")
	flag.StringVar(&outFile, "file", "", "save the result to this file")
	flag.StringVar(&tickers, "tickers", "", "name of tickers separated by comma. Eg. CLM5, CLZ5")
	flag.StringVar(&day, "day", "", "Day or day range in format: yyyMMdd or yyyMMdd-yyyMMdd")
	flag.BoolVar(&debug, "debug", false, "debug")
	flag.Int64Var(&serviceId, "service-id", -1, "Service id. eg: 6803")
	flag.BoolVar(&header, "header", true, "Include headers or not")
	flag.StringVar(&compression, "compression", "plain", "Available compressions: plain, gzip, bzip2")
	flag.Parse()

	service, err := qg.NewQuantGoService(addr, debug)
	if err != nil {
		log.Fatal(err)
	}
	file, err := os.Create(outFile)
	defer file.Close()
	if err != nil {
		log.Fatal(err)
	}

	tickerNames := strings.Split(tickers, ",")
	params := qg.GetDataParameters{
		ServiceId:   int(serviceId),
		TickerNames: tickerNames,
		Date:        day,
		Header:      header,
		Compression: compression,
	}
	meta, n, err := service.GetData(params, file)
	if err != nil {
		log.Fatal(err)
	}
	rd, err := service.GetActionResult(meta.Id)
	if err != nil {
		log.Fatal(err)
	}
	if rd.Size != n {
		log.Fatal("Download size mismatch")
	}
}
Esempio n. 2
0
func main() {
	s, err := qg.NewQuantGoService("service.quantgo.com:4476", true)
	if err != nil {
		log.Fatal(err)
	}
	services, err := s.Available()
	if err != nil {
		log.Fatal(err)
	}
	for _, service := range services {
		fmt.Printf("%s: %d\n", service.DisplayName, service.Id)
	}
	fmt.Println("----")
	countries, err := s.Countries()
	if err != nil {
		log.Fatal(err)
	}
	for _, country := range countries {
		fmt.Printf("%s: %s\n", country.DisplayName, country.Code)
	}
	fmt.Println("----")
	partners, err := s.Partners()
	if err != nil {
		log.Fatal(err)
	}
	for _, partner := range partners {
		fmt.Printf("%s: %d\n", partner.Name, partner.Id)
	}
	fmt.Println("----")
	dts, err := s.DataTypes()
	if err != nil {
		log.Fatal(err)
	}
	for _, dt := range dts {
		fmt.Printf(dt.Name)
	}
	fmt.Println("----")
}