forked from ccxt/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen_interest_service_test.go
58 lines (51 loc) · 1.46 KB
/
open_interest_service_test.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package eoptions
import (
"testing"
"github.com/stretchr/testify/suite"
)
type OpenInterestServiceTestSuite struct {
baseTestSuite
}
func TestOpenInterestService(t *testing.T) {
suite.Run(t, new(OpenInterestServiceTestSuite))
}
func (s *OpenInterestServiceTestSuite) TestOpenInterest() {
data := []byte(`[
{
"symbol": "BTC-240628-36000-P",
"sumOpenInterest": "17.250",
"sumOpenInterestUsd": "1174670.00553185250",
"timestamp": "1717036680000"
},
{
"symbol": "BTC-240628-110000-C",
"sumOpenInterest": "25.180",
"sumOpenInterestUsd": "1714677.72401693020",
"timestamp": "1717036680000"
}]`)
s.mockDo(data, nil)
defer s.assertDo()
OIs, err := s.client.NewOpenInterestService().Do(newContext())
targetOIs := []*OpenInterest{
{
Symbol: "BTC-240628-36000-P",
SumOpenInterest: "17.250",
SumOpenInterestUsd: "1174670.00553185250",
Timestamp: "1717036680000",
},
{
Symbol: "BTC-240628-110000-C",
SumOpenInterest: "25.180",
SumOpenInterestUsd: "1714677.72401693020",
Timestamp: "1717036680000",
},
}
s.r().Equal(err, nil, "err != nil")
for i := range OIs {
r := s.r()
r.Equal(OIs[i].Symbol, targetOIs[i].Symbol, "Symbol")
r.Equal(OIs[i].SumOpenInterest, targetOIs[i].SumOpenInterest, "SumOpenInterest")
r.Equal(OIs[i].SumOpenInterestUsd, targetOIs[i].SumOpenInterestUsd, "SumOpenInterestUsd")
r.Equal(OIs[i].Timestamp, targetOIs[i].Timestamp, "Timestamp")
}
}