diff --git a/cmd/tradelogs/main.go b/cmd/tradelogs/main.go index 6d25643..79bc2e9 100644 --- a/cmd/tradelogs/main.go +++ b/cmd/tradelogs/main.go @@ -115,7 +115,7 @@ func run(c *cli.Context) error { } binanceClient := binance.NewClient(c.String(pricefiller.BinanceAPIKeyFlag.Name), c.String(pricefiller.BinanceSecretKeyFlag.Name)) - priceFiller, err := pricefiller.NewPriceFiller(binanceClient, s) + priceFiller, err := pricefiller.NewPriceFiller(l, binanceClient, s) if err != nil { l.Errorw("Error while init price filler") return err diff --git a/pkg/pricefiller/price_fillter.go b/pkg/pricefiller/price_fillter.go index cae0db4..22787af 100644 --- a/pkg/pricefiller/price_fillter.go +++ b/pkg/pricefiller/price_fillter.go @@ -40,9 +40,10 @@ type PriceFiller struct { mappedCoinInfo map[string]CoinInfo // address - coinInfo } -func NewPriceFiller(binanceClient *binance.Client, s *storage.Storage) (*PriceFiller, error) { +func NewPriceFiller(l *zap.SugaredLogger, binanceClient *binance.Client, + s *storage.Storage) (*PriceFiller, error) { p := &PriceFiller{ - l: zap.S(), + l: l, s: s, ksClient: NewKsClient(), binanceClient: binanceClient, @@ -141,7 +142,8 @@ func (p *PriceFiller) runBackFillTradelogPriceRoutine() { } func (p *PriceFiller) fullFillTradeLog(tradeLog storage.TradeLog) (storage.TradeLog, error) { - makerPrice, makerUsdAmount, err := p.getPriceAndAmountUsd(tradeLog.MakerToken, tradeLog.MakerTokenAmount, int64(tradeLog.Timestamp)) + makerPrice, makerUsdAmount, err := p.getPriceAndAmountUsd(strings.ToLower(tradeLog.MakerToken), + tradeLog.MakerTokenAmount, int64(tradeLog.Timestamp)) if err != nil { p.l.Errorw("Failed to getPriceAndAmountUsd for maker", "err", err) return tradeLog, err @@ -150,7 +152,8 @@ func (p *PriceFiller) fullFillTradeLog(tradeLog storage.TradeLog) (storage.Trade tradeLog.MakerTokenPrice = makerPrice tradeLog.MakerUsdAmount = makerUsdAmount - takerPrice, takerUsdAmount, err := p.getPriceAndAmountUsd(tradeLog.TakerToken, tradeLog.TakerTokenAmount, int64(tradeLog.Timestamp)) + takerPrice, takerUsdAmount, err := p.getPriceAndAmountUsd(strings.ToLower(tradeLog.TakerToken), + tradeLog.TakerTokenAmount, int64(tradeLog.Timestamp)) if err != nil { p.l.Errorw("Failed to getPriceAndAmountUsd for taker", "err", err) return tradeLog, err diff --git a/pkg/pricefiller/price_fillter_test.go b/pkg/pricefiller/price_fillter_test.go index 59016a2..f39797c 100644 --- a/pkg/pricefiller/price_fillter_test.go +++ b/pkg/pricefiller/price_fillter_test.go @@ -6,13 +6,14 @@ import ( "github.com/KyberNetwork/go-binance/v2" "github.com/KyberNetwork/tradelogs/pkg/storage" "github.com/test-go/testify/require" + "go.uber.org/zap" ) // go test -v -timeout 30s -run ^TestFillPrice$ github.com/KyberNetwork/tradelogs/pkg/pricefiller func TestFillPrice(t *testing.T) { t.Skip("Need to add Binance credentials") bClient := binance.NewClient("", "") - filler, err := NewPriceFiller(bClient, nil) + filler, err := NewPriceFiller(zap.S(), bClient, nil) if err != nil { require.NoError(t, err) }