diff --git a/currency/pair/pair.go b/currency/pair/pair.go index e82bbc3f..ac4cf13e 100644 --- a/currency/pair/pair.go +++ b/currency/pair/pair.go @@ -32,16 +32,6 @@ type CurrencyPair struct { SecondCurrency CurrencyItem `json:"second_currency"` } -// GetFirstCurrency returns the first currency item -func (c CurrencyPair) GetFirstCurrency() CurrencyItem { - return c.FirstCurrency -} - -// GetSecondCurrency returns the second currency item -func (c CurrencyPair) GetSecondCurrency() CurrencyItem { - return c.SecondCurrency -} - // Pair returns a currency pair string func (c CurrencyPair) Pair() CurrencyItem { return c.FirstCurrency + CurrencyItem(c.Delimiter) + c.SecondCurrency diff --git a/currency/pair/pair_test.go b/currency/pair/pair_test.go index 09ffa720..bec6c5ce 100644 --- a/currency/pair/pair_test.go +++ b/currency/pair/pair_test.go @@ -37,10 +37,10 @@ func TestString(t *testing.T) { } } -func TestGetFirstCurrency(t *testing.T) { +func TestFirstCurrency(t *testing.T) { t.Parallel() pair := NewCurrencyPair("BTC", "USD") - actual := pair.GetFirstCurrency() + actual := pair.FirstCurrency expected := CurrencyItem("BTC") if actual != expected { t.Errorf( @@ -50,10 +50,10 @@ func TestGetFirstCurrency(t *testing.T) { } } -func TestGetSecondCurrency(t *testing.T) { +func TestSecondCurrency(t *testing.T) { t.Parallel() pair := NewCurrencyPair("BTC", "USD") - actual := pair.GetSecondCurrency() + actual := pair.SecondCurrency expected := CurrencyItem("USD") if actual != expected { t.Errorf( diff --git a/exchanges/bitflyer/bitflyer_test.go b/exchanges/bitflyer/bitflyer_test.go index b3b52c27..20f055bc 100644 --- a/exchanges/bitflyer/bitflyer_test.go +++ b/exchanges/bitflyer/bitflyer_test.go @@ -149,7 +149,7 @@ func TestCheckFXString(t *testing.T) { t.Parallel() p := pair.NewCurrencyPairDelimiter("FXBTC_JPY", "_") p = b.CheckFXString(p) - if p.GetFirstCurrency().String() != "FX_BTC" { + if p.FirstCurrency.String() != "FX_BTC" { t.Error("test failed - Bitflyer - CheckFXString() error") } } diff --git a/exchanges/bitflyer/bitflyer_wrapper.go b/exchanges/bitflyer/bitflyer_wrapper.go index b18dca5f..80a1909e 100644 --- a/exchanges/bitflyer/bitflyer_wrapper.go +++ b/exchanges/bitflyer/bitflyer_wrapper.go @@ -81,7 +81,7 @@ func (b *Bitflyer) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker // CheckFXString upgrades currency pair if needed func (b *Bitflyer) CheckFXString(p pair.CurrencyPair) pair.CurrencyPair { - if common.StringContains(p.GetFirstCurrency().String(), "FX") { + if common.StringContains(p.FirstCurrency.String(), "FX") { p.FirstCurrency = "FX_BTC" return p } diff --git a/exchanges/bithumb/bithumb_wrapper.go b/exchanges/bithumb/bithumb_wrapper.go index eb684ba1..1b0e72c5 100644 --- a/exchanges/bithumb/bithumb_wrapper.go +++ b/exchanges/bithumb/bithumb_wrapper.go @@ -64,7 +64,7 @@ func (b *Bithumb) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Pr } for _, x := range b.GetEnabledCurrencies() { - currency := x.GetFirstCurrency().String() + currency := x.FirstCurrency.String() var tp ticker.Price tp.Pair = x tp.Ask = tickers[currency].SellPrice @@ -99,7 +99,7 @@ func (b *Bithumb) GetOrderbookEx(currency pair.CurrencyPair, assetType string) ( // UpdateOrderbook updates and returns the orderbook for a currency pair func (b *Bithumb) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) { var orderBook orderbook.Base - currency := p.GetFirstCurrency().String() + currency := p.FirstCurrency.String() orderbookNew, err := b.GetOrderBook(currency) if err != nil { diff --git a/exchanges/btcmarkets/btcmarkets_wrapper.go b/exchanges/btcmarkets/btcmarkets_wrapper.go index 3833e875..973c024f 100644 --- a/exchanges/btcmarkets/btcmarkets_wrapper.go +++ b/exchanges/btcmarkets/btcmarkets_wrapper.go @@ -59,8 +59,8 @@ func (b *BTCMarkets) Run() { // UpdateTicker updates and returns the ticker for a currency pair func (b *BTCMarkets) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error) { var tickerPrice ticker.Price - tick, err := b.GetTicker(p.GetFirstCurrency().String(), - p.GetSecondCurrency().String()) + tick, err := b.GetTicker(p.FirstCurrency.String(), + p.SecondCurrency.String()) if err != nil { return tickerPrice, err } @@ -93,8 +93,8 @@ func (b *BTCMarkets) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orde // UpdateOrderbook updates and returns the orderbook for a currency pair func (b *BTCMarkets) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) { var orderBook orderbook.Base - orderbookNew, err := b.GetOrderbook(p.GetFirstCurrency().String(), - p.GetSecondCurrency().String()) + orderbookNew, err := b.GetOrderbook(p.FirstCurrency.String(), + p.SecondCurrency.String()) if err != nil { return orderBook, err } @@ -151,7 +151,7 @@ func (b *BTCMarkets) GetExchangeHistory(p pair.CurrencyPair, assetType string) ( // SubmitExchangeOrder submits a new order func (b *BTCMarkets) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (int64, error) { - return b.NewOrder(p.GetFirstCurrency().Upper().String(), p.GetSecondCurrency().Upper().String(), price, amount, side.Format(b.GetName()), orderType.Format(b.GetName()), clientID) + return b.NewOrder(p.FirstCurrency.Upper().String(), p.SecondCurrency.Upper().String(), price, amount, side.Format(b.GetName()), orderType.Format(b.GetName()), clientID) } // ModifyExchangeOrder will allow of changing orderbook placement and limit to diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index 8ceada02..605e9f8f 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -69,7 +69,7 @@ func (l *LocalBitcoins) GetOrderbookEx(p pair.CurrencyPair, assetType string) (o // UpdateOrderbook updates and returns the orderbook for a currency pair func (l *LocalBitcoins) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) { var orderBook orderbook.Base - orderbookNew, err := l.GetOrderbook(p.GetSecondCurrency().String()) + orderbookNew, err := l.GetOrderbook(p.SecondCurrency.String()) if err != nil { return orderBook, err } diff --git a/exchanges/orderbook/orderbook.go b/exchanges/orderbook/orderbook.go index 67033ff8..107ffbe6 100644 --- a/exchanges/orderbook/orderbook.go +++ b/exchanges/orderbook/orderbook.go @@ -83,7 +83,7 @@ func GetOrderbook(exchange string, p pair.CurrencyPair, orderbookType string) (B return Base{}, err } - if !FirstCurrencyExists(exchange, p.GetFirstCurrency()) { + if !FirstCurrencyExists(exchange, p.FirstCurrency) { return Base{}, errors.New(ErrPrimaryCurrencyNotFound) } @@ -91,7 +91,7 @@ func GetOrderbook(exchange string, p pair.CurrencyPair, orderbookType string) (B return Base{}, errors.New(ErrSecondaryCurrencyNotFound) } - return orderbook.Orderbook[p.GetFirstCurrency()][p.GetSecondCurrency()][orderbookType], nil + return orderbook.Orderbook[p.FirstCurrency][p.SecondCurrency][orderbookType], nil } // GetOrderbookByExchange returns an exchange orderbook @@ -128,8 +128,8 @@ func SecondCurrencyExists(exchange string, p pair.CurrencyPair) bool { defer m.Unlock() for _, y := range Orderbooks { if y.ExchangeName == exchange { - if _, ok := y.Orderbook[p.GetFirstCurrency()]; ok { - if _, ok := y.Orderbook[p.GetFirstCurrency()][p.GetSecondCurrency()]; ok { + if _, ok := y.Orderbook[p.FirstCurrency]; ok { + if _, ok := y.Orderbook[p.FirstCurrency][p.SecondCurrency]; ok { return true } } @@ -175,7 +175,7 @@ func ProcessOrderbook(exchangeName string, p pair.CurrencyPair, orderbookNew Bas return } - if FirstCurrencyExists(exchangeName, p.GetFirstCurrency()) { + if FirstCurrencyExists(exchangeName, p.FirstCurrency) { if !SecondCurrencyExists(exchangeName, p) { m.Lock() a := orderbook.Orderbook[p.FirstCurrency] diff --git a/exchanges/ticker/ticker.go b/exchanges/ticker/ticker.go index 695374ce..b523985f 100644 --- a/exchanges/ticker/ticker.go +++ b/exchanges/ticker/ticker.go @@ -121,8 +121,8 @@ func SecondCurrencyExists(exchange string, p pair.CurrencyPair) bool { defer m.Unlock() for _, y := range Tickers { if y.ExchangeName == exchange { - if _, ok := y.Price[p.GetFirstCurrency()]; ok { - if _, ok := y.Price[p.GetFirstCurrency()][p.GetSecondCurrency()]; ok { + if _, ok := y.Price[p.FirstCurrency]; ok { + if _, ok := y.Price[p.FirstCurrency][p.SecondCurrency]; ok { return true } }