From ca55f2f96593b372a057ee5cae260b5e5b097c90 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 4 Apr 2019 15:31:49 +1100 Subject: [PATCH] Optimisation: Large struct pointer conversion (final part) (#265) Completes large struct pointer optomisations over the entire codebase and enables hugeParams linter by default --- .golangci.yml | 1 - currency/currency.go | 2 +- currency/storage.go | 2 +- currency/storage_test.go | 7 +- exchange.go | 4 +- exchanges/alphapoint/alphapoint_wrapper.go | 2 +- exchanges/anx/anx.go | 4 +- exchanges/anx/anx_test.go | 2 +- exchanges/anx/anx_wrapper.go | 2 +- exchanges/binance/binance.go | 4 +- exchanges/binance/binance_test.go | 2 +- exchanges/binance/binance_wrapper.go | 2 +- exchanges/bitfinex/bitfinex.go | 4 +- exchanges/bitfinex/bitfinex_test.go | 2 +- exchanges/bitfinex/bitfinex_wrapper.go | 2 +- exchanges/bitflyer/bitflyer.go | 4 +- exchanges/bitflyer/bitflyer_test.go | 2 +- exchanges/bitflyer/bitflyer_wrapper.go | 2 +- exchanges/bithumb/bithumb.go | 4 +- exchanges/bithumb/bithumb_test.go | 2 +- exchanges/bithumb/bithumb_wrapper.go | 2 +- exchanges/bitmex/bitmex.go | 14 ++-- exchanges/bitmex/bitmex_parameters.go | 80 +++++++++---------- exchanges/bitmex/bitmex_test.go | 2 +- exchanges/bitmex/bitmex_wrapper.go | 2 +- exchanges/bitstamp/bitstamp.go | 4 +- exchanges/bitstamp/bitstamp_test.go | 2 +- exchanges/bitstamp/bitstamp_wrapper.go | 2 +- exchanges/bittrex/bittrex.go | 4 +- exchanges/bittrex/bittrex_test.go | 2 +- exchanges/bittrex/bittrex_wrapper.go | 2 +- exchanges/btcc/btcc.go | 4 +- exchanges/btcc/btcc_test.go | 2 +- exchanges/btcmarkets/btcmarkets.go | 4 +- exchanges/btcmarkets/btcmarkets_test.go | 2 +- exchanges/btcmarkets/btcmarkets_wrapper.go | 2 +- exchanges/btse/btse.go | 4 +- exchanges/btse/btse_test.go | 2 +- exchanges/btse/btse_wrapper.go | 2 +- exchanges/coinbasepro/coinbasepro.go | 4 +- exchanges/coinbasepro/coinbasepro_test.go | 2 +- exchanges/coinbasepro/coinbasepro_wrapper.go | 2 +- exchanges/coinut/coinut.go | 4 +- exchanges/coinut/coinut_test.go | 2 +- exchanges/coinut/coinut_wrapper.go | 2 +- exchanges/exchange.go | 2 +- exchanges/exmo/exmo.go | 4 +- exchanges/exmo/exmo_test.go | 2 +- exchanges/exmo/exmo_wrapper.go | 2 +- exchanges/gateio/gateio.go | 4 +- exchanges/gateio/gateio_test.go | 2 +- exchanges/gateio/gateio_wrapper.go | 2 +- exchanges/gemini/gemini.go | 4 +- exchanges/gemini/gemini_test.go | 4 +- exchanges/gemini/gemini_wrapper.go | 2 +- exchanges/hitbtc/hitbtc.go | 4 +- exchanges/hitbtc/hitbtc_test.go | 2 +- exchanges/hitbtc/hitbtc_wrapper.go | 2 +- exchanges/huobi/huobi.go | 4 +- exchanges/huobi/huobi_test.go | 2 +- exchanges/huobi/huobi_wrapper.go | 2 +- exchanges/huobihadax/huobihadax.go | 4 +- exchanges/huobihadax/huobihadax_test.go | 2 +- exchanges/huobihadax/huobihadax_wrapper.go | 2 +- exchanges/itbit/itbit.go | 4 +- exchanges/itbit/itbit_test.go | 2 +- exchanges/itbit/itbit_wrapper.go | 2 +- exchanges/kraken/kraken.go | 4 +- exchanges/kraken/kraken_test.go | 2 +- exchanges/kraken/kraken_wrapper.go | 2 +- exchanges/lakebtc/lakebtc.go | 4 +- exchanges/lakebtc/lakebtc_test.go | 2 +- exchanges/lakebtc/lakebtc_wrapper.go | 2 +- exchanges/localbitcoins/localbitcoins.go | 4 +- exchanges/localbitcoins/localbitcoins_test.go | 2 +- .../localbitcoins/localbitcoins_wrapper.go | 2 +- exchanges/okcoin/okcoin_test.go | 2 +- exchanges/okex/okex_test.go | 2 +- exchanges/okgroup/okgroup.go | 4 +- exchanges/okgroup/okgroup_wrapper.go | 2 +- exchanges/orderbook/orderbook.go | 10 +-- exchanges/orderbook/orderbook_test.go | 10 +-- exchanges/poloniex/poloniex.go | 4 +- exchanges/poloniex/poloniex_test.go | 2 +- exchanges/poloniex/poloniex_wrapper.go | 2 +- exchanges/ticker/ticker.go | 10 +-- exchanges/ticker/ticker_test.go | 22 ++--- exchanges/yobit/yobit.go | 4 +- exchanges/yobit/yobit_test.go | 2 +- exchanges/yobit/yobit_wrapper.go | 2 +- exchanges/zb/zb.go | 4 +- exchanges/zb/zb_test.go | 2 +- exchanges/zb/zb_wrapper.go | 2 +- helpers_test.go | 2 +- main.go | 2 +- tools/exchange_template/main_file.tmpl | 4 +- tools/exchange_template/wrapper_file.tmpl | 2 +- 97 files changed, 195 insertions(+), 195 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f7937adc..43d31819 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -65,7 +65,6 @@ linters-settings: - experimental disabled-checks: - wrapperFunc - - hugeParam - importShadow - rangeValCopy - methodExprCall diff --git a/currency/currency.go b/currency/currency.go index 7569e8cd..475f4642 100644 --- a/currency/currency.go +++ b/currency/currency.go @@ -72,7 +72,7 @@ func GetTotalMarketCryptocurrencies() ([]Code, error) { } // RunStorageUpdater runs a new foreign exchange updater instance -func RunStorageUpdater(o BotOverrides, m MainConfiguration, filepath string, v bool) error { +func RunStorageUpdater(o BotOverrides, m *MainConfiguration, filepath string, v bool) error { return storage.RunUpdater(o, m, filepath, v) } diff --git a/currency/storage.go b/currency/storage.go index d3e4135f..e6923f50 100644 --- a/currency/storage.go +++ b/currency/storage.go @@ -96,7 +96,7 @@ func (s *Storage) SetDefaults() { // dump file and keep foreign exchange rates updated as fast as possible without // triggering rate limiters, it will also run a full cryptocurrency check // through coin market cap and expose analytics for exchange services -func (s *Storage) RunUpdater(overrides BotOverrides, settings MainConfiguration, filePath string, verbose bool) error { +func (s *Storage) RunUpdater(overrides BotOverrides, settings *MainConfiguration, filePath string, verbose bool) error { s.mtx.Lock() if !settings.Cryptocurrencies.HasData() { diff --git a/currency/storage_test.go b/currency/storage_test.go index bfa5acc6..2ed70a61 100644 --- a/currency/storage_test.go +++ b/currency/storage_test.go @@ -5,7 +5,8 @@ import "testing" func TestRunUpdater(t *testing.T) { var newStorage Storage - err := newStorage.RunUpdater(BotOverrides{}, MainConfiguration{}, "", false) + emptyMainConfig := MainConfiguration{} + err := newStorage.RunUpdater(BotOverrides{}, &emptyMainConfig, "", false) if err == nil { t.Fatal("Test Failed storage RunUpdater() error cannot be nil") } @@ -15,12 +16,12 @@ func TestRunUpdater(t *testing.T) { FiatDisplayCurrency: USD, } - err = newStorage.RunUpdater(BotOverrides{}, mainConfig, "", false) + err = newStorage.RunUpdater(BotOverrides{}, &mainConfig, "", false) if err == nil { t.Fatal("Test Failed storage RunUpdater() error cannot be nil") } - err = newStorage.RunUpdater(BotOverrides{}, mainConfig, "/bla", false) + err = newStorage.RunUpdater(BotOverrides{}, &mainConfig, "/bla", false) if err != nil { t.Fatal("Test Failed storage RunUpdater() error", err) } diff --git a/exchange.go b/exchange.go index 61f54165..f1a9da27 100644 --- a/exchange.go +++ b/exchange.go @@ -84,7 +84,7 @@ func ReloadExchange(name string) error { } e := GetExchangeByName(nameLower) - e.Setup(exchCfg) + e.Setup(&exchCfg) log.Debugf("%s exchange reloaded successfully.\n", name) return nil } @@ -207,7 +207,7 @@ func LoadExchange(name string, useWG bool, wg *sync.WaitGroup) error { } exchCfg.Enabled = true - exch.Setup(exchCfg) + exch.Setup(&exchCfg) if useWG { exch.Start(wg) diff --git a/exchanges/alphapoint/alphapoint_wrapper.go b/exchanges/alphapoint/alphapoint_wrapper.go index 6ee79650..7a5c8081 100644 --- a/exchanges/alphapoint/alphapoint_wrapper.go +++ b/exchanges/alphapoint/alphapoint_wrapper.go @@ -56,7 +56,7 @@ func (a *Alphapoint) UpdateTicker(p currency.Pair, assetType string) (ticker.Pri tickerPrice.Volume = tick.Volume tickerPrice.Last = tick.Last - err = ticker.ProcessTicker(a.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(a.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/anx/anx.go b/exchanges/anx/anx.go index ddd0bbb7..c6dc4e15 100644 --- a/exchanges/anx/anx.go +++ b/exchanges/anx/anx.go @@ -76,7 +76,7 @@ func (a *ANX) SetDefaults() { } // Setup is run on startup to setup exchange with config values -func (a *ANX) Setup(exch config.ExchangeConfig) { +func (a *ANX) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { a.SetEnabled(false) } else { @@ -102,7 +102,7 @@ func (a *ANX) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = a.SetAPIURL(&exch) + err = a.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/anx/anx_test.go b/exchanges/anx/anx_test.go index 6130045e..fe28dba8 100644 --- a/exchanges/anx/anx_test.go +++ b/exchanges/anx/anx_test.go @@ -53,7 +53,7 @@ func TestSetup(t *testing.T) { if err != nil { t.Error("Test Failed - ANX Setup() init error") } - a.Setup(anxConfig) + a.Setup(&anxConfig) a.APIKey = testAPIKey a.APISecret = testAPISecret a.AuthenticatedAPISupport = true diff --git a/exchanges/anx/anx_wrapper.go b/exchanges/anx/anx_wrapper.go index 4f864f18..6a62cbb1 100644 --- a/exchanges/anx/anx_wrapper.go +++ b/exchanges/anx/anx_wrapper.go @@ -150,7 +150,7 @@ func (a *ANX) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, err tickerPrice.High = 0 } - err = ticker.ProcessTicker(a.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(a.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index 92753ddf..626e2381 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -101,7 +101,7 @@ func (b *Binance) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (b *Binance) Setup(exch config.ExchangeConfig) { +func (b *Binance) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -127,7 +127,7 @@ func (b *Binance) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index 454e8bbc..20a7addc 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -33,7 +33,7 @@ func TestSetup(t *testing.T) { binanceConfig.AuthenticatedAPISupport = true binanceConfig.APIKey = testAPIKey binanceConfig.APISecret = testAPISecret - b.Setup(binanceConfig) + b.Setup(&binanceConfig) } func TestGetExchangeValidCurrencyPairs(t *testing.T) { diff --git a/exchanges/binance/binance_wrapper.go b/exchanges/binance/binance_wrapper.go index a716749e..55a7956f 100644 --- a/exchanges/binance/binance_wrapper.go +++ b/exchanges/binance/binance_wrapper.go @@ -98,7 +98,7 @@ func (b *Binance) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tickerPrice.Last = tick[y].LastPrice tickerPrice.Low = tick[y].LowPrice tickerPrice.Volume = tick[y].Volume - ticker.ProcessTicker(b.Name, tickerPrice, assetType) + ticker.ProcessTicker(b.Name, &tickerPrice, assetType) } } return ticker.GetTicker(b.Name, p, assetType) diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index 9c53066c..505f8916 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -118,7 +118,7 @@ func (b *Bitfinex) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (b *Bitfinex) Setup(exch config.ExchangeConfig) { +func (b *Bitfinex) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -145,7 +145,7 @@ func (b *Bitfinex) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index 029c88c9..b52a51da 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -29,7 +29,7 @@ func TestSetup(t *testing.T) { if err != nil { t.Error("Test Failed - Bitfinex Setup() init error") } - b.Setup(bfxConfig) + b.Setup(&bfxConfig) b.APIKey = testAPIKey b.APISecret = testAPISecret if !b.Enabled || b.AuthenticatedAPISupport || b.RESTPollingDelay != time.Duration(10) || diff --git a/exchanges/bitfinex/bitfinex_wrapper.go b/exchanges/bitfinex/bitfinex_wrapper.go index 14acf178..5cfe0425 100644 --- a/exchanges/bitfinex/bitfinex_wrapper.go +++ b/exchanges/bitfinex/bitfinex_wrapper.go @@ -79,7 +79,7 @@ func (b *Bitfinex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price tick.Volume = tickerNew[x].Volume tick.High = tickerNew[x].High - err = ticker.ProcessTicker(b.Name, tick, assetType) + err = ticker.ProcessTicker(b.Name, &tick, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/bitflyer/bitflyer.go b/exchanges/bitflyer/bitflyer.go index e0bcde90..2d286a23 100644 --- a/exchanges/bitflyer/bitflyer.go +++ b/exchanges/bitflyer/bitflyer.go @@ -103,7 +103,7 @@ func (b *Bitflyer) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (b *Bitflyer) Setup(exch config.ExchangeConfig) { +func (b *Bitflyer) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -130,7 +130,7 @@ func (b *Bitflyer) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/bitflyer/bitflyer_test.go b/exchanges/bitflyer/bitflyer_test.go index ccdbce3f..0692dd4f 100644 --- a/exchanges/bitflyer/bitflyer_test.go +++ b/exchanges/bitflyer/bitflyer_test.go @@ -35,7 +35,7 @@ func TestSetup(t *testing.T) { bitflyerConfig.APIKey = testAPIKey bitflyerConfig.APISecret = testAPISecret - b.Setup(bitflyerConfig) + b.Setup(&bitflyerConfig) } func TestGetLatestBlockCA(t *testing.T) { diff --git a/exchanges/bitflyer/bitflyer_wrapper.go b/exchanges/bitflyer/bitflyer_wrapper.go index 524a1854..a403aded 100644 --- a/exchanges/bitflyer/bitflyer_wrapper.go +++ b/exchanges/bitflyer/bitflyer_wrapper.go @@ -66,7 +66,7 @@ func (b *Bitflyer) UpdateTicker(p currency.Pair, assetType string) (ticker.Price tickerPrice.Last = tickerNew.Last tickerPrice.Volume = tickerNew.Volume // tickerPrice.High - err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/bithumb/bithumb.go b/exchanges/bithumb/bithumb.go index c74fadd3..d8f26aec 100644 --- a/exchanges/bithumb/bithumb.go +++ b/exchanges/bithumb/bithumb.go @@ -85,7 +85,7 @@ func (b *Bithumb) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (b *Bithumb) Setup(exch config.ExchangeConfig) { +func (b *Bithumb) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -112,7 +112,7 @@ func (b *Bithumb) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/bithumb/bithumb_test.go b/exchanges/bithumb/bithumb_test.go index 40cf3e94..2d866fc7 100644 --- a/exchanges/bithumb/bithumb_test.go +++ b/exchanges/bithumb/bithumb_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { bitConfig.APIKey = testAPIKey bitConfig.APISecret = testAPISecret - b.Setup(bitConfig) + b.Setup(&bitConfig) } func TestGetTradablePairs(t *testing.T) { diff --git a/exchanges/bithumb/bithumb_wrapper.go b/exchanges/bithumb/bithumb_wrapper.go index 64c9bee4..2f14b342 100644 --- a/exchanges/bithumb/bithumb_wrapper.go +++ b/exchanges/bithumb/bithumb_wrapper.go @@ -84,7 +84,7 @@ func (b *Bithumb) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tp.Volume = tickers[currency].Volume1Day tp.High = tickers[currency].MaxPrice - err = ticker.ProcessTicker(b.Name, tp, assetType) + err = ticker.ProcessTicker(b.Name, &tp, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index 0c5a358a..fcb39222 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -139,7 +139,7 @@ func (b *Bitmex) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (b *Bitmex) Setup(exch config.ExchangeConfig) { +func (b *Bitmex) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -164,7 +164,7 @@ func (b *Bitmex) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } @@ -218,7 +218,7 @@ func (b *Bitmex) RemoveAPIKey(params APIKeyParams) (bool, error) { return keyDeleted, b.SendAuthenticatedHTTPRequest(http.MethodDelete, bitmexEndpointAPIkeys, - params, + ¶ms, &keyDeleted) } @@ -228,7 +228,7 @@ func (b *Bitmex) DisableAPIKey(params APIKeyParams) (APIKey, error) { return keyInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost, bitmexEndpointDisableAPIkey, - params, + ¶ms, &keyInfo) } @@ -238,7 +238,7 @@ func (b *Bitmex) EnableAPIKey(params APIKeyParams) (APIKey, error) { return keyInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost, bitmexEndpointEnableAPIkey, - params, + ¶ms, &keyInfo) } @@ -246,7 +246,7 @@ func (b *Bitmex) EnableAPIKey(params APIKeyParams) (APIKey, error) { func (b *Bitmex) GetTrollboxMessages(params ChatGetParams) ([]Chat, error) { var messages []Chat - return messages, b.SendHTTPRequest(bitmexEndpointTrollbox, params, &messages) + return messages, b.SendHTTPRequest(bitmexEndpointTrollbox, ¶ms, &messages) } // SendTrollboxMessage sends a message to the bitmex trollbox @@ -255,7 +255,7 @@ func (b *Bitmex) SendTrollboxMessage(params ChatSendParams) ([]Chat, error) { return messages, b.SendAuthenticatedHTTPRequest(http.MethodPost, bitmexEndpointTrollboxSend, - params, + ¶ms, &messages) } diff --git a/exchanges/bitmex/bitmex_parameters.go b/exchanges/bitmex/bitmex_parameters.go index 807a5821..1f39af6f 100644 --- a/exchanges/bitmex/bitmex_parameters.go +++ b/exchanges/bitmex/bitmex_parameters.go @@ -91,7 +91,7 @@ type APIKeyParams struct { } // VerifyData verifies outgoing data sets -func (p APIKeyParams) VerifyData() error { +func (p *APIKeyParams) VerifyData() error { if p.APIKeyID == "" { return errors.New("verifydata APIKeyParams error - APIKeyID not set") } @@ -100,7 +100,7 @@ func (p APIKeyParams) VerifyData() error { // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p APIKeyParams) ToURLVals(path string) (string, error) { +func (p *APIKeyParams) ToURLVals(path string) (string, error) { values, err := StructValsToURLVals(&p) if err != nil { return "", err @@ -109,8 +109,8 @@ func (p APIKeyParams) ToURLVals(path string) (string, error) { } // IsNil checks to see if any values has been set for the paramater -func (p APIKeyParams) IsNil() bool { - return p == (APIKeyParams{}) +func (p *APIKeyParams) IsNil() bool { + return (APIKeyParams{}) == *p } // ChatGetParams contains all the parameters to send to the API endpoint @@ -129,14 +129,14 @@ type ChatGetParams struct { } // VerifyData verifies outgoing data sets -func (p ChatGetParams) VerifyData() error { +func (p *ChatGetParams) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p ChatGetParams) ToURLVals(path string) (string, error) { - values, err := StructValsToURLVals(&p) +func (p *ChatGetParams) ToURLVals(path string) (string, error) { + values, err := StructValsToURLVals(p) if err != nil { return "", err } @@ -144,8 +144,8 @@ func (p ChatGetParams) ToURLVals(path string) (string, error) { } // IsNil checks to see if any values has been set for the paramater -func (p ChatGetParams) IsNil() bool { - return p == (ChatGetParams{}) +func (p *ChatGetParams) IsNil() bool { + return *p == (ChatGetParams{}) } // ChatSendParams contains all the parameters to send to the API endpoint @@ -172,8 +172,8 @@ func (p ChatSendParams) ToURLVals(path string) (string, error) { } // IsNil checks to see if any values has been set for the paramater -func (p ChatSendParams) IsNil() bool { - return p == (ChatSendParams{}) +func (p *ChatSendParams) IsNil() bool { + return *p == (ChatSendParams{}) } // GenericRequestParams contains all the parameters for some general functions @@ -214,14 +214,14 @@ type GenericRequestParams struct { } // VerifyData verifies outgoing data sets -func (p GenericRequestParams) VerifyData() error { +func (p *GenericRequestParams) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p GenericRequestParams) ToURLVals(path string) (string, error) { - values, err := StructValsToURLVals(&p) +func (p *GenericRequestParams) ToURLVals(path string) (string, error) { + values, err := StructValsToURLVals(p) if err != nil { return "", err } @@ -229,8 +229,8 @@ func (p GenericRequestParams) ToURLVals(path string) (string, error) { } // IsNil checks to see if any values has been set for the paramater -func (p GenericRequestParams) IsNil() bool { - return p == (GenericRequestParams{}) +func (p *GenericRequestParams) IsNil() bool { + return *p == (GenericRequestParams{}) } // LeaderboardGetParams contains all the parameters to send to the API endpoint @@ -332,19 +332,19 @@ type OrderNewParams struct { } // VerifyData verifies outgoing data sets -func (p OrderNewParams) VerifyData() error { +func (p *OrderNewParams) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p OrderNewParams) ToURLVals(path string) (string, error) { +func (p *OrderNewParams) ToURLVals(path string) (string, error) { return "", nil } // IsNil checks to see if any values has been set for the paramater -func (p OrderNewParams) IsNil() bool { - return p == (OrderNewParams{}) +func (p *OrderNewParams) IsNil() bool { + return *p == (OrderNewParams{}) } // OrderAmendParams contains all the parameters to send to the API endpoint @@ -394,7 +394,7 @@ type OrderAmendParams struct { } // VerifyData verifies outgoing data sets -func (p OrderAmendParams) VerifyData() error { +func (p *OrderAmendParams) VerifyData() error { if p.OrderID == "" { return errors.New("verifydata() OrderNewParams error - OrderID not set") } @@ -403,13 +403,13 @@ func (p OrderAmendParams) VerifyData() error { // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p OrderAmendParams) ToURLVals(path string) (string, error) { +func (p *OrderAmendParams) ToURLVals(path string) (string, error) { return "", nil } // IsNil checks to see if any values has been set for the paramater -func (p OrderAmendParams) IsNil() bool { - return p == (OrderAmendParams{}) +func (p *OrderAmendParams) IsNil() bool { + return *p == (OrderAmendParams{}) } // OrderCancelParams contains all the parameters to send to the API endpoint @@ -773,19 +773,19 @@ type QuoteGetBucketedParams struct { } // VerifyData verifies outgoing data sets -func (p QuoteGetBucketedParams) VerifyData() error { +func (p *QuoteGetBucketedParams) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p QuoteGetBucketedParams) ToURLVals(path string) (string, error) { +func (p *QuoteGetBucketedParams) ToURLVals(path string) (string, error) { return "", nil } // IsNil checks to see if any values has been set for the paramater -func (p QuoteGetBucketedParams) IsNil() bool { - return p == (QuoteGetBucketedParams{}) +func (p *QuoteGetBucketedParams) IsNil() bool { + return *p == (QuoteGetBucketedParams{}) } // TradeGetBucketedParams contains all the parameters to send to the API @@ -834,19 +834,19 @@ type TradeGetBucketedParams struct { } // VerifyData verifies outgoing data sets -func (p TradeGetBucketedParams) VerifyData() error { +func (p *TradeGetBucketedParams) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p TradeGetBucketedParams) ToURLVals(path string) (string, error) { +func (p *TradeGetBucketedParams) ToURLVals(path string) (string, error) { return "", nil } // IsNil checks to see if any values has been set for the paramater -func (p TradeGetBucketedParams) IsNil() bool { - return p == (TradeGetBucketedParams{}) +func (p *TradeGetBucketedParams) IsNil() bool { + return *p == (TradeGetBucketedParams{}) } // UserUpdateParams contains all the parameters to send to the API endpoint @@ -871,19 +871,19 @@ type UserUpdateParams struct { } // VerifyData verifies outgoing data sets -func (p UserUpdateParams) VerifyData() error { +func (p *UserUpdateParams) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p UserUpdateParams) ToURLVals(path string) (string, error) { +func (p *UserUpdateParams) ToURLVals(path string) (string, error) { return "", nil } // IsNil checks to see if any values has been set for the paramater -func (p UserUpdateParams) IsNil() bool { - return p == (UserUpdateParams{}) +func (p *UserUpdateParams) IsNil() bool { + return *p == (UserUpdateParams{}) } // UserTokenParams contains all the parameters to send to the API endpoint @@ -1051,17 +1051,17 @@ type OrdersRequest struct { } // VerifyData verifies parameter data during SendAuthenticatedHTTPRequest -func (p OrdersRequest) VerifyData() error { +func (p *OrdersRequest) VerifyData() error { return nil } // ToURLVals converts struct values to url.values and encodes it on the supplied // path -func (p OrdersRequest) ToURLVals(path string) (string, error) { +func (p *OrdersRequest) ToURLVals(path string) (string, error) { return "", nil } // IsNil checks to see if any values has been set for the paramater -func (p OrdersRequest) IsNil() bool { - return p == (OrdersRequest{}) +func (p *OrdersRequest) IsNil() bool { + return *p == (OrdersRequest{}) } diff --git a/exchanges/bitmex/bitmex_test.go b/exchanges/bitmex/bitmex_test.go index 4e383617..3b3256e5 100644 --- a/exchanges/bitmex/bitmex_test.go +++ b/exchanges/bitmex/bitmex_test.go @@ -35,7 +35,7 @@ func TestSetup(t *testing.T) { bitmexConfig.APIKey = testAPIKey bitmexConfig.APISecret = testAPISecret - b.Setup(bitmexConfig) + b.Setup(&bitmexConfig) } func TestStart(t *testing.T) { diff --git a/exchanges/bitmex/bitmex_wrapper.go b/exchanges/bitmex/bitmex_wrapper.go index 6b6585a6..7c2b5ee2 100644 --- a/exchanges/bitmex/bitmex_wrapper.go +++ b/exchanges/bitmex/bitmex_wrapper.go @@ -76,7 +76,7 @@ func (b *Bitmex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tickerPrice.Pair = p tickerPrice.Last = tick[0].Price tickerPrice.Volume = float64(tick[0].Size) - return tickerPrice, ticker.ProcessTicker(b.Name, tickerPrice, assetType) + return tickerPrice, ticker.ProcessTicker(b.Name, &tickerPrice, assetType) } // GetTickerPrice returns the ticker for a currency pair diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index 5163e40a..efcde3e1 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -92,7 +92,7 @@ func (b *Bitstamp) SetDefaults() { } // Setup sets configuration values to bitstamp -func (b *Bitstamp) Setup(exch config.ExchangeConfig) { +func (b *Bitstamp) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -123,7 +123,7 @@ func (b *Bitstamp) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/bitstamp/bitstamp_test.go b/exchanges/bitstamp/bitstamp_test.go index 99a8d5d7..a2420a5d 100644 --- a/exchanges/bitstamp/bitstamp_test.go +++ b/exchanges/bitstamp/bitstamp_test.go @@ -51,7 +51,7 @@ func TestSetup(t *testing.T) { bConfig.APISecret = apiSecret bConfig.ClientID = customerID - b.Setup(bConfig) + b.Setup(&bConfig) b.ClientID = customerID if !b.IsEnabled() || b.RESTPollingDelay != time.Duration(10) || diff --git a/exchanges/bitstamp/bitstamp_wrapper.go b/exchanges/bitstamp/bitstamp_wrapper.go index 0070253d..96175161 100644 --- a/exchanges/bitstamp/bitstamp_wrapper.go +++ b/exchanges/bitstamp/bitstamp_wrapper.go @@ -75,7 +75,7 @@ func (b *Bitstamp) UpdateTicker(p currency.Pair, assetType string) (ticker.Price tickerPrice.Volume = tick.Volume tickerPrice.High = tick.High - err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index c678fde1..4aeecbc8 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -89,7 +89,7 @@ func (b *Bittrex) SetDefaults() { } // Setup method sets current configuration details if enabled -func (b *Bittrex) Setup(exch config.ExchangeConfig) { +func (b *Bittrex) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -115,7 +115,7 @@ func (b *Bittrex) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/bittrex/bittrex_test.go b/exchanges/bittrex/bittrex_test.go index 3e6c6965..4fd51faa 100644 --- a/exchanges/bittrex/bittrex_test.go +++ b/exchanges/bittrex/bittrex_test.go @@ -37,7 +37,7 @@ func TestSetup(t *testing.T) { bConfig.APISecret = apiSecret bConfig.AuthenticatedAPISupport = true - b.Setup(bConfig) + b.Setup(&bConfig) if !b.IsEnabled() || b.RESTPollingDelay != time.Duration(10) || b.Verbose || diff --git a/exchanges/bittrex/bittrex_wrapper.go b/exchanges/bittrex/bittrex_wrapper.go index 74d60b31..530a452c 100644 --- a/exchanges/bittrex/bittrex_wrapper.go +++ b/exchanges/bittrex/bittrex_wrapper.go @@ -121,7 +121,7 @@ func (b *Bittrex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tickerPrice.Bid = tick.Result[y].Bid tickerPrice.Last = tick.Result[y].Last tickerPrice.Volume = tick.Result[y].Volume - ticker.ProcessTicker(b.GetName(), tickerPrice, assetType) + ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType) } } return ticker.GetTicker(b.Name, p, assetType) diff --git a/exchanges/btcc/btcc.go b/exchanges/btcc/btcc.go index 1cce657a..4d3858d5 100644 --- a/exchanges/btcc/btcc.go +++ b/exchanges/btcc/btcc.go @@ -49,7 +49,7 @@ func (b *BTCC) SetDefaults() { } // Setup is run on startup to setup exchange with config values -func (b *BTCC) Setup(exch config.ExchangeConfig) { +func (b *BTCC) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -76,7 +76,7 @@ func (b *BTCC) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/btcc/btcc_test.go b/exchanges/btcc/btcc_test.go index 618d958f..14534de7 100644 --- a/exchanges/btcc/btcc_test.go +++ b/exchanges/btcc/btcc_test.go @@ -30,7 +30,7 @@ func TestSetup(t *testing.T) { if err != nil { t.Error("Test Failed - BTCC Setup() init error") } - b.Setup(bConfig) + b.Setup(&bConfig) if !b.IsEnabled() || b.AuthenticatedAPISupport || b.RESTPollingDelay != time.Duration(10) || b.Verbose || diff --git a/exchanges/btcmarkets/btcmarkets.go b/exchanges/btcmarkets/btcmarkets.go index 6bbdbfbb..d571774f 100644 --- a/exchanges/btcmarkets/btcmarkets.go +++ b/exchanges/btcmarkets/btcmarkets.go @@ -78,7 +78,7 @@ func (b *BTCMarkets) SetDefaults() { } // Setup takes in an exchange configuration and sets all parameters -func (b *BTCMarkets) Setup(exch config.ExchangeConfig) { +func (b *BTCMarkets) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -104,7 +104,7 @@ func (b *BTCMarkets) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/btcmarkets/btcmarkets_test.go b/exchanges/btcmarkets/btcmarkets_test.go index 7333e38e..6dd37fac 100644 --- a/exchanges/btcmarkets/btcmarkets_test.go +++ b/exchanges/btcmarkets/btcmarkets_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { bConfig.APISecret = apiSecret bConfig.AuthenticatedAPISupport = true - b.Setup(bConfig) + b.Setup(&bConfig) } func TestGetMarkets(t *testing.T) { diff --git a/exchanges/btcmarkets/btcmarkets_wrapper.go b/exchanges/btcmarkets/btcmarkets_wrapper.go index a3fbe15c..4e949bee 100644 --- a/exchanges/btcmarkets/btcmarkets_wrapper.go +++ b/exchanges/btcmarkets/btcmarkets_wrapper.go @@ -79,7 +79,7 @@ func (b *BTCMarkets) UpdateTicker(p currency.Pair, assetType string) (ticker.Pri tickerPrice.Bid = tick.BestBID tickerPrice.Last = tick.LastPrice - err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/btse/btse.go b/exchanges/btse/btse.go index 137982b6..0e377ebe 100644 --- a/exchanges/btse/btse.go +++ b/exchanges/btse/btse.go @@ -70,7 +70,7 @@ func (b *BTSE) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (b *BTSE) Setup(exch config.ExchangeConfig) { +func (b *BTSE) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { b.SetEnabled(false) } else { @@ -97,7 +97,7 @@ func (b *BTSE) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = b.SetAPIURL(&exch) + err = b.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/btse/btse_test.go b/exchanges/btse/btse_test.go index 6c43f374..2875e025 100644 --- a/exchanges/btse/btse_test.go +++ b/exchanges/btse/btse_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { btseConfig.APIKey = apiKey btseConfig.APISecret = apiSecret - b.Setup(btseConfig) + b.Setup(&btseConfig) } func TestGetMarkets(t *testing.T) { diff --git a/exchanges/btse/btse_wrapper.go b/exchanges/btse/btse_wrapper.go index ab2ba7eb..beb304d5 100644 --- a/exchanges/btse/btse_wrapper.go +++ b/exchanges/btse/btse_wrapper.go @@ -73,7 +73,7 @@ func (b *BTSE) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, er tickerPrice.Volume = s.Volume tickerPrice.High = s.High - err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/coinbasepro/coinbasepro.go b/exchanges/coinbasepro/coinbasepro.go index 6c1ae987..8d150706 100644 --- a/exchanges/coinbasepro/coinbasepro.go +++ b/exchanges/coinbasepro/coinbasepro.go @@ -92,7 +92,7 @@ func (c *CoinbasePro) SetDefaults() { } // Setup initialises the exchange parameters with the current configuration -func (c *CoinbasePro) Setup(exch config.ExchangeConfig) { +func (c *CoinbasePro) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { c.SetEnabled(false) } else { @@ -122,7 +122,7 @@ func (c *CoinbasePro) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = c.SetAPIURL(&exch) + err = c.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index 6ddfa962..7936b720 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { gdxConfig.APIKey = apiKey gdxConfig.APISecret = apiSecret gdxConfig.AuthenticatedAPISupport = true - c.Setup(gdxConfig) + c.Setup(&gdxConfig) } func TestGetProducts(t *testing.T) { diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index f569df78..fc7d4c5c 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -103,7 +103,7 @@ func (c *CoinbasePro) UpdateTicker(p currency.Pair, assetType string) (ticker.Pr tickerPrice.High = stats.High tickerPrice.Low = stats.Low - err = ticker.ProcessTicker(c.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(c.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/coinut/coinut.go b/exchanges/coinut/coinut.go index f282124e..fc96dcc2 100644 --- a/exchanges/coinut/coinut.go +++ b/exchanges/coinut/coinut.go @@ -81,7 +81,7 @@ func (c *COINUT) SetDefaults() { } // Setup sets the current exchange configuration -func (c *COINUT) Setup(exch config.ExchangeConfig) { +func (c *COINUT) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { c.SetEnabled(false) } else { @@ -108,7 +108,7 @@ func (c *COINUT) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = c.SetAPIURL(&exch) + err = c.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/coinut/coinut_test.go b/exchanges/coinut/coinut_test.go index 20f70218..e1e4a059 100644 --- a/exchanges/coinut/coinut_test.go +++ b/exchanges/coinut/coinut_test.go @@ -32,7 +32,7 @@ func TestSetup(t *testing.T) { } bConfig.AuthenticatedAPISupport = true bConfig.APIKey = apiKey - c.Setup(bConfig) + c.Setup(&bConfig) c.ClientID = clientID if !c.IsEnabled() || diff --git a/exchanges/coinut/coinut_wrapper.go b/exchanges/coinut/coinut_wrapper.go index ac778953..b5a32fec 100644 --- a/exchanges/coinut/coinut_wrapper.go +++ b/exchanges/coinut/coinut_wrapper.go @@ -147,7 +147,7 @@ func (c *COINUT) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tickerPrice.High = tick.HighestBuy tickerPrice.Low = tick.LowestSell - err = ticker.ProcessTicker(c.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(c.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/exchange.go b/exchanges/exchange.go index 5496bf4a..e695ef8c 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -289,7 +289,7 @@ type Base struct { // IBotExchange enforces standard functions for all exchanges supported in // GoCryptoTrader type IBotExchange interface { - Setup(exch config.ExchangeConfig) + Setup(exch *config.ExchangeConfig) Start(wg *sync.WaitGroup) SetDefaults() GetName() string diff --git a/exchanges/exmo/exmo.go b/exchanges/exmo/exmo.go index 5a32f132..2250bf67 100644 --- a/exchanges/exmo/exmo.go +++ b/exchanges/exmo/exmo.go @@ -77,7 +77,7 @@ func (e *EXMO) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func (e *EXMO) Setup(exch config.ExchangeConfig) { +func (e *EXMO) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { e.SetEnabled(false) } else { @@ -103,7 +103,7 @@ func (e *EXMO) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = e.SetAPIURL(&exch) + err = e.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/exmo/exmo_test.go b/exchanges/exmo/exmo_test.go index 4827c07a..24189feb 100644 --- a/exchanges/exmo/exmo_test.go +++ b/exchanges/exmo/exmo_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { exmoConf.APIKey = APIKey exmoConf.APISecret = APISecret - e.Setup(exmoConf) + e.Setup(&exmoConf) e.AuthenticatedAPISupport = true e.APIKey = APIKey diff --git a/exchanges/exmo/exmo_wrapper.go b/exchanges/exmo/exmo_wrapper.go index 2ea6bd10..a6219095 100644 --- a/exchanges/exmo/exmo_wrapper.go +++ b/exchanges/exmo/exmo_wrapper.go @@ -79,7 +79,7 @@ func (e *EXMO) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, er tickerPrice.Low = result[currency].Low tickerPrice.Volume = result[currency].Volume - err = ticker.ProcessTicker(e.Name, tickerPrice, assetType) + err = ticker.ProcessTicker(e.Name, &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 6af44af3..b8f41470 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -82,7 +82,7 @@ func (g *Gateio) SetDefaults() { } // Setup sets user configuration -func (g *Gateio) Setup(exch config.ExchangeConfig) { +func (g *Gateio) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { g.SetEnabled(false) } else { @@ -109,7 +109,7 @@ func (g *Gateio) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = g.SetAPIURL(&exch) + err = g.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index 8498923c..4ef3923f 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { gateioConfig.APIKey = apiKey gateioConfig.APISecret = apiSecret - g.Setup(gateioConfig) + g.Setup(&gateioConfig) } func TestGetSymbols(t *testing.T) { diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index 27c20750..a0c1f563 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -68,7 +68,7 @@ func (g *Gateio) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tp.Low = result[currency].Low tp.Volume = result[currency].Volume - err = ticker.ProcessTicker(g.Name, tp, assetType) + err = ticker.ProcessTicker(g.Name, &tp, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index 72d7ea48..4f933cff 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -127,7 +127,7 @@ func (g *Gemini) SetDefaults() { } // Setup sets exchange configuration parameters -func (g *Gemini) Setup(exch config.ExchangeConfig) { +func (g *Gemini) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { g.SetEnabled(false) } else { @@ -154,7 +154,7 @@ func (g *Gemini) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = g.SetAPIURL(&exch) + err = g.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/gemini/gemini_test.go b/exchanges/gemini/gemini_test.go index 85bdf3df..0037befb 100644 --- a/exchanges/gemini/gemini_test.go +++ b/exchanges/gemini/gemini_test.go @@ -63,8 +63,8 @@ func TestSetup(t *testing.T) { geminiConfig.AuthenticatedAPISupport = true - Session[1].Setup(geminiConfig) - Session[2].Setup(geminiConfig) + Session[1].Setup(&geminiConfig) + Session[2].Setup(&geminiConfig) Session[1].APIKey = apiKey1 Session[1].APISecret = apiSecret1 diff --git a/exchanges/gemini/gemini_wrapper.go b/exchanges/gemini/gemini_wrapper.go index 3d406315..606be83f 100644 --- a/exchanges/gemini/gemini_wrapper.go +++ b/exchanges/gemini/gemini_wrapper.go @@ -89,7 +89,7 @@ func (g *Gemini) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tickerPrice.Last = tick.Last tickerPrice.Volume = tick.Volume.USD - err = ticker.ProcessTicker(g.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(g.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/hitbtc/hitbtc.go b/exchanges/hitbtc/hitbtc.go index d092b5e2..fc8c1a5a 100644 --- a/exchanges/hitbtc/hitbtc.go +++ b/exchanges/hitbtc/hitbtc.go @@ -84,7 +84,7 @@ func (h *HitBTC) SetDefaults() { } // Setup sets user exchange configuration settings -func (h *HitBTC) Setup(exch config.ExchangeConfig) { +func (h *HitBTC) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { h.SetEnabled(false) } else { @@ -111,7 +111,7 @@ func (h *HitBTC) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = h.SetAPIURL(&exch) + err = h.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/hitbtc/hitbtc_test.go b/exchanges/hitbtc/hitbtc_test.go index a4f4c2dc..a0a23aeb 100644 --- a/exchanges/hitbtc/hitbtc_test.go +++ b/exchanges/hitbtc/hitbtc_test.go @@ -33,7 +33,7 @@ func TestSetup(t *testing.T) { hitbtcConfig.APIKey = apiKey hitbtcConfig.APISecret = apiSecret - h.Setup(hitbtcConfig) + h.Setup(&hitbtcConfig) } func TestGetOrderbook(t *testing.T) { diff --git a/exchanges/hitbtc/hitbtc_wrapper.go b/exchanges/hitbtc/hitbtc_wrapper.go index 2e8d8985..278fa89a 100644 --- a/exchanges/hitbtc/hitbtc_wrapper.go +++ b/exchanges/hitbtc/hitbtc_wrapper.go @@ -91,7 +91,7 @@ func (h *HitBTC) UpdateTicker(currencyPair currency.Pair, assetType string) (tic tp.Low = tick[curr].Low tp.Volume = tick[curr].Volume - err = ticker.ProcessTicker(h.GetName(), tp, assetType) + err = ticker.ProcessTicker(h.GetName(), &tp, assetType) if err != nil { return ticker.Price{}, err } diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index d633c116..439fcd06 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -99,7 +99,7 @@ func (h *HUOBI) SetDefaults() { } // Setup sets user configuration -func (h *HUOBI) Setup(exch config.ExchangeConfig) { +func (h *HUOBI) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { h.SetEnabled(false) } else { @@ -128,7 +128,7 @@ func (h *HUOBI) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = h.SetAPIURL(&exch) + err = h.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/huobi/huobi_test.go b/exchanges/huobi/huobi_test.go index 95f44ad0..156b316f 100644 --- a/exchanges/huobi/huobi_test.go +++ b/exchanges/huobi/huobi_test.go @@ -69,7 +69,7 @@ func TestSetup(t *testing.T) { hConfig.APIKey = apiKey hConfig.APISecret = apiSecret - h.Setup(hConfig) + h.Setup(&hConfig) } func TestGetSpotKline(t *testing.T) { diff --git a/exchanges/huobi/huobi_wrapper.go b/exchanges/huobi/huobi_wrapper.go index 48746052..50573bb0 100644 --- a/exchanges/huobi/huobi_wrapper.go +++ b/exchanges/huobi/huobi_wrapper.go @@ -117,7 +117,7 @@ func (h *HUOBI) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, e tickerPrice.Bid = tick.Bid[0] } - err = ticker.ProcessTicker(h.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(h.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/huobihadax/huobihadax.go b/exchanges/huobihadax/huobihadax.go index f63502aa..9a5f1b44 100644 --- a/exchanges/huobihadax/huobihadax.go +++ b/exchanges/huobihadax/huobihadax.go @@ -94,7 +94,7 @@ func (h *HUOBIHADAX) SetDefaults() { } // Setup sets user configuration -func (h *HUOBIHADAX) Setup(exch config.ExchangeConfig) { +func (h *HUOBIHADAX) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { h.SetEnabled(false) } else { @@ -122,7 +122,7 @@ func (h *HUOBIHADAX) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = h.SetAPIURL(&exch) + err = h.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/huobihadax/huobihadax_test.go b/exchanges/huobihadax/huobihadax_test.go index f7aad877..b7af942c 100644 --- a/exchanges/huobihadax/huobihadax_test.go +++ b/exchanges/huobihadax/huobihadax_test.go @@ -65,7 +65,7 @@ func TestSetup(t *testing.T) { hadaxConfig.APIKey = apiKey hadaxConfig.APISecret = apiSecret - h.Setup(hadaxConfig) + h.Setup(&hadaxConfig) } func TestGetSpotKline(t *testing.T) { diff --git a/exchanges/huobihadax/huobihadax_wrapper.go b/exchanges/huobihadax/huobihadax_wrapper.go index e806137e..c975ae82 100644 --- a/exchanges/huobihadax/huobihadax_wrapper.go +++ b/exchanges/huobihadax/huobihadax_wrapper.go @@ -74,7 +74,7 @@ func (h *HUOBIHADAX) UpdateTicker(p currency.Pair, assetType string) (ticker.Pri tickerPrice.Bid = tick.Bid[0] } - err = ticker.ProcessTicker(h.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(h.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/itbit/itbit.go b/exchanges/itbit/itbit.go index a7c47e65..1cd836ef 100644 --- a/exchanges/itbit/itbit.go +++ b/exchanges/itbit/itbit.go @@ -69,7 +69,7 @@ func (i *ItBit) SetDefaults() { } // Setup sets the exchange parameters from exchange config -func (i *ItBit) Setup(exch config.ExchangeConfig) { +func (i *ItBit) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { i.SetEnabled(false) } else { @@ -95,7 +95,7 @@ func (i *ItBit) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = i.SetAPIURL(&exch) + err = i.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/itbit/itbit_test.go b/exchanges/itbit/itbit_test.go index 26e297c1..87f1aacf 100644 --- a/exchanges/itbit/itbit_test.go +++ b/exchanges/itbit/itbit_test.go @@ -36,7 +36,7 @@ func TestSetup(t *testing.T) { itbitConfig.APISecret = apiSecret itbitConfig.ClientID = clientID - i.Setup(itbitConfig) + i.Setup(&itbitConfig) } func TestGetTicker(t *testing.T) { diff --git a/exchanges/itbit/itbit_wrapper.go b/exchanges/itbit/itbit_wrapper.go index 86deaf09..9663b542 100644 --- a/exchanges/itbit/itbit_wrapper.go +++ b/exchanges/itbit/itbit_wrapper.go @@ -50,7 +50,7 @@ func (i *ItBit) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, e tickerPrice.Low = tick.Low24h tickerPrice.Volume = tick.Volume24h - err = ticker.ProcessTicker(i.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(i.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index 93802410..1df51b07 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -99,7 +99,7 @@ func (k *Kraken) SetDefaults() { } // Setup sets current exchange configuration -func (k *Kraken) Setup(exch config.ExchangeConfig) { +func (k *Kraken) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { k.SetEnabled(false) } else { @@ -126,7 +126,7 @@ func (k *Kraken) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = k.SetAPIURL(&exch) + err = k.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index 3cf48bd6..b34ad7c8 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -36,7 +36,7 @@ func TestSetup(t *testing.T) { krakenConfig.APISecret = apiSecret krakenConfig.ClientID = clientID krakenConfig.WebsocketURL = k.WebsocketURL - k.Setup(krakenConfig) + k.Setup(&krakenConfig) } // TestGetServerTime API endpoint test diff --git a/exchanges/kraken/kraken_wrapper.go b/exchanges/kraken/kraken_wrapper.go index 7749292f..27a6ab4e 100644 --- a/exchanges/kraken/kraken_wrapper.go +++ b/exchanges/kraken/kraken_wrapper.go @@ -109,7 +109,7 @@ func (k *Kraken) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tp.High = z.High tp.Low = z.Low tp.Volume = z.Volume - ticker.ProcessTicker(k.GetName(), tp, assetType) + ticker.ProcessTicker(k.GetName(), &tp, assetType) } } return ticker.GetTicker(k.GetName(), p, assetType) diff --git a/exchanges/lakebtc/lakebtc.go b/exchanges/lakebtc/lakebtc.go index f12d7e48..11fe0d0f 100644 --- a/exchanges/lakebtc/lakebtc.go +++ b/exchanges/lakebtc/lakebtc.go @@ -69,7 +69,7 @@ func (l *LakeBTC) SetDefaults() { } // Setup sets exchange configuration profile -func (l *LakeBTC) Setup(exch config.ExchangeConfig) { +func (l *LakeBTC) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { l.SetEnabled(false) } else { @@ -95,7 +95,7 @@ func (l *LakeBTC) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = l.SetAPIURL(&exch) + err = l.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/lakebtc/lakebtc_test.go b/exchanges/lakebtc/lakebtc_test.go index 6c0e78b5..3d037a85 100644 --- a/exchanges/lakebtc/lakebtc_test.go +++ b/exchanges/lakebtc/lakebtc_test.go @@ -33,7 +33,7 @@ func TestSetup(t *testing.T) { lakebtcConfig.APIKey = apiKey lakebtcConfig.APISecret = apiSecret - l.Setup(lakebtcConfig) + l.Setup(&lakebtcConfig) } func TestGetTradablePairs(t *testing.T) { diff --git a/exchanges/lakebtc/lakebtc_wrapper.go b/exchanges/lakebtc/lakebtc_wrapper.go index dd61d621..271e3270 100644 --- a/exchanges/lakebtc/lakebtc_wrapper.go +++ b/exchanges/lakebtc/lakebtc_wrapper.go @@ -67,7 +67,7 @@ func (l *LakeBTC) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, tickerPrice.Low = tick[currency].Low tickerPrice.Last = tick[currency].Last - err = ticker.ProcessTicker(l.GetName(), tickerPrice, assetType) + err = ticker.ProcessTicker(l.GetName(), &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/localbitcoins/localbitcoins.go b/exchanges/localbitcoins/localbitcoins.go index b2427ab2..4606333a 100644 --- a/exchanges/localbitcoins/localbitcoins.go +++ b/exchanges/localbitcoins/localbitcoins.go @@ -138,7 +138,7 @@ func (l *LocalBitcoins) SetDefaults() { } // Setup sets exchange configuration parameters -func (l *LocalBitcoins) Setup(exch config.ExchangeConfig) { +func (l *LocalBitcoins) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { l.SetEnabled(false) } else { @@ -160,7 +160,7 @@ func (l *LocalBitcoins) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = l.SetAPIURL(&exch) + err = l.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/localbitcoins/localbitcoins_test.go b/exchanges/localbitcoins/localbitcoins_test.go index 1bd80fc0..57d7636c 100644 --- a/exchanges/localbitcoins/localbitcoins_test.go +++ b/exchanges/localbitcoins/localbitcoins_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { localbitcoinsConfig.APIKey = apiKey localbitcoinsConfig.APISecret = apiSecret - l.Setup(localbitcoinsConfig) + l.Setup(&localbitcoinsConfig) } func TestGetTicker(t *testing.T) { diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index 3561bfd3..5e448850 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -72,7 +72,7 @@ func (l *LocalBitcoins) UpdateTicker(p currency.Pair, assetType string) (ticker. tp.Last = tick[currency].Avg24h tp.Volume = tick[currency].VolumeBTC - err = ticker.ProcessTicker(l.GetName(), tp, assetType) + err = ticker.ProcessTicker(l.GetName(), &tp, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/okcoin/okcoin_test.go b/exchanges/okcoin/okcoin_test.go index 74e7aaf9..5ddba65a 100644 --- a/exchanges/okcoin/okcoin_test.go +++ b/exchanges/okcoin/okcoin_test.go @@ -67,7 +67,7 @@ func TestSetup(t *testing.T) { okcoinConfig.APISecret = apiSecret okcoinConfig.ClientID = passphrase okcoinConfig.WebsocketURL = o.WebsocketURL - o.Setup(okcoinConfig) + o.Setup(&okcoinConfig) testSetupRan = true } diff --git a/exchanges/okex/okex_test.go b/exchanges/okex/okex_test.go index 343a6b49..2021c02f 100644 --- a/exchanges/okex/okex_test.go +++ b/exchanges/okex/okex_test.go @@ -68,7 +68,7 @@ func TestSetup(t *testing.T) { okexConfig.APISecret = apiSecret okexConfig.ClientID = passphrase okexConfig.WebsocketURL = o.WebsocketURL - o.Setup(okexConfig) + o.Setup(&okexConfig) testSetupRan = true } diff --git a/exchanges/okgroup/okgroup.go b/exchanges/okgroup/okgroup.go index acd48525..dfbec673 100644 --- a/exchanges/okgroup/okgroup.go +++ b/exchanges/okgroup/okgroup.go @@ -103,7 +103,7 @@ type OKGroup struct { } // Setup method sets current configuration details if enabled -func (o *OKGroup) Setup(exch config.ExchangeConfig) { +func (o *OKGroup) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { o.SetEnabled(false) } else { @@ -131,7 +131,7 @@ func (o *OKGroup) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = o.SetAPIURL(&exch) + err = o.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/okgroup/okgroup_wrapper.go b/exchanges/okgroup/okgroup_wrapper.go index 0e4f08a9..42e031ab 100644 --- a/exchanges/okgroup/okgroup_wrapper.go +++ b/exchanges/okgroup/okgroup_wrapper.go @@ -70,7 +70,7 @@ func (o *OKGroup) UpdateTicker(p currency.Pair, assetType string) (tickerData ti Volume: resp.BaseVolume24h, } - err = ticker.ProcessTicker(o.Name, tickerData, assetType) + err = ticker.ProcessTicker(o.Name, &tickerData, assetType) return } diff --git a/exchanges/orderbook/orderbook.go b/exchanges/orderbook/orderbook.go index f5302348..d225985c 100644 --- a/exchanges/orderbook/orderbook.go +++ b/exchanges/orderbook/orderbook.go @@ -137,7 +137,7 @@ func QuoteCurrencyExists(exchange string, p currency.Pair) bool { } // CreateNewOrderbook creates a new orderbook -func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType string) *Orderbook { +func CreateNewOrderbook(exchangeName string, orderbookNew *Base, orderbookType string) *Orderbook { m.Lock() defer m.Unlock() orderbook := Orderbook{} @@ -145,7 +145,7 @@ func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType st orderbook.Orderbook = make(map[*currency.Item]map[*currency.Item]map[string]Base) a := make(map[*currency.Item]map[string]Base) b := make(map[string]Base) - b[orderbookType] = orderbookNew + b[orderbookType] = *orderbookNew a[orderbookNew.Pair.Quote.Item] = b orderbook.Orderbook[orderbookNew.Pair.Base.Item] = a Orderbooks = append(Orderbooks, orderbook) @@ -154,7 +154,7 @@ func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType st // Process processes incoming orderbooks, creating or updating the orderbook // list -func (o Base) Process() error { +func (o *Base) Process() error { if o.Pair.IsEmpty() { return errors.New("orderbook currency pair not populated") } @@ -176,7 +176,7 @@ func (o Base) Process() error { if BaseCurrencyExists(o.ExchangeName, o.Pair.Base) { m.Lock() a := make(map[string]Base) - a[o.AssetType] = o + a[o.AssetType] = *o orderbook.Orderbook[o.Pair.Base.Item][o.Pair.Quote.Item] = a m.Unlock() return nil @@ -185,7 +185,7 @@ func (o Base) Process() error { m.Lock() a := make(map[*currency.Item]map[string]Base) b := make(map[string]Base) - b[o.AssetType] = o + b[o.AssetType] = *o a[o.Pair.Quote.Item] = b orderbook.Orderbook[o.Pair.Base.Item] = a m.Unlock() diff --git a/exchanges/orderbook/orderbook_test.go b/exchanges/orderbook/orderbook_test.go index 86ec0668..b18cefc5 100644 --- a/exchanges/orderbook/orderbook_test.go +++ b/exchanges/orderbook/orderbook_test.go @@ -79,7 +79,7 @@ func TestGetOrderbook(t *testing.T) { Bids: []Item{{Price: 200, Amount: 10}}, } - CreateNewOrderbook("Exchange", base, Spot) + CreateNewOrderbook("Exchange", &base, Spot) result, err := Get("Exchange", c, Spot) if err != nil { @@ -116,7 +116,7 @@ func TestGetOrderbookByExchange(t *testing.T) { Bids: []Item{{Price: 200, Amount: 10}}, } - CreateNewOrderbook("Exchange", base, Spot) + CreateNewOrderbook("Exchange", &base, Spot) _, err := GetByExchange("Exchange") if err != nil { @@ -138,7 +138,7 @@ func TestFirstCurrencyExists(t *testing.T) { Bids: []Item{{Price: 200, Amount: 10}}, } - CreateNewOrderbook("Exchange", base, Spot) + CreateNewOrderbook("Exchange", &base, Spot) if !BaseCurrencyExists("Exchange", c.Base) { t.Fatal("Test failed. TestFirstCurrencyExists expected first currency doesn't exist") @@ -158,7 +158,7 @@ func TestSecondCurrencyExists(t *testing.T) { Bids: []Item{{Price: 200, Amount: 10}}, } - CreateNewOrderbook("Exchange", base, Spot) + CreateNewOrderbook("Exchange", &base, Spot) if !QuoteCurrencyExists("Exchange", c) { t.Fatal("Test failed. TestSecondCurrencyExists expected first currency doesn't exist") @@ -178,7 +178,7 @@ func TestCreateNewOrderbook(t *testing.T) { Bids: []Item{{Price: 200, Amount: 10}}, } - CreateNewOrderbook("Exchange", base, Spot) + CreateNewOrderbook("Exchange", &base, Spot) result, err := Get("Exchange", c, Spot) if err != nil { diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index 22c01f35..689ad54e 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -90,7 +90,7 @@ func (p *Poloniex) SetDefaults() { } // Setup sets user exchange configuration settings -func (p *Poloniex) Setup(exch config.ExchangeConfig) { +func (p *Poloniex) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { p.SetEnabled(false) } else { @@ -117,7 +117,7 @@ func (p *Poloniex) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = p.SetAPIURL(&exch) + err = p.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/poloniex/poloniex_test.go b/exchanges/poloniex/poloniex_test.go index f7a55694..e18be2c3 100644 --- a/exchanges/poloniex/poloniex_test.go +++ b/exchanges/poloniex/poloniex_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { poloniexConfig.APIKey = apiKey poloniexConfig.APISecret = apiSecret - p.Setup(poloniexConfig) + p.Setup(&poloniexConfig) } func TestGetTicker(t *testing.T) { diff --git a/exchanges/poloniex/poloniex_wrapper.go b/exchanges/poloniex/poloniex_wrapper.go index c6210e8f..87c4987c 100644 --- a/exchanges/poloniex/poloniex_wrapper.go +++ b/exchanges/poloniex/poloniex_wrapper.go @@ -75,7 +75,7 @@ func (p *Poloniex) UpdateTicker(currencyPair currency.Pair, assetType string) (t tp.Low = tick[curr].Low24Hr tp.Volume = tick[curr].BaseVolume - err = ticker.ProcessTicker(p.GetName(), tp, assetType) + err = ticker.ProcessTicker(p.GetName(), &tp, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/ticker/ticker.go b/exchanges/ticker/ticker.go index 3a3f37ea..4b75fd27 100644 --- a/exchanges/ticker/ticker.go +++ b/exchanges/ticker/ticker.go @@ -131,7 +131,7 @@ func SecondCurrencyExists(exchange string, p currency.Pair) bool { } // CreateNewTicker creates a new Ticker -func CreateNewTicker(exchangeName string, tickerNew Price, tickerType string) Ticker { +func CreateNewTicker(exchangeName string, tickerNew *Price, tickerType string) Ticker { m.Lock() defer m.Unlock() ticker := Ticker{} @@ -139,7 +139,7 @@ func CreateNewTicker(exchangeName string, tickerNew Price, tickerType string) Ti ticker.Price = make(map[string]map[string]map[string]Price) a := make(map[string]map[string]Price) b := make(map[string]Price) - b[tickerType] = tickerNew + b[tickerType] = *tickerNew a[tickerNew.Pair.Quote.Upper().String()] = b ticker.Price[tickerNew.Pair.Base.Upper().String()] = a Tickers = append(Tickers, ticker) @@ -148,7 +148,7 @@ func CreateNewTicker(exchangeName string, tickerNew Price, tickerType string) Ti // ProcessTicker processes incoming tickers, creating or updating the Tickers // list -func ProcessTicker(exchangeName string, tickerNew Price, tickerType string) error { +func ProcessTicker(exchangeName string, tickerNew *Price, tickerType string) error { if tickerNew.Pair.String() == "" { return errors.New("") } @@ -164,7 +164,7 @@ func ProcessTicker(exchangeName string, tickerNew Price, tickerType string) erro if FirstCurrencyExists(exchangeName, tickerNew.Pair.Base) { m.Lock() a := make(map[string]Price) - a[tickerType] = tickerNew + a[tickerType] = *tickerNew ticker.Price[tickerNew.Pair.Base.Upper().String()][tickerNew.Pair.Quote.Upper().String()] = a m.Unlock() return nil @@ -173,7 +173,7 @@ func ProcessTicker(exchangeName string, tickerNew Price, tickerType string) erro m.Lock() a := make(map[string]map[string]Price) b := make(map[string]Price) - b[tickerType] = tickerNew + b[tickerType] = *tickerNew a[tickerNew.Pair.Quote.Upper().String()] = b ticker.Price[tickerNew.Pair.Base.Upper().String()] = a m.Unlock() diff --git a/exchanges/ticker/ticker_test.go b/exchanges/ticker/ticker_test.go index be49baef..0b969afd 100644 --- a/exchanges/ticker/ticker_test.go +++ b/exchanges/ticker/ticker_test.go @@ -25,7 +25,7 @@ func TestPriceToString(t *testing.T) { PriceATH: 1337, } - newTicker := CreateNewTicker("ANX", priceStruct, Spot) + newTicker := CreateNewTicker("ANX", &priceStruct, Spot) if newTicker.PriceToString(newPair, "last", Spot) != "1200" { t.Error("Test Failed - ticker PriceToString last value is incorrect") @@ -66,7 +66,7 @@ func TestGetTicker(t *testing.T) { PriceATH: 1337, } - err := ProcessTicker("bitfinex", priceStruct, Spot) + err := ProcessTicker("bitfinex", &priceStruct, Spot) if err != nil { t.Fatal("Test failed. ProcessTicker error", err) } @@ -98,7 +98,7 @@ func TestGetTicker(t *testing.T) { priceStruct.PriceATH = 9001 priceStruct.Pair.Base = currency.ETH - err = ProcessTicker("bitfinex", priceStruct, "futures_3m") + err = ProcessTicker("bitfinex", &priceStruct, "futures_3m") if err != nil { t.Fatal("Test failed. ProcessTicker error", err) } @@ -126,7 +126,7 @@ func TestGetTickerByExchange(t *testing.T) { PriceATH: 1337, } - anxTicker := CreateNewTicker("ANX", priceStruct, Spot) + anxTicker := CreateNewTicker("ANX", &priceStruct, Spot) Tickers = append(Tickers, anxTicker) tickerPtr, err := GetTickerByExchange("ANX") @@ -151,7 +151,7 @@ func TestFirstCurrencyExists(t *testing.T) { PriceATH: 1337, } - alphaTicker := CreateNewTicker("alphapoint", priceStruct, Spot) + alphaTicker := CreateNewTicker("alphapoint", &priceStruct, Spot) Tickers = append(Tickers, alphaTicker) if !FirstCurrencyExists("alphapoint", currency.BTC) { @@ -177,7 +177,7 @@ func TestSecondCurrencyExists(t *testing.T) { PriceATH: 1337, } - bitstampTicker := CreateNewTicker("bitstamp", priceStruct, "SPOT") + bitstampTicker := CreateNewTicker("bitstamp", &priceStruct, "SPOT") Tickers = append(Tickers, bitstampTicker) if !SecondCurrencyExists("bitstamp", newPair) { @@ -204,7 +204,7 @@ func TestCreateNewTicker(t *testing.T) { PriceATH: 1337, } - newTicker := CreateNewTicker("ANX", priceStruct, Spot) + newTicker := CreateNewTicker("ANX", &priceStruct, Spot) if reflect.ValueOf(newTicker).NumField() != 2 { t.Error("Test Failed - ticker CreateNewTicker struct change/or updated") @@ -259,12 +259,12 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers PriceATH: 1337, } - err := ProcessTicker("btcc", Price{}, Spot) + err := ProcessTicker("btcc", &Price{}, Spot) if err == nil { t.Fatal("Test failed. ProcessTicker error cannot be nil") } - err = ProcessTicker("btcc", priceStruct, Spot) + err = ProcessTicker("btcc", &priceStruct, Spot) if err != nil { t.Fatal("Test failed. ProcessTicker error", err) } @@ -280,7 +280,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers secondPair := currency.NewPairFromStrings("BTC", "AUD") priceStruct.Pair = secondPair - err = ProcessTicker("btcc", priceStruct, Spot) + err = ProcessTicker("btcc", &priceStruct, Spot) if err != nil { t.Fatal("Test failed. ProcessTicker error", err) } @@ -326,7 +326,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers } sm.Lock() - err = ProcessTicker(newName, tp, Spot) + err = ProcessTicker(newName, &tp, Spot) if err != nil { log.Error(err) catastrophicFailure = true diff --git a/exchanges/yobit/yobit.go b/exchanges/yobit/yobit.go index 8fa6a9bf..40694725 100644 --- a/exchanges/yobit/yobit.go +++ b/exchanges/yobit/yobit.go @@ -78,7 +78,7 @@ func (y *Yobit) SetDefaults() { } // Setup sets exchange configuration parameters for Yobit -func (y *Yobit) Setup(exch config.ExchangeConfig) { +func (y *Yobit) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { y.SetEnabled(false) } else { @@ -105,7 +105,7 @@ func (y *Yobit) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = y.SetAPIURL(&exch) + err = y.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/yobit/yobit_test.go b/exchanges/yobit/yobit_test.go index fda86c56..269f5835 100644 --- a/exchanges/yobit/yobit_test.go +++ b/exchanges/yobit/yobit_test.go @@ -35,7 +35,7 @@ func TestSetup(t *testing.T) { conf.APISecret = apiSecret conf.AuthenticatedAPISupport = true - y.Setup(conf) + y.Setup(&conf) } func TestGetInfo(t *testing.T) { diff --git a/exchanges/yobit/yobit_wrapper.go b/exchanges/yobit/yobit_wrapper.go index 7505599f..c783c1cf 100644 --- a/exchanges/yobit/yobit_wrapper.go +++ b/exchanges/yobit/yobit_wrapper.go @@ -59,7 +59,7 @@ func (y *Yobit) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, e tickerPrice.Low = result[currency].Low tickerPrice.Volume = result[currency].VolumeCurrent - err = ticker.ProcessTicker(y.Name, tickerPrice, assetType) + err = ticker.ProcessTicker(y.Name, &tickerPrice, assetType) if err != nil { return tickerPrice, err } diff --git a/exchanges/zb/zb.go b/exchanges/zb/zb.go index 31b5292e..193e2d5f 100644 --- a/exchanges/zb/zb.go +++ b/exchanges/zb/zb.go @@ -82,7 +82,7 @@ func (z *ZB) SetDefaults() { } // Setup sets user configuration -func (z *ZB) Setup(exch config.ExchangeConfig) { +func (z *ZB) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { z.SetEnabled(false) } else { @@ -110,7 +110,7 @@ func (z *ZB) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = z.SetAPIURL(&exch) + err = z.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/exchanges/zb/zb_test.go b/exchanges/zb/zb_test.go index 675193e4..707f94f8 100644 --- a/exchanges/zb/zb_test.go +++ b/exchanges/zb/zb_test.go @@ -34,7 +34,7 @@ func TestSetup(t *testing.T) { zbConfig.APIKey = apiKey zbConfig.APISecret = apiSecret - z.Setup(zbConfig) + z.Setup(&zbConfig) } func TestSpotNewOrder(t *testing.T) { diff --git a/exchanges/zb/zb_wrapper.go b/exchanges/zb/zb_wrapper.go index 306104ca..abbea0cc 100644 --- a/exchanges/zb/zb_wrapper.go +++ b/exchanges/zb/zb_wrapper.go @@ -76,7 +76,7 @@ func (z *ZB) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, erro tp.Low = result[currency].Low tp.Volume = result[currency].Vol - err = ticker.ProcessTicker(z.Name, tp, assetType) + err = ticker.ProcessTicker(z.Name, &tp, assetType) if err != nil { return tickerPrice, err } diff --git a/helpers_test.go b/helpers_test.go index 1036561d..2fc3d1a5 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -303,7 +303,7 @@ func TestGetSpecificTicker(t *testing.T) { p := currency.NewPairFromStrings("BTC", "USD") err := ticker.ProcessTicker("Bitstamp", - ticker.Price{Pair: p, Last: 1000}, + &ticker.Price{Pair: p, Last: 1000}, ticker.Spot) if err != nil { t.Fatal("Test failed. ProcessTicker error", err) diff --git a/main.go b/main.go index ffd2c4bd..6edd9a51 100644 --- a/main.go +++ b/main.go @@ -136,7 +136,7 @@ func main() { FxFixer: *FxFixer, FxOpenExchangeRates: *FxOpenExchangeRates, }, - currency.MainConfiguration{ + ¤cy.MainConfiguration{ ForexProviders: newFxSettings, CryptocurrencyProvider: coinmarketcap.Settings(bot.config.Currency.CryptocurrencyProvider), Cryptocurrencies: bot.config.Currency.Cryptocurrencies, diff --git a/tools/exchange_template/main_file.tmpl b/tools/exchange_template/main_file.tmpl index ddae83ca..029cc56e 100644 --- a/tools/exchange_template/main_file.tmpl +++ b/tools/exchange_template/main_file.tmpl @@ -50,7 +50,7 @@ func ({{.Variable}} *{{.CapitalName}}) SetDefaults() { } // Setup takes in the supplied exchange configuration details and sets params -func ({{.Variable}} *{{.CapitalName}}) Setup(exch config.ExchangeConfig) { +func ({{.Variable}} *{{.CapitalName}}) Setup(exch *config.ExchangeConfig) { if !exch.Enabled { {{.Variable}}.SetEnabled(false) } else { @@ -77,7 +77,7 @@ func ({{.Variable}} *{{.CapitalName}}) Setup(exch config.ExchangeConfig) { if err != nil { log.Fatal(err) } - err = {{.Variable}}.SetAPIURL(&exch) + err = {{.Variable}}.SetAPIURL(exch) if err != nil { log.Fatal(err) } diff --git a/tools/exchange_template/wrapper_file.tmpl b/tools/exchange_template/wrapper_file.tmpl index 1b80b247..143068b3 100644 --- a/tools/exchange_template/wrapper_file.tmpl +++ b/tools/exchange_template/wrapper_file.tmpl @@ -50,7 +50,7 @@ func ({{.Variable}} *{{.CapitalName}}) UpdateTicker(p currency.Pair, assetType s // tickerPrice.Last = tick[y].LastPrice // tickerPrice.Low = tick[y].LowPrice // tickerPrice.Volume = tick[y].Volume - // ticker.ProcessTicker({{.Variable}}.Name, x, tickerPrice, assetType) + // ticker.ProcessTicker({{.Variable}}.Name, x, &tickerPrice, assetType) // } // } //}