mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
kucoin: add bullet command for testing bullet
This commit is contained in:
parent
2230b484a8
commit
5382b7a0f2
|
@ -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
55
examples/kucoin/bullet.go
Normal 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
|
||||
},
|
||||
}
|
|
@ -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{
|
||||
|
|
|
@ -7,6 +7,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(orderbookCmd)
|
||||
}
|
||||
|
||||
var orderbookCmd = &cobra.Command{
|
||||
Use: "orderbook",
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(subAccountsCmd)
|
||||
}
|
||||
|
||||
var subAccountsCmd = &cobra.Command{
|
||||
Use: "subaccounts",
|
||||
Short: "subaccounts",
|
||||
|
|
|
@ -5,6 +5,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(symbolsCmd)
|
||||
}
|
||||
|
||||
var symbolsCmd = &cobra.Command{
|
||||
Use: "symbols",
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(tickersCmd)
|
||||
}
|
||||
|
||||
var tickersCmd = &cobra.Command{
|
||||
Use: "tickers",
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user