mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix kucoin context issue
This commit is contained in:
parent
fb9ece2341
commit
844b3c2e8e
|
@ -5,11 +5,12 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/exchange/kucoin/kucoinapi"
|
||||
"github.com/joho/godotenv"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/exchange/kucoin/kucoinapi"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -26,7 +27,7 @@ var rootCmd = &cobra.Command{
|
|||
SilenceUsage: true,
|
||||
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
accounts, err := client.AccountService.ListAccounts()
|
||||
accounts, err := client.AccountService.ListAccounts(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -26,7 +28,7 @@ var accountsCmd = &cobra.Command{
|
|||
return nil
|
||||
}
|
||||
|
||||
accounts, err := client.AccountService.ListAccounts()
|
||||
accounts, err := client.AccountService.ListAccounts(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import (
|
|||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
||||
var marketDataLimiter = rate.NewLimiter(rate.Every(500*time.Millisecond), 1)
|
||||
|
||||
var ErrMissingSequence = errors.New("sequence is missing")
|
||||
|
||||
// OKB is the platform currency of OKEx, pre-allocate static string here
|
||||
|
@ -53,7 +55,7 @@ func (e *Exchange) PlatformFeeCurrency() string {
|
|||
}
|
||||
|
||||
func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
|
||||
accounts, err := e.client.AccountService.ListAccounts()
|
||||
accounts, err := e.client.AccountService.ListAccounts(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -66,7 +68,7 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
|
|||
}
|
||||
|
||||
func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error) {
|
||||
accounts, err := e.client.AccountService.ListAccounts()
|
||||
accounts, err := e.client.AccountService.ListAccounts(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -150,7 +152,6 @@ func (e *Exchange) IsSupportedInterval(interval types.Interval) bool {
|
|||
return ok
|
||||
}
|
||||
|
||||
var marketDataLimiter = rate.NewLimiter(rate.Every(200*time.Millisecond), 1)
|
||||
|
||||
func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions) ([]types.KLine, error) {
|
||||
_ = marketDataLimiter.Wait(ctx)
|
||||
|
|
|
@ -50,8 +50,8 @@ type Account struct {
|
|||
Holds fixedpoint.Value `json:"holds"`
|
||||
}
|
||||
|
||||
func (s *AccountService) ListAccounts() ([]Account, error) {
|
||||
req, err := s.client.NewAuthenticatedRequest(context.Background(), "GET", "/api/v1/accounts", nil, nil)
|
||||
func (s *AccountService) ListAccounts(ctx context.Context) ([]Account, error) {
|
||||
req, err := s.client.NewAuthenticatedRequest(ctx, "GET", "/api/v1/accounts", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -260,9 +260,9 @@ func (s *Stream) getEndpoint() (string, error) {
|
|||
var bullet *kucoinapi.Bullet
|
||||
var err error
|
||||
if s.PublicOnly {
|
||||
bullet, err = s.client.BulletService.NewGetPublicBulletRequest().Do(nil)
|
||||
bullet, err = s.client.BulletService.NewGetPublicBulletRequest().Do(context.Background())
|
||||
} else {
|
||||
bullet, err = s.client.BulletService.NewGetPrivateBulletRequest().Do(nil)
|
||||
bullet, err = s.client.BulletService.NewGetPrivateBulletRequest().Do(context.Background())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user