2021-12-10 17:41:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2021-12-22 15:41:33 +00:00
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(orderbookCmd)
|
|
|
|
}
|
|
|
|
|
2021-12-10 17:41:23 +00:00
|
|
|
var orderbookCmd = &cobra.Command{
|
|
|
|
Use: "orderbook",
|
|
|
|
|
|
|
|
// SilenceUsage is an option to silence usage when an error occurs.
|
|
|
|
SilenceUsage: true,
|
|
|
|
|
|
|
|
Args: cobra.MinimumNArgs(1),
|
|
|
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
if len(args) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var depth = 0
|
|
|
|
if len(args) > 1 {
|
|
|
|
v, err := strconv.Atoi(args[1])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
depth = v
|
|
|
|
}
|
|
|
|
|
|
|
|
orderBook, err := client.MarketDataService.GetOrderBook(args[0], depth)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
logrus.Infof("orderBook: %+v", orderBook)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|