Documentation
¶
Overview ¶
Package googlefinance implements a simple interface for fetching historical prices from google.com/finance.
Example ¶
package main import ( "fmt" "time" "github.com/tiloso/googlefinance" ) func main() { type Quote struct { Date time.Time Open, High, Low, Close float64 Volume uint32 } var qs []Quote d, _ := time.Parse("2-Jan-06", "22-Oct-14") if err := googlefinance.Date(d).Key("NASDAQ:GOOG").Get(&qs); err != nil { fmt.Printf("err: %v\n", err) } fmt.Printf("%+v\n", qs) }
Output: [{Date:2014-10-22 00:00:00 +0000 UTC Open:529.89 High:539.8 Low:528.8 Close:532.71 Volume:2917183}]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query encapsulates query details
func Range ¶
Range returns a range based query
Example ¶
package main import ( "fmt" "time" "github.com/tiloso/googlefinance" ) func main() { type Quote struct { Date time.Time Open, High, Low, Close float64 Volume int } var qs []Quote start, _ := time.Parse("2006-Jan-02", "2014-Oct-13") end, _ := time.Parse("2006-Jan-02", "2014-Oct-14") if err := googlefinance.Range(start, end).Key("fra:dbk").Get(&qs); err != nil { fmt.Printf("err: %v\n", err) } fmt.Printf("%+v\n", qs) }
Output: [{Date:2014-10-14 00:00:00 +0000 UTC Open:24.84 High:25.22 Low:24.66 Close:25.07 Volume:44751} {Date:2014-10-13 00:00:00 +0000 UTC Open:25.03 High:25.34 Low:24.82 Close:25.15 Volume:49379}]
func (*Query) Key ¶
Key clones the query and sets the provided key on the new instance. Stocks' Keys often have following schema: `<exchange>:<symbol>` (e.g. "NASDAQ:GOOG" for Google Inc at NASAQ Stock Exchange) and can be found on google finance for stocks or other financial data. (Make sure historical prices are available as csv export.)
Directories
¶
Path | Synopsis |
---|---|
Package csvdecoding implements decoding of CSV streams (from googlefinance) into slices of Go structs.
|
Package csvdecoding implements decoding of CSV streams (from googlefinance) into slices of Go structs. |
Click to show internal directories.
Click to hide internal directories.