README
¶
Yahoo Finance Provider
Go client for YahooFinance stock quote historical and real time data.
Installation
go get -u github.com/dijeferson/yahoo-finance-provider
Usage and Examples
1. Historical stock quote data for MSFT
package main
import (
"fmt"
"github.com/dijeferson/yahoo-finance-provider"
)
func main() {
response, _ := yahoofinance.FetchDailyQuoteHistory("MSFT")
for _, stock := range response {
fmt.Println(stock.ToJSON())
}
}
2. Latest stock quote data for MSFT
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())
}
}
Available Intervals
- OneMinutes
- TwoMinutes
- FiveMinutes
- FifteenMinutes
- ThirtyMinutes
- SixtyMinutes
- NinetyMinutes
- OneHour
- OneDays
- FiveDays
- SevenDays
- ThirtyDays
- NinetyDays
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StockQuote ¶
type StockQuote struct { Symbol string Date string Open float64 High float64 Low float64 Close float64 AdjClose float64 Volume float64 }
StockQuote data type
func Fetch ¶
func Fetch(symbol string, startDate int64, endDate int64, interval interval.Interval) ([]StockQuote, error)
Fetch fetches stock quotes for a given symbol, in a given timespan (startDate and endDate), separated by interval.
func FetchDailyQuoteHistory ¶
func FetchDailyQuoteHistory(symbol string) ([]StockQuote, error)
FetchDailyQuoteHistory fetches daily stock quote values from 1970-01-01 until today for a given symbol.
func FetchUntilNow ¶
func FetchUntilNow(symbol string, startDate int64, interval interval.Interval) ([]StockQuote, error)
FetchUntilNow fetches stock quote values for a given symbol from a startDate until now, separated by interval.
func (*StockQuote) String ¶
func (data *StockQuote) String() string
String generates a debuggable and easy to read string from the model
func (*StockQuote) ToJSON ¶
func (data *StockQuote) ToJSON() string
ToJSON generates the JSON serialization for the model