Go client for YahooFinance stock quote historical and real time data.
go get -u github.com/dijeferson/yahoo-finance-provider
package main
import (
"fmt"
"github.com/dijeferson/yahoo-finance-provider"
)
func main() {
response, _ := yahoofinance.FetchDailyHistoricQuote("MSFT")
for _, stock := range response {
fmt.Println(stock.ToJSON())
}
}
Use the interval
type to specify the aggregation. In the example below, the last 15 minutes of stock values for MSFT, aggregated by 5 min averages.
package main
import (
"fmt"
"time"
"github.com/dijeferson/yahoo-finance-provider"
"github.com/dijeferson/yahoo-finance-provider/interval"
)
func main() {
// currentTime - 15 minutes
start := time.Now().Unix() - 900
response, _ := yahoofinance.FetchUntilNow("MSFT", start, interval.FiveMinutes)
for _, stock := range response {
fmt.Println(stock.ToJSON())
}
}
- OneMinutes
- TwoMinutes
- FiveMinutes
- FifteenMinutes
- ThirtyMinutes
- SixtyMinutes
- NinetyMinutes
- OneHour
- OneDays
- FiveDays
- SevenDays
- ThirtyDays
- NinetyDays