Beispiel #1
0
// getSymbol downloads symbol data from Quandl and
// outputs it to stdout or file
func getSymbol(a map[string]interface{}) {
	quandlSetup(a)

	format := a["--format"].(string)
	showUrl := a["--url"].(bool)
	symbol := a["<symbol>"].(string)

	opts := getOptions(a, "column", "rows", "trim_start",
		"trim_end", "sort_order", "collapse", "transformation",
		"exclude_headers", "exclude_data")

	result, err := quandl.GetSymbolRaw(symbol, format, opts)
	panicon(err)

	output(a, result, format)
	showQuandlUrl(showUrl, quandl.LastUrl)
}
Beispiel #2
0
func ExampleNewOptions() {
	quandl.ApiKey = apiKey
	quandl.CacheHandler = filecache.Handler{Life: 60}

	opts := quandl.NewOptions(
		"trim_start", "2014-01-01",
		"trim_end", "2014-01-06",
		"column", "4",
	)

	data, err := quandl.GetSymbolRaw("WIKI/AAPL", "csv", opts)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(data))

	// Output:
	// Date,Close
	// 2014-01-06,543.93
	// 2014-01-03,540.98
	// 2014-01-02,553.13
}
Beispiel #3
0
func ExampleGetSymbolRaw() {
	// This block is optional
	quandl.ApiKey = apiKey
	quandl.CacheHandler = filecache.Handler{Life: 60}
	v := quandl.Options{}
	v.Set("trim_start", "2014-01-01")
	v.Set("trim_end", "2014-01-06")
	v.Set("column", "4") // Close price only
	// ---

	data, err := quandl.GetSymbolRaw("WIKI/AAPL", "csv", v)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(data))

	// Output:
	// Date,Close
	// 2014-01-06,543.93
	// 2014-01-03,540.98
	// 2014-01-02,553.13
}