當前位置: 首頁>>代碼示例>>Golang>>正文


Golang quandl.Options類代碼示例

本文整理匯總了Golang中github.com/DannyBen/quandl.Options的典型用法代碼示例。如果您正苦於以下問題:Golang Options類的具體用法?Golang Options怎麽用?Golang Options使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Options類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ExampleSymbolResponse

func ExampleSymbolResponse() {
	// 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-02-02")
	// ---

	data, err := quandl.GetSymbol("WIKI/MSFT", v)
	if err != nil {
		panic(err)
	}
	fmt.Println(data.ColumnNames[0], "...")
	fmt.Println(data.Errors)
	fmt.Println(data.Id)
	fmt.Println(data.SourceName)
	fmt.Println(data.SourceCode)
	fmt.Println(data.Code)
	fmt.Println(data.Name[:20], "...")
	fmt.Println(data.UrlizeName[:20], "...")
	fmt.Println(data.DisplayUrl)
	fmt.Println(data.Description[:20], "...")
	fmt.Println(data.UpdatedAt[:3], "...")
	fmt.Println(data.Frequency)
	fmt.Println(data.FromDate)
	fmt.Println(data.ToDate[:3], "...")
	fmt.Println(data.Private)
	fmt.Println(data.Type)
	fmt.Println(data.Premium)
	fmt.Println(data.Data[0][1])

	// Output:
	// Date ...
	// map[]
	// 9775827
	// Wiki EOD Stock Prices
	// WIKI
	// MSFT
	// Microsoft Corporatio ...
	// Microsoft-Corporatio ...
	// http://www.quandl.com/WIKI/MSFT
	// End of day open, hig ...
	// 201 ...
	// daily
	// 1986-03-13
	// 201 ...
	// false
	//
	// false
	// 36.95
}
開發者ID:illyabusigin,項目名稱:quandl,代碼行數:52,代碼來源:quandl_test.go

示例2: getOptions

// getOptions converts command line flags to quandl query string options
func getOptions(a map[string]interface{}, names ...string) quandl.Options {
	opts := quandl.Options{}
	for _, n := range names {
		key := string("--" + n)
		if a[key] != nil {
			if v, ok := a[key].(string); ok {
				opts.Set(n, v)
			} else if v, ok := a[key].(bool); ok {
				if v {
					opts.Set(n, "true")
				}
			}
		}
	}

	return opts
}
開發者ID:crohr,項目名稱:gondl,代碼行數:18,代碼來源:gondl.go

示例3: ExampleGetSymbol

func ExampleGetSymbol() {
	// 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-02-02")
	// ---

	data, err := quandl.GetSymbol("WIKI/AAPL", v)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Symbol: %v, Row Count: %v\n", data.Code, len(data.Data))
	fmt.Printf("Fifth column is named %v\n", data.ColumnNames[4])
	fmt.Printf("On %v the close price was %v\n", data.Data[1][0], data.Data[1][4])

	// Output:
	// Symbol: AAPL, Row Count: 21
	// Fifth column is named Close
	// On 2014-01-30 the close price was 499.78
}
開發者ID:illyabusigin,項目名稱:quandl,代碼行數:22,代碼來源:quandl_test.go

示例4: ExampleToColumns

func ExampleToColumns() {
	// This block is optional
	quandl.ApiKey = apiKey
	quandl.CacheHandler = filecache.Handler{Life: 60}
	v := quandl.Options{}
	v.Set("trim_start", "2014-01-06")
	v.Set("trim_end", "2014-01-08")
	v.Set("column", "4")
	// ---

	data, err := quandl.GetSymbol("WIKI/AAPL", v)
	if err != nil {
		panic(err)
	}

	d := quandl.ToColumns(data.Data)
	fmt.Println(d)

	// Output:
	// [[2014-01-08 2014-01-07 2014-01-06] [543.46 540.04 543.93]]
}
開發者ID:illyabusigin,項目名稱:quandl,代碼行數:21,代碼來源:quandl_test.go

示例5: ExampleSymbolResponse_ToNamedColumns_2

func ExampleSymbolResponse_ToNamedColumns_2() {
	// This block is optional
	quandl.ApiKey = apiKey
	quandl.CacheHandler = filecache.Handler{Life: 60}
	v := quandl.Options{}
	v.Set("trim_start", "2014-01-06")
	v.Set("trim_end", "2014-01-07")
	v.Set("column", "11")
	// ---

	data, err := quandl.GetSymbol("WIKI/AAPL", v)
	if err != nil {
		panic(err)
	}

	d := data.ToNamedColumns([]string{"date", "close"})
	fmt.Println(d["date"], d["close"])

	// Output:
	// [2014-01-07 2014-01-06] [75.561212341336 76.105492609478]
}
開發者ID:illyabusigin,項目名稱:quandl,代碼行數:21,代碼來源:quandl_test.go

示例6: ExampleGetSymbolRaw

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
}
開發者ID:illyabusigin,項目名稱:quandl,代碼行數:22,代碼來源:quandl_test.go


注:本文中的github.com/DannyBen/quandl.Options類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。