piquette / finance-go

:bar_chart: Financial markets data library implemented in go.
https://piquette.io/projects/finance-go
MIT License
712 stars 101 forks source link

Docs don't show how to use the forex.Quote #5

Open jrmiller82 opened 6 years ago

jrmiller82 commented 6 years ago

I can't get the forex.Quote("EURUSD") function to work. Am I not specifying the symbol correctly?

jrmiller82 commented 6 years ago

Maybe some lines in the documentation that the symbols are like EURUSD=X.

ackleymi commented 6 years ago

Hey @jrmiller82, check out https://godoc.org/github.com/piquette/finance-go/forex for the exposed functions in the forex package. They are:

List returns a forex.Iter struct that can be used like-

symbols := []string{"GBPUSD=X", "AUDUSD=X"}
iter := forex.List(symbols)
for iter.Next() {
        pairQuote := iter.ForexPair()
    fmt.Println(pairQuote)
}
if iter.Err() != nil {
    fmt.Println(iter.Err())
}

The forex symbols can be found at https://finance.yahoo.com/currencies. But you're right, I need to include some more information.

Make sure you're using the tip of master, it is stable. Use go get -v -u github.com/piquette/finance-go to update or dep ensure -update if you're using dep.