2021-12-10 17:03:17 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-12-31 18:07:48 +00:00
|
|
|
"context"
|
|
|
|
|
2021-12-10 17:03:17 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2021-12-22 15:41:33 +00:00
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(tickersCmd)
|
|
|
|
}
|
|
|
|
|
2021-12-10 17:03:17 +00:00
|
|
|
var tickersCmd = &cobra.Command{
|
|
|
|
Use: "tickers",
|
|
|
|
|
|
|
|
// SilenceUsage is an option to silence usage when an error occurs.
|
|
|
|
SilenceUsage: true,
|
|
|
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
if len(args) == 0 {
|
|
|
|
allTickers, err := client.MarketDataService.ListTickers()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
logrus.Infof("allTickers: %+v", allTickers)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-12-31 18:07:48 +00:00
|
|
|
req := client.MarketDataService.NewGetTickerRequest(args[0])
|
|
|
|
ticker, err := req.Do(context.Background())
|
2021-12-10 17:03:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
logrus.Infof("ticker: %+v", ticker)
|
2021-12-21 17:26:00 +00:00
|
|
|
|
|
|
|
tickerStats, err := client.MarketDataService.GetTicker24HStat(args[0])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
logrus.Infof("ticker 24h stats: %+v", tickerStats)
|
2021-12-10 17:03:17 +00:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|