kucoin: add bullet command for testing bullet

This commit is contained in:
c9s 2021-12-22 23:41:33 +08:00
parent 2230b484a8
commit 5382b7a0f2
7 changed files with 75 additions and 5 deletions

View File

@ -5,6 +5,10 @@ import (
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(accountsCmd)
}
var accountsCmd = &cobra.Command{
Use: "accounts",

55
examples/kucoin/bullet.go Normal file
View File

@ -0,0 +1,55 @@
package main
import (
"context"
"errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(bulletCmd)
}
var bulletCmd = &cobra.Command{
Use: "bullet",
// SilenceUsage is an option to silence usage when an error occurs.
SilenceUsage: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return nil
}
ctx := context.Background()
t := args[0]
switch t {
case "public":
bullet, err := client.BulletService.NewGetPublicBulletRequest().Do(ctx)
if err != nil {
return err
}
logrus.Infof("public bullet: %+v", bullet)
case "private":
bullet, err := client.BulletService.NewGetPrivateBulletRequest().Do(ctx)
if err != nil {
return err
}
logrus.Infof("private bullet: %+v", bullet)
default:
return errors.New("valid bullet type: public, private")
}
return nil
},
}

View File

@ -17,11 +17,6 @@ func init() {
rootCmd.PersistentFlags().String("kucoin-api-secret", "", "okex api secret")
rootCmd.PersistentFlags().String("kucoin-api-passphrase", "", "okex api secret")
rootCmd.AddCommand(accountsCmd)
rootCmd.AddCommand(subAccountsCmd)
rootCmd.AddCommand(symbolsCmd)
rootCmd.AddCommand(tickersCmd)
rootCmd.AddCommand(orderbookCmd)
}
var rootCmd = &cobra.Command{

View File

@ -7,6 +7,10 @@ import (
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(orderbookCmd)
}
var orderbookCmd = &cobra.Command{
Use: "orderbook",

View File

@ -5,6 +5,10 @@ import (
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(subAccountsCmd)
}
var subAccountsCmd = &cobra.Command{
Use: "subaccounts",
Short: "subaccounts",

View File

@ -5,6 +5,10 @@ import (
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(symbolsCmd)
}
var symbolsCmd = &cobra.Command{
Use: "symbols",

View File

@ -5,6 +5,10 @@ import (
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(tickersCmd)
}
var tickersCmd = &cobra.Command{
Use: "tickers",