move providers into providers subdirectory
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
26
providers/staticjsonFinnhub/quote.go
Normal file
26
providers/staticjsonFinnhub/quote.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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 := "e{}
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user