mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
maxapi: add kline api test
This commit is contained in:
parent
3e41c1fb15
commit
cbbe6e286d
|
@ -22,6 +22,6 @@ type GetKLinesRequest struct {
|
|||
timestamp time.Time `param:"timestamp,seconds"`
|
||||
}
|
||||
|
||||
func (s *PublicService) NewGetKLinesRequest() *GetKLinesRequest {
|
||||
return &GetKLinesRequest{client: s.client}
|
||||
func (c *RestClient) NewGetKLinesRequest() *GetKLinesRequest {
|
||||
return &GetKLinesRequest{client: c}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ func (s *PublicService) KLines(symbol string, resolution string, start time.Time
|
|||
return nil, err
|
||||
}
|
||||
|
||||
req := s.NewGetKLinesRequest()
|
||||
req := s.client.NewGetKLinesRequest()
|
||||
req.Market(symbol).Period(int(interval)).Timestamp(start).Limit(limit)
|
||||
data, err := req.Do(context.Background())
|
||||
if err != nil {
|
||||
|
|
|
@ -35,6 +35,16 @@ func TestPublicService(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("v2/k", func(t *testing.T) {
|
||||
req := client.NewGetKLinesRequest()
|
||||
data, err := req.Market("btcusdt").Period(int(60)).Limit(100).Do(ctx)
|
||||
assert.NoError(t, err)
|
||||
if assert.NotEmpty(t, data) {
|
||||
assert.NotEmpty(t, data[0])
|
||||
assert.Len(t, data[0], 6)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("v2/tickers", func(t *testing.T) {
|
||||
req := client.NewGetTickersRequest()
|
||||
tickers, err := req.Do(ctx)
|
||||
|
|
Loading…
Reference in New Issue
Block a user