forked from sklinkert/igmarkets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentiment.go
28 lines (23 loc) · 922 Bytes
/
sentiment.go
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
package igmarkets
import (
"bytes"
"context"
"fmt"
"net/http"
)
// ClientSentimentResponse - Response for client sentiment
type ClientSentimentResponse struct {
LongPositionPercentage float64 `json:"longPositionPercentage"`
ShortPositionPercentage float64 `json:"shortPositionPercentage"`
}
// GetClientSentiment - Get the client sentiment for the given instrument's market
func (ig *IGMarkets) GetClientSentiment(ctx context.Context, MarketID string) (*ClientSentimentResponse, error) {
bodyReq := new(bytes.Buffer)
req, err := http.NewRequest("GET", ig.APIURL+"/gateway/deal/clientsentiment/"+MarketID, bodyReq)
if err != nil {
return nil, fmt.Errorf("igmarkets: unable to create HTTP request for GetClientSentiment: %v", err)
}
igResponseInterface, err := ig.doRequest(ctx, req, 1, ClientSentimentResponse{})
igResponse, _ := igResponseInterface.(*ClientSentimentResponse)
return igResponse, err
}