diff --git a/currency/pair/pair.go b/currency/pair/pair.go index a0ca789c..c357ae46 100644 --- a/currency/pair/pair.go +++ b/currency/pair/pair.go @@ -65,7 +65,9 @@ func (c CurrencyPair) Display(delimiter string, uppercase bool) CurrencyItem { // Equal compares two currency pairs and returns whether or not they are equal func (c CurrencyPair) Equal(p CurrencyPair) bool { if c.FirstCurrency.Upper() == p.FirstCurrency.Upper() && - c.SecondCurrency.Upper() == p.SecondCurrency.Upper() { + c.SecondCurrency.Upper() == p.SecondCurrency.Upper() || + c.FirstCurrency.Upper() == p.SecondCurrency.Upper() && + c.SecondCurrency.Upper() == p.FirstCurrency.Upper() { return true } return false diff --git a/currency/pair/pair_test.go b/currency/pair/pair_test.go index c8f6fcd0..84f936d7 100644 --- a/currency/pair/pair_test.go +++ b/currency/pair/pair_test.go @@ -1,6 +1,8 @@ package pair -import "testing" +import ( + "testing" +) func TestLower(t *testing.T) { t.Parallel() @@ -127,6 +129,16 @@ func TestEqual(t *testing.T) { actual, expected, ) } + + secondPair = NewCurrencyPair("USD", "BTC") + actual = pair.Equal(secondPair) + expected = true + if actual != expected { + t.Errorf( + "Test failed. Equal(): %v was not equal to expected value: %v", + actual, expected, + ) + } } func TestNewCurrencyPair(t *testing.T) { diff --git a/exchanges/gdax/gdax.go b/exchanges/gdax/gdax.go index 4049f870..187a9a52 100644 --- a/exchanges/gdax/gdax.go +++ b/exchanges/gdax/gdax.go @@ -196,7 +196,6 @@ func (g *GDAX) GetTicker(currencyPair string) (Ticker, error) { path := fmt.Sprintf( "%s/%s/%s", g.APIUrl+gdaxProducts, currencyPair, gdaxTicker) - log.Println(path) return ticker, common.SendHTTPGetRequest(path, true, g.Verbose, &ticker) } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index eefd5320..2d3beb7a 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -127,6 +127,8 @@ func (g *Gemini) Setup(exch config.ExchangeConfig) { g.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",") if exch.UseSandbox { g.APIUrl = geminiSandboxAPIURL + } else { + g.APIUrl = geminiAPIURL } err := g.SetCurrencyPairFormat() if err != nil { diff --git a/exchanges/kraken/kraken_wrapper.go b/exchanges/kraken/kraken_wrapper.go index f94fa218..c2e43cc1 100644 --- a/exchanges/kraken/kraken_wrapper.go +++ b/exchanges/kraken/kraken_wrapper.go @@ -54,20 +54,19 @@ func (k *Kraken) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Pri } for _, x := range pairs { - var tp ticker.Price - tick, ok := k.Ticker[x.Pair().String()] - if !ok { - continue + for y, z := range k.Ticker { + if common.StringContains(y, x.FirstCurrency.Upper().String()) && common.StringContains(y, x.SecondCurrency.Upper().String()) { + var tp ticker.Price + tp.Pair = x + tp.Last = z.Last + tp.Ask = z.Ask + tp.Bid = z.Bid + tp.High = z.High + tp.Low = z.Low + tp.Volume = z.Volume + ticker.ProcessTicker(k.GetName(), x, tp, assetType) + } } - - tp.Pair = x - tp.Last = tick.Last - tp.Ask = tick.Ask - tp.Bid = tick.Bid - tp.High = tick.High - tp.Low = tick.Low - tp.Volume = tick.Volume - ticker.ProcessTicker(k.GetName(), x, tp, assetType) } return ticker.GetTicker(k.GetName(), p, assetType) } diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index 9cfc99e9..a056101e 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -34,7 +34,7 @@ func (l *LocalBitcoins) UpdateTicker(p pair.CurrencyPair, assetType string) (tic currency := x.SecondCurrency.String() var tp ticker.Price tp.Pair = x - tp.Last = tick[currency].Rates.Last + tp.Last = tick[currency].Avg24h tp.Volume = tick[currency].VolumeBTC ticker.ProcessTicker(l.GetName(), x, tp, assetType) }