-
Notifications
You must be signed in to change notification settings - Fork 1
/
market_test.go
105 lines (85 loc) · 2.27 KB
/
market_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package kalshi
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestEvents(t *testing.T) {
ctx := context.Background()
client := testClient(t)
t.Run("NoOptions", func(t *testing.T) {
t.Parallel()
resp, err := client.Events(ctx, EventsRequest{})
require.NoError(t, err)
t.Logf("got %v events", len(resp.Events))
require.Greater(t, len(resp.Events), 100)
})
t.Run("SeriesTicker", func(t *testing.T) {
t.Parallel()
resp, err := client.Events(ctx, EventsRequest{
SeriesTicker: "GTEMP",
})
require.NoError(t, err)
require.Greater(t, len(resp.Events), 1)
t.Run("GetEvent", func(t *testing.T) {
t.Parallel()
ev, err := client.Event(ctx, resp.Events[0].EventTicker)
require.NoError(t, err)
require.NotZero(t, ev)
})
})
}
func TestTrades(t *testing.T) {
ctx := context.Background()
client := testClient(t)
market := highestVolumeMarkets(ctx, t, client)[0]
_, err := client.Trades(ctx, TradesRequest{
Ticker: market.Ticker,
})
require.NoError(t, err)
// It's very possible that there are no trades on a test market.
}
func TestMarkets(t *testing.T) {
t.Parallel()
ctx := context.Background()
client := testClient(t)
t.Run("NoOptions", func(t *testing.T) {
t.Parallel()
resp, err := client.Markets(ctx, MarketsRequest{})
require.NoError(t, err)
// 100 is the maximum default limit.
require.Len(t, resp.Markets, 100)
require.NotEmpty(t, resp.Cursor)
})
t.Run("GTEMP", func(t *testing.T) {
t.Parallel()
resp, err := client.Markets(ctx, MarketsRequest{
SeriesTicker: "GTEMP",
MinCloseTs: int(time.Now().Unix()),
})
require.NoError(t, err)
require.Equal(t, len(resp.Markets), 1)
testMarket := resp.Markets[0]
t.Run("Market", func(t *testing.T) {
t.Parallel()
market, err := client.Market(ctx, testMarket.Ticker)
require.NoError(t, err)
require.NotZero(t, market)
})
t.Run("MarketHistory", func(t *testing.T) {
t.Parallel()
resp, err := client.MarketHistory(ctx, testMarket.Ticker, MarketHistoryRequest{})
require.NoError(t, err)
require.NotZero(t, resp)
})
})
}
func TestSeries(t *testing.T) {
t.Parallel()
ctx := context.Background()
client := testClient(t)
resp, err := client.Series(ctx, "NASDAQ100")
require.NoError(t, err)
require.NotEmpty(t, resp)
}