forked from go-numb/go-dydx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_public_test.go
55 lines (48 loc) · 1.46 KB
/
client_public_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
package dydx_test
import (
"fmt"
"testing"
"time"
"github.com/magiclars-off/go-dydx"
"github.com/magiclars-off/go-dydx/helpers"
"github.com/magiclars-off/go-dydx/public"
"github.com/stretchr/testify/assert"
)
func TestGetMarkets(t *testing.T) {
client := dydx.New(options)
res, err := client.Public.GetMarkets("")
assert.NoError(t, err)
for k, v := range res.Markets {
fmt.Printf("max position - %v\n", v.MaxPositionSize)
fmt.Printf("%v - %#v\n", k, helpers.ToFloat(v.MinOrderSize)*helpers.ToFloat(v.IndexPrice))
}
}
func TestGetTrades(t *testing.T) {
client := dydx.New(options)
res, err := client.Public.GetTrades(&public.TradesParam{
MarketID: "BTC-USD",
})
assert.NoError(t, err)
fmt.Printf("%v", res)
}
func TestGetCandles(t *testing.T) {
client := dydx.New(options)
start := -100 * 24 * time.Hour
res, err := client.Public.GetCandles(&public.CandlesParam{
Market: "BTC-USD",
Resolution: "5MINS",
FromISO: time.Now().UTC().Add(start).Format(time.RFC3339),
ToISO: time.Now().UTC().Add(start + time.Duration(5*100)*time.Minute).Format(time.RFC3339),
Limit: 100,
})
assert.NoError(t, err)
fmt.Printf("%v, lenght: %d\n", res, len(res.Candles))
}
func TestGetHistoricalFunding(t *testing.T) {
client := dydx.New(options)
res, err := client.Public.GetHistoricalFunding(&public.HistoricalFundingsParam{
Market: "BTC-USD",
})
assert.NoError(t, err)
fmt.Printf("%v", res)
}