ynab-portfolio-monitor/providers/staticjsonFinnhub/quote.go
Steven Polley 4c01dc4ea2
All checks were successful
continuous-integration/drone/push Build is passing
move providers into providers subdirectory
2023-11-13 17:39:22 -07:00

27 lines
645 B
Go

package staticjsonFinnhub
import (
"fmt"
"net/url"
)
type quote struct {
C float64 `json:"c"` // Current price
H float64 `json:"h"` // High price of the day
L float64 `json:"l"` // Low price of the day
O float64 `json:"O"` // Open price of the day
Pc float64 `json:"pc"` // Previous close price
T int `json:"t"` // ?
}
func (c client) getQuote(symbol string) (int, error) {
quoteResponse := &quote{}
query := url.Values{}
query.Add("symbol", symbol)
err := c.get("/quote", quoteResponse, query)
if err != nil {
return 0, fmt.Errorf("http get request error: %v", err)
}
return int(quoteResponse.C * 1000), nil
}