-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtechnical_indicator.go
More file actions
38 lines (31 loc) · 909 Bytes
/
technical_indicator.go
File metadata and controls
38 lines (31 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package fmpcloud
import (
"fmt"
jsoniter "github.com/json-iterator/go"
"github.com/spacecodewor/fmpcloud-go/objects"
)
// Url const for request
const (
urlAPITechnicalIndicatorSymbol = "/v3/technical_indicator/%s/%s"
)
// TechnicalIndicator client
type TechnicalIndicator struct {
Client *HTTPClient
}
// Indicators - Daily Indicators. Types: SMA - EMA - WMA - DEMA - TEMA - williams - RSI - ADX - standardDeviation
func (t *TechnicalIndicator) Indicators(req objects.RequestIndicators) (iList []objects.ResponseIndicators, err error) {
data, err := t.Client.Get(
fmt.Sprintf(urlAPITechnicalIndicatorSymbol, req.Resolution.String(), req.Symbol),
map[string]string{
"type": req.Indicator.String(),
"period": fmt.Sprint(req.Timeperiod),
})
if err != nil {
return nil, err
}
err = jsoniter.Unmarshal(data.Body(), &iList)
if err != nil {
return nil, err
}
return iList, nil
}