From 89aee54ea1ecaddf21da2c1ca27cb714c3e197fe Mon Sep 17 00:00:00 2001 From: hexoul Date: Mon, 12 Nov 2018 10:39:10 +0900 Subject: [PATCH] stat: fix timestamp and remove inappropriate API --- statistics/statistics.go | 20 ++------------------ statistics/statistics_test.go | 15 --------------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/statistics/statistics.go b/statistics/statistics.go index ca6008b..6465a1a 100644 --- a/statistics/statistics.go +++ b/statistics/statistics.go @@ -7,8 +7,8 @@ import ( "io" "os" "strings" + "time" - kucoin "github.com/eeonevision/kucoin-go" "github.com/gocolly/colly" "github.com/jasonlvhit/gocron" log "github.com/sirupsen/logrus" @@ -37,9 +37,8 @@ func init() { logger = log.New() // Default configuration - timestampFormat := "02-01-2006 15:04:05" logger.Formatter = &log.JSONFormatter{ - TimestampFormat: timestampFormat, + TimestampFormat: time.RFC3339, } if f, err := os.OpenFile(logPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666); err == nil { logger.Out = io.MultiWriter(f, os.Stdout) @@ -133,18 +132,3 @@ func taskGatherTokenMetric(symbol, addr string) { "txns": txns, }).Info("GatherTokenMetric") } - -// GatherKucoinBalance records a balance of Kucoin account -func GatherKucoinBalance(k *kucoin.Kucoin, symbol string, job *gocron.Job) { - job.Do(taskGatherKucoinBalance, k, symbol) -} - -func taskGatherKucoinBalance(k *kucoin.Kucoin, symbol string) { - if bal, err := k.GetCoinBalance(symbol); err == nil { - logger.WithFields(log.Fields{ - "symbol": symbol, - "balance": bal.Balance, - "freeze": bal.FreezeBalance, - }).Info("GatherKucoinBalance") - } -} diff --git a/statistics/statistics_test.go b/statistics/statistics_test.go index 73ef7d8..71c6ebe 100644 --- a/statistics/statistics_test.go +++ b/statistics/statistics_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - kucoin "github.com/eeonevision/kucoin-go" "github.com/jasonlvhit/gocron" coinmarketcap "github.com/hexoul/go-coinmarketcap" @@ -36,17 +35,3 @@ func TestGatherTokenMetric(t *testing.T) { gocron.Start() time.Sleep(35 * time.Second) } - -func TestGatherKucoinBalance(t *testing.T) { - k := kucoin.New("API_KEY", "API_SECRET") - GatherKucoinBalance(k, "BTC", gocron.Every(10).Seconds()) - gocron.Start() - time.Sleep(15 * time.Second) -} - -func TestKucoinListMergedDealtOrders(t *testing.T) { - k := kucoin.New("API_KEY", "API_SECRET") - if ret, err := k.ListMergedDealtOrders("ETH-BTC", "BUY", 20, 1, 0, 0); err == nil { - t.Logf("%v\n", ret) - } -}