diff --git a/config/config.go b/config/config.go index df43411c..c2c0c687 100644 --- a/config/config.go +++ b/config/config.go @@ -1313,7 +1313,7 @@ func (c *Config) LoadConfig(configPath string) error { } // UpdateConfig updates the config with a supplied config file -func (c *Config) UpdateConfig(configPath string, newCfg Config) error { +func (c *Config) UpdateConfig(configPath string, newCfg *Config) error { err := newCfg.CheckConfig() if err != nil { return err diff --git a/config/config_test.go b/config/config_test.go index 382d93f1..46a526ba 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -916,18 +916,18 @@ func TestUpdateConfig(t *testing.T) { } newCfg := c - err = c.UpdateConfig(ConfigTestFile, newCfg) + err = c.UpdateConfig(ConfigTestFile, &newCfg) if err != nil { t.Fatalf("Test failed. %s", err) } - err = c.UpdateConfig("//non-existantpath\\", newCfg) + err = c.UpdateConfig("//non-existantpath\\", &newCfg) if err == nil { t.Fatalf("Test failed. Error should of been thrown for invalid path") } newCfg.Currency.Cryptocurrencies = currency.NewCurrenciesFromStringArray([]string{""}) - err = c.UpdateConfig(ConfigTestFile, newCfg) + err = c.UpdateConfig(ConfigTestFile, &newCfg) if err != nil { t.Errorf("Test failed. %s", err) } @@ -936,6 +936,20 @@ func TestUpdateConfig(t *testing.T) { } } +func BenchmarkUpdateConfig(b *testing.B) { + var c Config + + err := c.LoadConfig(ConfigTestFile) + if err != nil { + b.Errorf("Unable to benchmark UpdateConfig(): %s", err) + } + + newCfg := c + for i := 0; i < b.N; i++ { + _ = c.UpdateConfig(ConfigTestFile, &newCfg) + } +} + func TestCheckLoggerConfig(t *testing.T) { c := GetConfig() err := c.LoadConfig(ConfigTestFile) diff --git a/exchanges/alphapoint/alphapoint_test.go b/exchanges/alphapoint/alphapoint_test.go index 6b16b3ab..4de37dc0 100644 --- a/exchanges/alphapoint/alphapoint_test.go +++ b/exchanges/alphapoint/alphapoint_test.go @@ -498,7 +498,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := a.GetActiveOrders(getOrdersRequest) + _, err := a.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet(a) && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet(a) && err == nil { @@ -514,7 +514,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := a.GetOrderHistory(getOrdersRequest) + _, err := a.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet(a) && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet(a) && err == nil { @@ -568,7 +568,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.BTC, currency.LTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -594,7 +594,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.BTC, currency.LTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -636,7 +636,7 @@ func TestWithdraw(t *testing.T) { AddressTag: "0123456789", } - _, err := a.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := a.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected 'Not implemented', received %v", err) } @@ -652,7 +652,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := a.WithdrawFiatFunds(withdrawFiatRequest) + _, err := a.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err) } @@ -668,7 +668,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := a.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := a.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err) } diff --git a/exchanges/alphapoint/alphapoint_wrapper.go b/exchanges/alphapoint/alphapoint_wrapper.go index a3f61bd4..ef932568 100644 --- a/exchanges/alphapoint/alphapoint_wrapper.go +++ b/exchanges/alphapoint/alphapoint_wrapper.go @@ -157,7 +157,7 @@ func (a *Alphapoint) ModifyOrder(_ exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (a *Alphapoint) CancelOrder(order exchange.OrderCancellation) error { +func (a *Alphapoint) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { return err @@ -169,7 +169,7 @@ func (a *Alphapoint) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders for a given account -func (a *Alphapoint) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (a *Alphapoint) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { return exchange.CancelAllOrdersResponse{}, a.CancelAllExistingOrders(orderCancellation.AccountID) } @@ -207,18 +207,18 @@ func (a *Alphapoint) GetDepositAddress(cryptocurrency currency.Code, _ string) ( // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (a *Alphapoint) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (a *Alphapoint) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted -func (a *Alphapoint) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (a *Alphapoint) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func (a *Alphapoint) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (a *Alphapoint) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } @@ -228,13 +228,13 @@ func (a *Alphapoint) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (a *Alphapoint) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (a *Alphapoint) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return 0, common.ErrFunctionNotSupported } // GetActiveOrders retrieves any orders that are active/open // This function is not concurrency safe due to orderSide/orderType maps -func (a *Alphapoint) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (a *Alphapoint) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := a.GetOrders() if err != nil { return nil, err @@ -277,7 +277,7 @@ func (a *Alphapoint) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) // GetOrderHistory retrieves account order information // Can Limit response to specific order status // This function is not concurrency safe due to orderSide/orderType maps -func (a *Alphapoint) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (a *Alphapoint) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := a.GetOrders() if err != nil { return nil, err diff --git a/exchanges/anx/anx.go b/exchanges/anx/anx.go index 8f187a71..ddd0bbb7 100644 --- a/exchanges/anx/anx.go +++ b/exchanges/anx/anx.go @@ -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) } @@ -444,7 +444,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf } // GetFee returns an estimate of fee based on type of transaction -func (a *ANX) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (a *ANX) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/anx/anx_test.go b/exchanges/anx/anx_test.go index aac5d062..5f289827 100644 --- a/exchanges/anx/anx_test.go +++ b/exchanges/anx/anx_test.go @@ -128,8 +128,8 @@ func TestGetAPIKey(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -230,7 +230,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := a.GetActiveOrders(getOrdersRequest) + _, err := a.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -246,7 +246,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := a.GetOrderHistory(getOrdersRequest) + _, err := a.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -295,7 +295,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.BTC, currency.LTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -320,7 +320,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.BTC, currency.LTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -377,7 +377,7 @@ func TestWithdraw(t *testing.T) { AddressTag: "0123456789", } - _, err := a.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := a.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Withdraw failed to be placed: %v", err) } else if !areTestAPIKeysSet() && err == nil { @@ -395,7 +395,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := a.WithdrawFiatFunds(withdrawFiatRequest) + _, err := a.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -411,7 +411,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := a.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := a.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/anx/anx_wrapper.go b/exchanges/anx/anx_wrapper.go index e5608d08..cf7be131 100644 --- a/exchanges/anx/anx_wrapper.go +++ b/exchanges/anx/anx_wrapper.go @@ -294,14 +294,14 @@ func (a *ANX) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (a *ANX) CancelOrder(order exchange.OrderCancellation) error { +func (a *ANX) CancelOrder(order *exchange.OrderCancellation) error { orderIDs := []string{order.OrderID} _, err := a.CancelOrderByIDs(orderIDs) return err } // CancelAllOrders cancels all orders associated with a currency pair -func (a *ANX) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (a *ANX) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -342,20 +342,20 @@ func (a *ANX) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (a *ANX) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (a *ANX) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return a.Send(withdrawRequest.Currency.String(), withdrawRequest.Address, "", fmt.Sprintf("%v", withdrawRequest.Amount)) } // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (a *ANX) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (a *ANX) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { // Fiat withdrawals available via website return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func (a *ANX) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (a *ANX) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { // Fiat withdrawals available via website return "", common.ErrFunctionNotSupported } @@ -366,12 +366,12 @@ func (a *ANX) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (a *ANX) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (a *ANX) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return a.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (a *ANX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (a *ANX) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := a.GetOrderList(true) if err != nil { return nil, err @@ -407,7 +407,7 @@ func (a *ANX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exc // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (a *ANX) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (a *ANX) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := a.GetOrderList(false) if err != nil { return nil, err diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index 0c3ad9c9..a067257c 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -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) } @@ -696,7 +696,7 @@ func (b *Binance) SetValues() { } // GetFee returns an estimate of fee based on type of transaction -func (b *Binance) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Binance) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index bc7c93bc..08c878e6 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -231,8 +231,8 @@ func TestGetAccount(t *testing.T) { t.Logf("Current takerFee: %d", account.TakerCommission) } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -333,7 +333,7 @@ func TestGetActiveOrders(t *testing.T) { var getOrdersRequest = exchange.GetOrdersRequest{ OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if err == nil { t.Error("Expected: 'At least one currency is required to fetch order history'. received nil") } @@ -342,7 +342,7 @@ func TestGetActiveOrders(t *testing.T) { currency.NewPair(currency.LTC, currency.BTC), } - _, err = b.GetActiveOrders(getOrdersRequest) + _, err = b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -358,7 +358,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if err == nil { t.Error("Expected: 'At least one currency is required to fetch order history'. received nil") } @@ -367,7 +367,7 @@ func TestGetOrderHistory(t *testing.T) { currency.NewPair(currency.LTC, currency.BTC)} - _, err = b.GetOrderHistory(getOrdersRequest) + _, err = b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -409,7 +409,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -431,7 +431,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -487,7 +487,7 @@ func TestWithdraw(t *testing.T) { Description: "WITHDRAW IT ALL", } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -506,7 +506,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -522,7 +522,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/binance/binance_wrapper.go b/exchanges/binance/binance_wrapper.go index 51eab915..1ad1e71f 100644 --- a/exchanges/binance/binance_wrapper.go +++ b/exchanges/binance/binance_wrapper.go @@ -251,7 +251,7 @@ func (b *Binance) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Binance) CancelOrder(order exchange.OrderCancellation) error { +func (b *Binance) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { return err @@ -265,7 +265,7 @@ func (b *Binance) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Binance) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Binance) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -297,7 +297,7 @@ func (b *Binance) GetDepositAddress(cryptocurrency currency.Code, _ string) (str // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Binance) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Binance) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { amountStr := strconv.FormatFloat(withdrawRequest.Amount, 'f', -1, 64) id, err := b.WithdrawCrypto(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.AddressTag, withdrawRequest.Description, amountStr) @@ -306,13 +306,13 @@ func (b *Binance) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Binance) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Binance) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Binance) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Binance) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -322,12 +322,12 @@ func (b *Binance) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *Binance) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Binance) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (b *Binance) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Binance) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("at least one currency is required to fetch order history") } @@ -367,7 +367,7 @@ func (b *Binance) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([ // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *Binance) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Binance) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("at least one currency is required to fetch order history") } diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index aa4b53e0..9c53066c 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -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) } @@ -616,48 +616,35 @@ func (b *Bitfinex) WithdrawCryptocurrency(withdrawType, wallet, address, payment &response) } -// WithdrawFIAT requests a withdrawal from one of your wallets. -// For Cryptocurrency, use WithdrawCryptocurrency -func (b *Bitfinex) WithdrawFIAT(withdrawType, wallet, wireCurrency, - accountName, bankName, bankAddress, bankCity, bankCountry, swift, - transactionMessage, intermediaryBankName, intermediaryBankAddress, - intermediaryBankCity, intermediaryBankCountry, intermediaryBankSwift string, - amount, accountNumber, intermediaryBankAccountNumber float64, isExpressWire, - requiresIntermediaryBank bool) ([]Withdrawal, error) { +func (b *Bitfinex) WithdrawFIAT(withdrawalType, walletType string, withdrawRequest *exchange.WithdrawRequest) ([]Withdrawal, error) { response := []Withdrawal{} req := make(map[string]interface{}) - req["withdraw_type"] = withdrawType - req["walletselected"] = wallet - req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) - req["account_name"] = accountName - req["account_number"] = strconv.FormatFloat(accountNumber, 'f', -1, 64) - req["bank_name"] = bankName - req["bank_address"] = bankAddress - req["bank_city"] = bankCity - req["bank_country"] = bankCountry - req["expressWire"] = isExpressWire - req["swift"] = swift - req["detail_payment"] = transactionMessage - req["currency"] = wireCurrency - req["account_address"] = bankAddress - if requiresIntermediaryBank { - req["intermediary_bank_name"] = intermediaryBankName - req["intermediary_bank_address"] = intermediaryBankAddress - req["intermediary_bank_city"] = intermediaryBankCity - req["intermediary_bank_country"] = intermediaryBankCountry - req["intermediary_bank_account"] = strconv.FormatFloat(intermediaryBankAccountNumber, - 'f', - -1, - 64) - req["intermediary_bank_swift"] = intermediaryBankSwift + req["withdraw_type"] = withdrawalType + req["walletselected"] = walletType + req["amount"] = strconv.FormatFloat(withdrawRequest.Amount, 'f', -1, 64) + req["account_name"] = withdrawRequest.BankAccountName + req["account_number"] = strconv.FormatFloat(withdrawRequest.BankAccountNumber, 'f', -1, 64) + req["bank_name"] = withdrawRequest.BankName + req["bank_address"] = withdrawRequest.BankAddress + req["bank_city"] = withdrawRequest.BankCity + req["bank_country"] = withdrawRequest.BankCountry + req["expressWire"] = withdrawRequest.IsExpressWire + req["swift"] = withdrawRequest.SwiftCode + req["detail_payment"] = withdrawRequest.Description + req["currency"] = withdrawRequest.WireCurrency + req["account_address"] = withdrawRequest.BankAddress + + if withdrawRequest.RequiresIntermediaryBank { + req["intermediary_bank_name"] = withdrawRequest.IntermediaryBankName + req["intermediary_bank_address"] = withdrawRequest.IntermediaryBankAddress + req["intermediary_bank_city"] = withdrawRequest.IntermediaryBankCity + req["intermediary_bank_country"] = withdrawRequest.IntermediaryBankCountry + req["intermediary_bank_account"] = strconv.FormatFloat(withdrawRequest.IntermediaryBankAccountNumber, 'f', -1, 64) + req["intermediary_bank_swift"] = withdrawRequest.IntermediarySwiftCode } - return response, - b.SendAuthenticatedHTTPRequest(http.MethodPost, - bitfinexWithdrawal, - req, - &response) + return response, b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexWithdrawal, req, &response) } // NewOrder submits a new order and returns a order information @@ -1065,7 +1052,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[ } // GetFee returns an estimate of fee based on type of transaction -func (b *Bitfinex) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitfinex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index 707e533e..9ecc1f72 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -610,8 +610,8 @@ func TestCloseMarginFunding(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -711,7 +711,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -727,7 +727,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -775,7 +775,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -801,7 +801,7 @@ func TestCancelAllExchangeOrdera(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -843,7 +843,7 @@ func TestWithdraw(t *testing.T) { Description: "WITHDRAW IT ALL", } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -876,7 +876,7 @@ func TestWithdrawFiat(t *testing.T) { IsExpressWire: false, } - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -915,7 +915,7 @@ func TestWithdrawInternationalBank(t *testing.T) { IntermediarySwiftCode: "Taylor", } - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } diff --git a/exchanges/bitfinex/bitfinex_wrapper.go b/exchanges/bitfinex/bitfinex_wrapper.go index 138e8d3e..23ddbf94 100644 --- a/exchanges/bitfinex/bitfinex_wrapper.go +++ b/exchanges/bitfinex/bitfinex_wrapper.go @@ -221,7 +221,7 @@ func (b *Bitfinex) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Bitfinex) CancelOrder(order exchange.OrderCancellation) error { +func (b *Bitfinex) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -234,7 +234,7 @@ func (b *Bitfinex) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Bitfinex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Bitfinex) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { _, err := b.CancelAllExistingOrders() return exchange.CancelAllOrdersResponse{}, err } @@ -261,7 +261,7 @@ func (b *Bitfinex) GetDepositAddress(cryptocurrency currency.Code, accountID str } // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted -func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { withdrawalType := b.ConvertSymbolToWithdrawalType(withdrawRequest.Currency) // Bitfinex has support for three types, exchange, margin and deposit // As this is for trading, I've made the wrapper default 'exchange' @@ -285,19 +285,13 @@ func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdraw // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted // Returns comma delimited withdrawal IDs -func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { withdrawalType := "wire" // Bitfinex has support for three types, exchange, margin and deposit // As this is for trading, I've made the wrapper default 'exchange' // TODO: Discover an automated way to make the decision for wallet type to withdraw from walletType := "exchange" - resp, err := b.WithdrawFIAT(withdrawalType, walletType, withdrawRequest.WireCurrency, - withdrawRequest.BankAccountName, withdrawRequest.BankName, withdrawRequest.BankAddress, - withdrawRequest.BankCity, withdrawRequest.BankCountry, withdrawRequest.SwiftCode, - withdrawRequest.Description, withdrawRequest.IntermediaryBankName, withdrawRequest.IntermediaryBankAddress, - withdrawRequest.IntermediaryBankCity, withdrawRequest.IntermediaryBankCountry, withdrawRequest.IntermediarySwiftCode, - withdrawRequest.Amount, withdrawRequest.BankAccountNumber, withdrawRequest.IntermediaryBankAccountNumber, - withdrawRequest.IsExpressWire, withdrawRequest.RequiresIntermediaryBank) + resp, err := b.WithdrawFIAT(withdrawalType, walletType, withdrawRequest) if err != nil { return "", err } @@ -324,7 +318,7 @@ func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) ( // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted // Returns comma delimited withdrawal IDs -func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return b.WithdrawFiatFunds(withdrawRequest) } @@ -334,12 +328,12 @@ func (b *Bitfinex) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *Bitfinex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitfinex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (b *Bitfinex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitfinex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail resp, err := b.GetOpenOrders() if err != nil { @@ -399,7 +393,7 @@ func (b *Bitfinex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ( // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *Bitfinex) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitfinex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail resp, err := b.GetInactiveOrders() if err != nil { diff --git a/exchanges/bitflyer/bitflyer.go b/exchanges/bitflyer/bitflyer.go index 38719ba3..e0bcde90 100644 --- a/exchanges/bitflyer/bitflyer.go +++ b/exchanges/bitflyer/bitflyer.go @@ -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) } @@ -393,7 +393,7 @@ func (b *Bitflyer) SendAuthHTTPRequest() { // GetFee returns an estimate of fee based on type of transaction // TODO: Figure out the weird fee structure. Do we use Bitcoin Easy Exchange,Lightning Spot,Bitcoin Market,Lightning FX/Futures ??? -func (b *Bitflyer) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitflyer) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/bitflyer/bitflyer_test.go b/exchanges/bitflyer/bitflyer_test.go index 599b3aae..60404ed6 100644 --- a/exchanges/bitflyer/bitflyer_test.go +++ b/exchanges/bitflyer/bitflyer_test.go @@ -148,8 +148,8 @@ func TestGetTickerPrice(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -251,7 +251,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -267,7 +267,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected '%v', received '%v'", common.ErrNotYetImplemented, err) } @@ -311,7 +311,7 @@ func TestCancelExchangeOrder(t *testing.T) { } currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -334,7 +334,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { } currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -362,7 +362,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected 'Not Yet Implemented', received %v", err) } @@ -385,7 +385,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err) } @@ -401,7 +401,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrNotYetImplemented { t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err) } diff --git a/exchanges/bitflyer/bitflyer_wrapper.go b/exchanges/bitflyer/bitflyer_wrapper.go index dfce15bb..69ea694e 100644 --- a/exchanges/bitflyer/bitflyer_wrapper.go +++ b/exchanges/bitflyer/bitflyer_wrapper.go @@ -178,12 +178,12 @@ func (b *Bitflyer) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Bitflyer) CancelOrder(order exchange.OrderCancellation) error { +func (b *Bitflyer) CancelOrder(order *exchange.OrderCancellation) error { return common.ErrNotYetImplemented } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Bitflyer) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Bitflyer) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { // TODO, implement BitFlyer API b.CancelAllExistingOrders() return exchange.CancelAllOrdersResponse{}, common.ErrNotYetImplemented @@ -202,19 +202,19 @@ func (b *Bitflyer) GetDepositAddress(cryptocurrency currency.Code, accountID str // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitflyer) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitflyer) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitflyer) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitflyer) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitflyer) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitflyer) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } @@ -224,12 +224,12 @@ func (b *Bitflyer) GetWebsocket() (*exchange.Websocket, error) { } // GetActiveOrders retrieves any orders that are active/open -func (b *Bitflyer) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitflyer) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrNotYetImplemented } // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *Bitflyer) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitflyer) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bithumb/bithumb.go b/exchanges/bithumb/bithumb.go index a78396a2..c74fadd3 100644 --- a/exchanges/bithumb/bithumb.go +++ b/exchanges/bithumb/bithumb.go @@ -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) } @@ -607,7 +607,7 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r } // GetFee returns an estimate of fee based on type of transaction -func (b *Bithumb) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bithumb) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/bithumb/bithumb_test.go b/exchanges/bithumb/bithumb_test.go index 2dc3c763..6a58c9eb 100644 --- a/exchanges/bithumb/bithumb_test.go +++ b/exchanges/bithumb/bithumb_test.go @@ -192,8 +192,8 @@ func TestMarketSellOrder(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -292,7 +292,7 @@ func TestGetActiveOrders(t *testing.T) { OrderSide: exchange.SellOrderSide, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -308,7 +308,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -357,7 +357,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -383,7 +383,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -445,7 +445,7 @@ func TestWithdraw(t *testing.T) { Description: "WITHDRAW IT ALL", } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -479,7 +479,7 @@ func TestWithdrawFiat(t *testing.T) { IsExpressWire: false, } - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -498,7 +498,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/bithumb/bithumb_wrapper.go b/exchanges/bithumb/bithumb_wrapper.go index 5565808c..dcd222cc 100644 --- a/exchanges/bithumb/bithumb_wrapper.go +++ b/exchanges/bithumb/bithumb_wrapper.go @@ -230,7 +230,7 @@ func (b *Bithumb) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Bithumb) CancelOrder(order exchange.OrderCancellation) error { +func (b *Bithumb) CancelOrder(order *exchange.OrderCancellation) error { _, err := b.CancelTrade(order.Side.ToString(), order.OrderID, order.CurrencyPair.Base.String()) @@ -238,7 +238,7 @@ func (b *Bithumb) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Bithumb) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Bithumb) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -286,14 +286,14 @@ func (b *Bithumb) GetDepositAddress(cryptocurrency currency.Code, _ string) (str // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bithumb) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bithumb) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { _, err := b.WithdrawCrypto(withdrawRequest.Address, withdrawRequest.AddressTag, withdrawRequest.Currency.String(), withdrawRequest.Amount) return "", err } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bithumb) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bithumb) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { if math.Mod(withdrawRequest.Amount, 1) != 0 { return "", errors.New("currency KRW does not support decimal places") } @@ -315,7 +315,7 @@ func (b *Bithumb) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (s } // WithdrawFiatFundsToInternationalBank is not supported as Bithumb only withdraws KRW to South Korean banks -func (b *Bithumb) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bithumb) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -325,12 +325,12 @@ func (b *Bithumb) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *Bithumb) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bithumb) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (b *Bithumb) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bithumb) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail resp, err := b.GetOrders("", "", "1000", "", "") if err != nil { @@ -375,7 +375,7 @@ func (b *Bithumb) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([ // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *Bithumb) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bithumb) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail resp, err := b.GetOrders("", "", "1000", "", "") if err != nil { diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index d7f93b25..14f13da4 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -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) } @@ -935,7 +935,7 @@ func (b *Bitmex) CaptureError(resp, reType interface{}) error { } // GetFee returns an estimate of fee based on type of transaction -func (b *Bitmex) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitmex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 var err error diff --git a/exchanges/bitmex/bitmex_test.go b/exchanges/bitmex/bitmex_test.go index 6650d321..6bd730bf 100644 --- a/exchanges/bitmex/bitmex_test.go +++ b/exchanges/bitmex/bitmex_test.go @@ -234,7 +234,7 @@ func TestCancelOrders(t *testing.T) { func TestCancelAllOrders(t *testing.T) { _, err := b.CancelAllExistingOrders(OrderCancelAllParams{}) if err == nil { - t.Error("test failed - CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error)", err) + t.Error("test failed - CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error)", err) } } @@ -360,8 +360,8 @@ func TestGetPreviousTrades(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -461,7 +461,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -479,7 +479,7 @@ func TestGetOrderHistory(t *testing.T) { currency.BTC)}, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -528,7 +528,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "123456789012345678901234567890123456", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -554,7 +554,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "123456789012345678901234567890123456", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -611,7 +611,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -630,7 +630,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -646,7 +646,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/bitmex/bitmex_wrapper.go b/exchanges/bitmex/bitmex_wrapper.go index 753e63d7..ab9904a8 100644 --- a/exchanges/bitmex/bitmex_wrapper.go +++ b/exchanges/bitmex/bitmex_wrapper.go @@ -227,7 +227,7 @@ func (b *Bitmex) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Bitmex) CancelOrder(order exchange.OrderCancellation) error { +func (b *Bitmex) CancelOrder(order *exchange.OrderCancellation) error { var params = OrderCancelParams{ OrderID: order.OrderID, } @@ -237,7 +237,7 @@ func (b *Bitmex) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Bitmex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Bitmex) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -267,7 +267,7 @@ func (b *Bitmex) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitmex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitmex) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { var request = UserRequestWithdrawalParams{ Address: withdrawRequest.Address, Amount: withdrawRequest.Amount, @@ -288,13 +288,13 @@ func (b *Bitmex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitmex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitmex) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitmex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitmex) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -304,13 +304,13 @@ func (b *Bitmex) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *Bitmex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitmex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open // This function is not concurrency safe due to orderSide/orderType maps -func (b *Bitmex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitmex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail params := OrdersRequest{} params.Filter = "{\"open\":true}" @@ -355,7 +355,7 @@ func (b *Bitmex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([] // GetOrderHistory retrieves account order information // Can Limit response to specific order status // This function is not concurrency safe due to orderSide/orderType maps -func (b *Bitmex) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitmex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail params := OrdersRequest{} resp, err := b.GetOrders(params) diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index cefeb00a..5163e40a 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -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) } @@ -143,7 +143,7 @@ func (b *Bitstamp) Setup(exch config.ExchangeConfig) { } // GetFee returns an estimate of fee based on type of transaction -func (b *Bitstamp) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitstamp) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/bitstamp/bitstamp_test.go b/exchanges/bitstamp/bitstamp_test.go index f6f099e0..3bc153be 100644 --- a/exchanges/bitstamp/bitstamp_test.go +++ b/exchanges/bitstamp/bitstamp_test.go @@ -61,8 +61,8 @@ func TestSetup(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -375,7 +375,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -391,7 +391,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -439,7 +439,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -465,7 +465,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -507,7 +507,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -542,7 +542,7 @@ func TestWithdrawFiat(t *testing.T) { IBAN: "IT60X0542811101000000123456", } - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -583,7 +583,7 @@ func TestWithdrawInternationalBank(t *testing.T) { IntermediaryBankPostalCode: "2088", } - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } diff --git a/exchanges/bitstamp/bitstamp_wrapper.go b/exchanges/bitstamp/bitstamp_wrapper.go index a92f13a9..c560ddff 100644 --- a/exchanges/bitstamp/bitstamp_wrapper.go +++ b/exchanges/bitstamp/bitstamp_wrapper.go @@ -93,7 +93,7 @@ func (b *Bitstamp) GetTickerPrice(p currency.Pair, assetType string) (ticker.Pri } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *Bitstamp) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bitstamp) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } @@ -215,7 +215,7 @@ func (b *Bitstamp) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Bitstamp) CancelOrder(order exchange.OrderCancellation) error { +func (b *Bitstamp) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -227,7 +227,7 @@ func (b *Bitstamp) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Bitstamp) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Bitstamp) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { isCancelAllSuccessful, err := b.CancelAllExistingOrders() if !isCancelAllSuccessful { err = errors.New("cancel all orders failed. Bitstamp provides no further information. Check order status to verify") @@ -249,7 +249,7 @@ func (b *Bitstamp) GetDepositAddress(cryptocurrency currency.Code, _ string) (st // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitstamp) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitstamp) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := b.CryptoWithdrawal(withdrawRequest.Amount, withdrawRequest.Address, withdrawRequest.Currency.String(), withdrawRequest.AddressTag, true) if err != nil { return "", err @@ -263,7 +263,7 @@ func (b *Bitstamp) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdraw // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitstamp) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitstamp) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := b.OpenBankWithdrawal(withdrawRequest.Amount, withdrawRequest.Currency.String(), withdrawRequest.BankAccountName, withdrawRequest.IBAN, withdrawRequest.SwiftCode, withdrawRequest.BankAddress, withdrawRequest.BankPostalCode, withdrawRequest.BankCity, withdrawRequest.BankCountry, @@ -280,7 +280,7 @@ func (b *Bitstamp) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) ( // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := b.OpenInternationalBankWithdrawal(withdrawRequest.Amount, withdrawRequest.Currency.String(), withdrawRequest.BankAccountName, withdrawRequest.IBAN, withdrawRequest.SwiftCode, withdrawRequest.BankAddress, withdrawRequest.BankPostalCode, withdrawRequest.BankCity, withdrawRequest.BankCountry, @@ -303,7 +303,7 @@ func (b *Bitstamp) GetWebsocket() (*exchange.Websocket, error) { } // GetActiveOrders retrieves any orders that are active/open -func (b *Bitstamp) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitstamp) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail var currPair string if len(getOrdersRequest.Currencies) != 1 { @@ -338,7 +338,7 @@ func (b *Bitstamp) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ( // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *Bitstamp) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bitstamp) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var currPair string if len(getOrdersRequest.Currencies) == 1 { currPair = getOrdersRequest.Currencies[0].String() diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index f788f228..c678fde1 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -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) } @@ -521,7 +521,7 @@ func (b *Bittrex) SendAuthenticatedHTTPRequest(path string, values url.Values, r } // GetFee returns an estimate of fee based on type of transaction -func (b *Bittrex) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bittrex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 var err error diff --git a/exchanges/bittrex/bittrex_test.go b/exchanges/bittrex/bittrex_test.go index 618c4e9b..bd663262 100644 --- a/exchanges/bittrex/bittrex_test.go +++ b/exchanges/bittrex/bittrex_test.go @@ -219,8 +219,8 @@ func TestGetDepositHistory(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -323,7 +323,7 @@ func TestGetActiveOrders(t *testing.T) { getOrdersRequest.Currencies[0].Delimiter = "-" - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -339,7 +339,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -388,7 +388,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -414,7 +414,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -456,7 +456,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -475,7 +475,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -491,7 +491,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/bittrex/bittrex_wrapper.go b/exchanges/bittrex/bittrex_wrapper.go index 4c3d5ca1..54a41c30 100644 --- a/exchanges/bittrex/bittrex_wrapper.go +++ b/exchanges/bittrex/bittrex_wrapper.go @@ -232,14 +232,14 @@ func (b *Bittrex) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *Bittrex) CancelOrder(order exchange.OrderCancellation) error { +func (b *Bittrex) CancelOrder(order *exchange.OrderCancellation) error { _, err := b.CancelExistingOrder(order.OrderID) return err } // CancelAllOrders cancels all orders associated with a currency pair -func (b *Bittrex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *Bittrex) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -276,20 +276,20 @@ func (b *Bittrex) GetDepositAddress(cryptocurrency currency.Code, _ string) (str // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bittrex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bittrex) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { uuid, err := b.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.AddressTag, withdrawRequest.Address, withdrawRequest.Amount) return fmt.Sprintf("%v", uuid), err } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bittrex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bittrex) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -299,13 +299,13 @@ func (b *Bittrex) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *Bittrex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *Bittrex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (b *Bittrex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bittrex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var currPair string if len(getOrdersRequest.Currencies) == 1 { currPair = getOrdersRequest.Currencies[0].String() @@ -350,7 +350,7 @@ func (b *Bittrex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([ // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *Bittrex) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *Bittrex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var currPair string if len(getOrdersRequest.Currencies) == 1 { currPair = getOrdersRequest.Currencies[0].String() diff --git a/exchanges/btcc/btcc.go b/exchanges/btcc/btcc.go index fb00a4f8..1cce657a 100644 --- a/exchanges/btcc/btcc.go +++ b/exchanges/btcc/btcc.go @@ -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) } @@ -96,7 +96,7 @@ func (b *BTCC) Setup(exch config.ExchangeConfig) { } // GetFee returns an estimate of fee based on type of transaction -func (b *BTCC) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *BTCC) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/btcc/btcc_test.go b/exchanges/btcc/btcc_test.go index fe6660e6..7d390833 100644 --- a/exchanges/btcc/btcc_test.go +++ b/exchanges/btcc/btcc_test.go @@ -75,8 +75,8 @@ func TestSetup(t *testing.T) { // t.Error("Test failed - GetAccountInfo() error", err) // } // } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -175,7 +175,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -191,7 +191,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -238,7 +238,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -261,7 +261,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -289,7 +289,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -312,7 +312,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -328,7 +328,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/btcc/btcc_wrapper.go b/exchanges/btcc/btcc_wrapper.go index b2e0740b..1fc75ed7 100644 --- a/exchanges/btcc/btcc_wrapper.go +++ b/exchanges/btcc/btcc_wrapper.go @@ -114,12 +114,12 @@ func (b *BTCC) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *BTCC) CancelOrder(order exchange.OrderCancellation) error { +func (b *BTCC) CancelOrder(order *exchange.OrderCancellation) error { return common.ErrNotYetImplemented } // CancelAllOrders cancels all orders associated with a currency pair -func (b *BTCC) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *BTCC) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { return exchange.CancelAllOrdersResponse{}, common.ErrNotYetImplemented } @@ -135,19 +135,19 @@ func (b *BTCC) GetDepositAddress(cryptocurrency currency.Code, accountID string) // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *BTCC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTCC) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCC) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTCC) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCC) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTCC) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -157,17 +157,17 @@ func (b *BTCC) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *BTCC) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *BTCC) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (b *BTCC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *BTCC) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrNotYetImplemented } // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *BTCC) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *BTCC) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/btcmarkets/btcmarkets.go b/exchanges/btcmarkets/btcmarkets.go index fd9a5dac..6bbdbfbb 100644 --- a/exchanges/btcmarkets/btcmarkets.go +++ b/exchanges/btcmarkets/btcmarkets.go @@ -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) } @@ -487,7 +487,7 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data, result } // GetFee returns an estimate of fee based on type of transaction -func (b *BTCMarkets) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *BTCMarkets) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/btcmarkets/btcmarkets_test.go b/exchanges/btcmarkets/btcmarkets_test.go index c6e56aa3..fafc7c8f 100644 --- a/exchanges/btcmarkets/btcmarkets_test.go +++ b/exchanges/btcmarkets/btcmarkets_test.go @@ -165,8 +165,8 @@ func TestGetOrderInfo(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -276,7 +276,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -294,7 +294,7 @@ func TestGetOrderHistory(t *testing.T) { currency.BTC)}, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -343,7 +343,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -369,7 +369,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -411,7 +411,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -444,7 +444,7 @@ func TestWithdrawFiat(t *testing.T) { IsExpressWire: false, } - _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + _, err := b.WithdrawFiatFunds(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -463,7 +463,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/btcmarkets/btcmarkets_wrapper.go b/exchanges/btcmarkets/btcmarkets_wrapper.go index 1c8ff82f..dbf5ee90 100644 --- a/exchanges/btcmarkets/btcmarkets_wrapper.go +++ b/exchanges/btcmarkets/btcmarkets_wrapper.go @@ -207,7 +207,7 @@ func (b *BTCMarkets) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *BTCMarkets) CancelOrder(order exchange.OrderCancellation) error { +func (b *BTCMarkets) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { return err @@ -218,7 +218,7 @@ func (b *BTCMarkets) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (b *BTCMarkets) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *BTCMarkets) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -306,13 +306,13 @@ func (b *BTCMarkets) GetDepositAddress(cryptocurrency currency.Code, accountID s } // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted -func (b *BTCMarkets) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTCMarkets) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return b.WithdrawCrypto(withdrawRequest.Amount, withdrawRequest.Currency.String(), withdrawRequest.Address) } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCMarkets) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTCMarkets) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { if withdrawRequest.Currency != currency.AUD { return "", errors.New("only AUD is supported for withdrawals") } @@ -321,7 +321,7 @@ func (b *BTCMarkets) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -331,12 +331,12 @@ func (b *BTCMarkets) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *BTCMarkets) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *BTCMarkets) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (b *BTCMarkets) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *BTCMarkets) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := b.GetOpenOrders() if err != nil { return nil, err @@ -394,7 +394,7 @@ func (b *BTCMarkets) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *BTCMarkets) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *BTCMarkets) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("requires at least one currency pair to retrieve history") } diff --git a/exchanges/btse/btse.go b/exchanges/btse/btse.go index 99bd23b9..da3e154c 100644 --- a/exchanges/btse/btse.go +++ b/exchanges/btse/btse.go @@ -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) } @@ -305,7 +305,7 @@ func (b *BTSE) SendAuthenticatedHTTPRequest(method, endpoint string, req map[str } // GetFee returns an estimate of fee based on type of transaction -func (b *BTSE) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *BTSE) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { diff --git a/exchanges/btse/btse_test.go b/exchanges/btse/btse_test.go index 8fba81c0..6c43f374 100644 --- a/exchanges/btse/btse_test.go +++ b/exchanges/btse/btse_test.go @@ -110,7 +110,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetActiveOrders(getOrdersRequest) + _, err := b.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -125,7 +125,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := b.GetOrderHistory(getOrdersRequest) + _, err := b.GetOrderHistory(&getOrdersRequest) if err != common.ErrFunctionNotSupported { t.Fatal("Test failed. Expected different result") } @@ -144,7 +144,7 @@ func TestGetFee(t *testing.T) { b.SetDefaults() TestSetup(t) - feeBuilder := exchange.FeeBuilder{ + feeBuilder := &exchange.FeeBuilder{ FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.USD), IsMaker: true, @@ -250,7 +250,7 @@ func TestCancelExchangeOrder(t *testing.T) { currency.USD.String(), "-") - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "0b66ccaf-dfd4-4b9f-a30b-2380b9c7b66d", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -278,7 +278,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currency.USD.String(), "-") - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", diff --git a/exchanges/btse/btse_wrapper.go b/exchanges/btse/btse_wrapper.go index 1d98bf08..72e149d3 100644 --- a/exchanges/btse/btse_wrapper.go +++ b/exchanges/btse/btse_wrapper.go @@ -166,7 +166,7 @@ func (b *BTSE) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (b *BTSE) CancelOrder(order exchange.OrderCancellation) error { +func (b *BTSE) CancelOrder(order *exchange.OrderCancellation) error { r, err := b.CancelExistingOrder(order.OrderID, exchange.FormatExchangeCurrency(b.Name, order.CurrencyPair).String()) if err != nil { @@ -186,7 +186,7 @@ func (b *BTSE) CancelOrder(order exchange.OrderCancellation) error { // CancelAllOrders cancels all orders associated with a currency pair // If product ID is sent, all orders of that specified market will be cancelled // If not specified, all orders of all markets will be cancelled -func (b *BTSE) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (b *BTSE) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { r, err := b.CancelOrders(exchange.FormatExchangeCurrency(b.Name, orderCancellation.CurrencyPair).String()) if err != nil { @@ -265,19 +265,19 @@ func (b *BTSE) GetDepositAddress(cryptocurrency currency.Code, accountID string) // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *BTSE) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTSE) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *BTSE) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTSE) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func (b *BTSE) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (b *BTSE) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -287,7 +287,7 @@ func (b *BTSE) GetWebsocket() (*exchange.Websocket, error) { } // GetActiveOrders retrieves any orders that are active/open -func (b *BTSE) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *BTSE) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := b.GetOrders("") if err != nil { return nil, err @@ -342,11 +342,11 @@ func (b *BTSE) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]ex // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (b *BTSE) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (b *BTSE) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrFunctionNotSupported } // GetFeeByType returns an estimate of fee based on type of transaction -func (b *BTSE) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (b *BTSE) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return b.GetFee(feeBuilder) } diff --git a/exchanges/coinbasepro/coinbasepro.go b/exchanges/coinbasepro/coinbasepro.go index 2ec7ee73..6c1ae987 100644 --- a/exchanges/coinbasepro/coinbasepro.go +++ b/exchanges/coinbasepro/coinbasepro.go @@ -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) } @@ -835,7 +835,7 @@ func (c *CoinbasePro) SendAuthenticatedHTTPRequest(method, path string, params m } // GetFee returns an estimate of fee based on type of transaction -func (c *CoinbasePro) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (c *CoinbasePro) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index aac02106..c23bf8ef 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -221,8 +221,8 @@ func TestAuthRequests(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -413,7 +413,7 @@ func TestGetActiveOrders(t *testing.T) { currency.LTC)}, } - _, err := c.GetActiveOrders(getOrdersRequest) + _, err := c.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -431,7 +431,7 @@ func TestGetOrderHistory(t *testing.T) { currency.LTC)}, } - _, err := c.GetOrderHistory(getOrdersRequest) + _, err := c.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -481,7 +481,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -508,7 +508,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -550,7 +550,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := c.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := c.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -573,7 +573,7 @@ func TestWithdrawFiat(t *testing.T) { BankName: "Federal Reserve Bank", } - _, err := c.WithdrawFiatFunds(withdrawFiatRequest) + _, err := c.WithdrawFiatFunds(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -596,7 +596,7 @@ func TestWithdrawInternationalBank(t *testing.T) { BankName: "Federal Reserve Bank", } - _, err := c.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := c.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index ff9cb146..caa0af84 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -219,12 +219,12 @@ func (c *CoinbasePro) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (c *CoinbasePro) CancelOrder(order exchange.OrderCancellation) error { +func (c *CoinbasePro) CancelOrder(order *exchange.OrderCancellation) error { return c.CancelExistingOrder(order.OrderID) } // CancelAllOrders cancels all orders associated with a currency pair -func (c *CoinbasePro) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (c *CoinbasePro) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { // CancellAllExisting orders returns a list of successful cancellations, we're only interested in failures _, err := c.CancelAllExistingOrders("") return exchange.CancelAllOrdersResponse{}, err @@ -243,14 +243,14 @@ func (c *CoinbasePro) GetDepositAddress(cryptocurrency currency.Code, accountID // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (c *CoinbasePro) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (c *CoinbasePro) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := c.WithdrawCrypto(withdrawRequest.Amount, withdrawRequest.Currency.String(), withdrawRequest.Address) return resp.ID, err } // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { paymentMethods, err := c.GetPayMethods() if err != nil { return "", err @@ -277,7 +277,7 @@ func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (c *CoinbasePro) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (c *CoinbasePro) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return c.WithdrawFiatFunds(withdrawRequest) } @@ -287,12 +287,12 @@ func (c *CoinbasePro) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (c *CoinbasePro) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (c *CoinbasePro) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return c.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (c *CoinbasePro) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (c *CoinbasePro) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var respOrders []GeneralizedOrderResponse for _, currency := range getOrdersRequest.Currencies { resp, err := c.GetOrders([]string{"open", "pending", "active"}, @@ -336,7 +336,7 @@ func (c *CoinbasePro) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (c *CoinbasePro) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (c *CoinbasePro) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var respOrders []GeneralizedOrderResponse for _, currency := range getOrdersRequest.Currencies { resp, err := c.GetOrders([]string{"done", "settled"}, diff --git a/exchanges/coinut/coinut.go b/exchanges/coinut/coinut.go index 3bc3aa74..f282124e 100644 --- a/exchanges/coinut/coinut.go +++ b/exchanges/coinut/coinut.go @@ -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) } @@ -394,7 +394,7 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{ } // GetFee returns an estimate of fee based on type of transaction -func (c *COINUT) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (c *COINUT) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/coinut/coinut_test.go b/exchanges/coinut/coinut_test.go index b20e0b41..57d844d2 100644 --- a/exchanges/coinut/coinut_test.go +++ b/exchanges/coinut/coinut_test.go @@ -50,8 +50,8 @@ func TestGetInstruments(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -197,7 +197,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := c.GetActiveOrders(getOrdersRequest) + _, err := c.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } @@ -213,7 +213,7 @@ func TestGetOrderHistory(t *testing.T) { currency.LTC)}, } - _, err := c.GetOrderHistory(getOrdersRequest) + _, err := c.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } @@ -260,7 +260,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -287,7 +287,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -343,7 +343,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := c.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := c.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected 'Not supported', received %v", err) } @@ -359,7 +359,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := c.WithdrawFiatFunds(withdrawFiatRequest) + _, err := c.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -375,7 +375,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := c.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := c.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/coinut/coinut_wrapper.go b/exchanges/coinut/coinut_wrapper.go index adc681c7..ae0d4171 100644 --- a/exchanges/coinut/coinut_wrapper.go +++ b/exchanges/coinut/coinut_wrapper.go @@ -274,7 +274,7 @@ func (c *COINUT) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (c *COINUT) CancelOrder(order exchange.OrderCancellation) error { +func (c *COINUT) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -296,7 +296,7 @@ func (c *COINUT) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (c *COINUT) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (c *COINUT) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { // TODO, this is a terrible implementation. Requires DB to improve // Coinut provides no way of retrieving orders without a currency // So we need to retrieve all currencies, then retrieve orders for each currency @@ -360,19 +360,19 @@ func (c *COINUT) GetDepositAddress(cryptocurrency currency.Code, accountID strin // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (c *COINUT) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (c *COINUT) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (c *COINUT) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (c *COINUT) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (c *COINUT) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (c *COINUT) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -382,12 +382,12 @@ func (c *COINUT) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (c *COINUT) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (c *COINUT) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return c.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (c *COINUT) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (c *COINUT) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { instruments, err := c.GetInstruments() if err != nil { return nil, err @@ -444,7 +444,7 @@ func (c *COINUT) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([] // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (c *COINUT) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (c *COINUT) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { instruments, err := c.GetInstruments() if err != nil { return nil, err diff --git a/exchanges/exchange.go b/exchanges/exchange.go index 8bd6c8f7..abfef223 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -317,17 +317,17 @@ type IBotExchange interface { GetFundingHistory() ([]FundHistory, error) SubmitOrder(p currency.Pair, side OrderSide, orderType OrderType, amount, price float64, clientID string) (SubmitOrderResponse, error) ModifyOrder(action ModifyOrder) (string, error) - CancelOrder(order OrderCancellation) error - CancelAllOrders(orders OrderCancellation) (CancelAllOrdersResponse, error) + CancelOrder(order *OrderCancellation) error + CancelAllOrders(orders *OrderCancellation) (CancelAllOrdersResponse, error) GetOrderInfo(orderID string) (OrderDetail, error) GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error) - GetOrderHistory(getOrdersRequest GetOrdersRequest) ([]OrderDetail, error) - GetActiveOrders(getOrdersRequest GetOrdersRequest) ([]OrderDetail, error) + GetOrderHistory(getOrdersRequest *GetOrdersRequest) ([]OrderDetail, error) + GetActiveOrders(getOrdersRequest *GetOrdersRequest) ([]OrderDetail, error) - WithdrawCryptocurrencyFunds(withdrawRequest WithdrawRequest) (string, error) - WithdrawFiatFunds(withdrawRequest WithdrawRequest) (string, error) - WithdrawFiatFundsToInternationalBank(withdrawRequest WithdrawRequest) (string, error) + WithdrawCryptocurrencyFunds(withdrawRequest *WithdrawRequest) (string, error) + WithdrawFiatFunds(withdrawRequest *WithdrawRequest) (string, error) + WithdrawFiatFundsToInternationalBank(withdrawRequest *WithdrawRequest) (string, error) GetWebsocket() (*Websocket, error) } @@ -858,7 +858,7 @@ func (o OrderSide) ToString() string { } // SetAPIURL sets configuration API URL for an exchange -func (e *Base) SetAPIURL(ec config.ExchangeConfig) error { +func (e *Base) SetAPIURL(ec *config.ExchangeConfig) error { if ec.APIURL == "" || ec.APIURLSecondary == "" { return errors.New("empty config API URLs") } diff --git a/exchanges/exchange_test.go b/exchanges/exchange_test.go index 7afed2ec..3ddb75d9 100644 --- a/exchanges/exchange_test.go +++ b/exchanges/exchange_test.go @@ -809,7 +809,7 @@ func TestUpdateCurrencies(t *testing.T) { } } -func TestAPIURL(t *testing.T) { +func TestSetAPIURL(t *testing.T) { testURL := "https://api.something.com" testURLSecondary := "https://api.somethingelse.com" testURLDefault := "https://api.defaultsomething.com" @@ -819,7 +819,7 @@ func TestAPIURL(t *testing.T) { test := config.ExchangeConfig{} - err := tester.SetAPIURL(test) + err := tester.SetAPIURL(&test) if err == nil { t.Error("test failed - setting zero value config") } @@ -830,7 +830,7 @@ func TestAPIURL(t *testing.T) { tester.APIUrlDefault = testURLDefault tester.APIUrlSecondaryDefault = testURLSecondaryDefault - err = tester.SetAPIURL(test) + err = tester.SetAPIURL(&test) if err != nil { t.Error("test failed", err) } @@ -852,6 +852,25 @@ func TestAPIURL(t *testing.T) { } } +func BenchmarkSetAPIURL(b *testing.B) { + tester := Base{Name: "test"} + + test := config.ExchangeConfig{} + + test.APIURL = "https://api.something.com" + test.APIURLSecondary = "https://api.somethingelse.com" + + tester.APIUrlDefault = "https://api.defaultsomething.com" + tester.APIUrlSecondaryDefault = "https://api.defaultsomethingelse.com" + + for i := 0; i < b.N; i++ { + err := tester.SetAPIURL(&test) + if err != nil { + b.Errorf("Benchmark failed %v", err) + } + } +} + func TestSupportsWithdrawPermissions(t *testing.T) { UAC := Base{Name: defaultTestExchange} UAC.APIWithdrawPermissions = AutoWithdrawCrypto | AutoWithdrawCryptoWithAPIPermission diff --git a/exchanges/exmo/exmo.go b/exchanges/exmo/exmo.go index 575d1840..5a32f132 100644 --- a/exchanges/exmo/exmo.go +++ b/exchanges/exmo/exmo.go @@ -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) } @@ -417,7 +417,7 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va } // GetFee returns an estimate of fee based on type of transaction -func (e *EXMO) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (e *EXMO) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/exmo/exmo_test.go b/exchanges/exmo/exmo_test.go index f88090f1..83b6fb2c 100644 --- a/exchanges/exmo/exmo_test.go +++ b/exchanges/exmo/exmo_test.go @@ -105,8 +105,8 @@ func TestGetRequiredAmount(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.BTC, currency.LTC), @@ -254,7 +254,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := e.GetActiveOrders(getOrdersRequest) + _, err := e.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -273,7 +273,7 @@ func TestGetOrderHistory(t *testing.T) { currPair.Delimiter = "_" getOrdersRequest.Currencies = []currency.Pair{currPair} - _, err := e.GetOrderHistory(getOrdersRequest) + _, err := e.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -321,7 +321,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -347,7 +347,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { } currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -389,7 +389,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := e.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := e.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -408,7 +408,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := e.WithdrawFiatFunds(withdrawFiatRequest) + _, err := e.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -424,7 +424,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := e.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := e.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/exmo/exmo_wrapper.go b/exchanges/exmo/exmo_wrapper.go index e63ba8a8..d0fa3eb1 100644 --- a/exchanges/exmo/exmo_wrapper.go +++ b/exchanges/exmo/exmo_wrapper.go @@ -239,7 +239,7 @@ func (e *EXMO) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (e *EXMO) CancelOrder(order exchange.OrderCancellation) error { +func (e *EXMO) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -250,7 +250,7 @@ func (e *EXMO) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (e *EXMO) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (e *EXMO) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -292,7 +292,7 @@ func (e *EXMO) GetDepositAddress(cryptocurrency currency.Code, _ string) (string // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := e.WithdrawCryptocurrency(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.AddressTag, withdrawRequest.Amount) return fmt.Sprintf("%v", resp), err @@ -300,13 +300,13 @@ func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequ // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (e *EXMO) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (e *EXMO) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (e *EXMO) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (e *EXMO) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -316,12 +316,12 @@ func (e *EXMO) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (e *EXMO) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (e *EXMO) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return e.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (e *EXMO) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (e *EXMO) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := e.GetOpenOrders() if err != nil { return nil, err @@ -351,7 +351,7 @@ func (e *EXMO) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]ex // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (e *EXMO) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (e *EXMO) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 92c4152c..6af44af3 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -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) } @@ -508,7 +508,7 @@ func (g *Gateio) SendAuthenticatedHTTPRequest(method, endpoint, param string, re } // GetFee returns an estimate of fee based on type of transaction -func (g *Gateio) GetFee(feeBuilder exchange.FeeBuilder) (fee float64, err error) { +func (g *Gateio) GetFee(feeBuilder *exchange.FeeBuilder) (fee float64, err error) { switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: feePairs, err := g.GetMarketInfo() diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index c3355b80..572ad853 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -143,8 +143,8 @@ func TestGetSpotKline(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.BTC.String(), @@ -255,7 +255,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := g.GetActiveOrders(getOrdersRequest) + _, err := g.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -275,7 +275,7 @@ func TestGetOrderHistory(t *testing.T) { currPair.Delimiter = "_" getOrdersRequest.Currencies = []currency.Pair{currPair} - _, err := g.GetOrderHistory(getOrdersRequest) + _, err := g.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -324,7 +324,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -350,7 +350,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -406,7 +406,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := g.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := g.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -425,7 +425,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := g.WithdrawFiatFunds(withdrawFiatRequest) + _, err := g.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -441,7 +441,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := g.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := g.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index 158e60eb..dc0dfac8 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -241,7 +241,7 @@ func (g *Gateio) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (g *Gateio) CancelOrder(order exchange.OrderCancellation) error { +func (g *Gateio) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -253,7 +253,7 @@ func (g *Gateio) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (g *Gateio) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (g *Gateio) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -309,19 +309,19 @@ func (g *Gateio) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (g *Gateio) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (g *Gateio) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return g.WithdrawCrypto(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.Amount) } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (g *Gateio) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (g *Gateio) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (g *Gateio) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (g *Gateio) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -331,12 +331,12 @@ func (g *Gateio) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (g *Gateio) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (g *Gateio) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return g.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (g *Gateio) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (g *Gateio) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var currPair string if len(getOrdersRequest.Currencies) == 1 { currPair = getOrdersRequest.Currencies[0].String() @@ -378,7 +378,7 @@ func (g *Gateio) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([] // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (g *Gateio) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (g *Gateio) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var trades []TradesResponse for _, currency := range getOrdersRequest.Currencies { resp, err := g.GetTradeHistory(currency.String()) diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index 013899c9..61d90514 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -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) } @@ -532,7 +532,7 @@ func (g *Gemini) SendAuthenticatedHTTPRequest(method, path string, params map[st } // GetFee returns an estimate of fee based on type of transaction -func (g *Gemini) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (g *Gemini) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/gemini/gemini_test.go b/exchanges/gemini/gemini_test.go index 2281e491..8be4e8c5 100644 --- a/exchanges/gemini/gemini_test.go +++ b/exchanges/gemini/gemini_test.go @@ -234,8 +234,8 @@ func TestPostHeartbeat(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.BTC.String(), @@ -349,7 +349,7 @@ func TestGetActiveOrders(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.LTC, currency.BTC)}, } - _, err := Session[1].GetActiveOrders(getOrdersRequest) + _, err := Session[1].GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -368,7 +368,7 @@ func TestGetOrderHistory(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.LTC, currency.BTC)}, } - _, err := Session[1].GetOrderHistory(getOrdersRequest) + _, err := Session[1].GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -419,7 +419,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -446,7 +446,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -489,7 +489,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := Session[1].WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := Session[1].WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -509,7 +509,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := Session[1].WithdrawFiatFunds(withdrawFiatRequest) + _, err := Session[1].WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -526,7 +526,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := Session[1].WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := Session[1].WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/gemini/gemini_wrapper.go b/exchanges/gemini/gemini_wrapper.go index 262789ff..389145a0 100644 --- a/exchanges/gemini/gemini_wrapper.go +++ b/exchanges/gemini/gemini_wrapper.go @@ -184,7 +184,7 @@ func (g *Gemini) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (g *Gemini) CancelOrder(order exchange.OrderCancellation) error { +func (g *Gemini) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { return err @@ -195,7 +195,7 @@ func (g *Gemini) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (g *Gemini) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (g *Gemini) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -228,7 +228,7 @@ func (g *Gemini) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (g *Gemini) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (g *Gemini) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := g.WithdrawCrypto(withdrawRequest.Address, withdrawRequest.Currency.String(), withdrawRequest.Amount) if err != nil { return "", err @@ -242,13 +242,13 @@ func (g *Gemini) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (g *Gemini) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (g *Gemini) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (g *Gemini) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (g *Gemini) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -258,12 +258,12 @@ func (g *Gemini) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (g *Gemini) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (g *Gemini) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return g.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (g *Gemini) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (g *Gemini) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := g.GetOrders() if err != nil { return nil, err @@ -308,7 +308,7 @@ func (g *Gemini) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([] // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (g *Gemini) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (g *Gemini) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } diff --git a/exchanges/hitbtc/hitbtc.go b/exchanges/hitbtc/hitbtc.go index 51b5adc6..d092b5e2 100644 --- a/exchanges/hitbtc/hitbtc.go +++ b/exchanges/hitbtc/hitbtc.go @@ -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) } @@ -615,7 +615,7 @@ func (h *HitBTC) SendAuthenticatedHTTPRequest(method, endpoint string, values ur } // GetFee returns an estimate of fee based on type of transaction -func (h *HitBTC) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (h *HitBTC) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/hitbtc/hitbtc_test.go b/exchanges/hitbtc/hitbtc_test.go index 6385f54f..c7888731 100644 --- a/exchanges/hitbtc/hitbtc_test.go +++ b/exchanges/hitbtc/hitbtc_test.go @@ -64,8 +64,8 @@ func TestGetCurrencies(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.ETH, currency.BTC), @@ -178,7 +178,7 @@ func TestGetActiveOrders(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.ETH, currency.BTC)}, } - _, err := h.GetActiveOrders(getOrdersRequest) + _, err := h.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -195,7 +195,7 @@ func TestGetOrderHistory(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.ETH, currency.BTC)}, } - _, err := h.GetOrderHistory(getOrdersRequest) + _, err := h.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -244,7 +244,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -270,7 +270,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -312,7 +312,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := h.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := h.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -331,7 +331,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := h.WithdrawFiatFunds(withdrawFiatRequest) + _, err := h.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -347,7 +347,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := h.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/hitbtc/hitbtc_wrapper.go b/exchanges/hitbtc/hitbtc_wrapper.go index edc526b4..9c107951 100644 --- a/exchanges/hitbtc/hitbtc_wrapper.go +++ b/exchanges/hitbtc/hitbtc_wrapper.go @@ -214,7 +214,7 @@ func (h *HitBTC) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (h *HitBTC) CancelOrder(order exchange.OrderCancellation) error { +func (h *HitBTC) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -227,7 +227,7 @@ func (h *HitBTC) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (h *HitBTC) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (h *HitBTC) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -261,7 +261,7 @@ func (h *HitBTC) GetDepositAddress(currency currency.Code, _ string) (string, er // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (h *HitBTC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HitBTC) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { _, err := h.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.Amount) return "", err @@ -269,13 +269,13 @@ func (h *HitBTC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (h *HitBTC) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HitBTC) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (h *HitBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HitBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -285,12 +285,12 @@ func (h *HitBTC) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (h *HitBTC) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (h *HitBTC) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return h.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (h *HitBTC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (h *HitBTC) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } @@ -335,7 +335,7 @@ func (h *HitBTC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([] // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (h *HitBTC) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (h *HitBTC) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index 3061ae4f..d633c116 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -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) } @@ -912,7 +912,7 @@ func (h *HUOBI) SendAuthenticatedHTTPRequest(method, endpoint string, values url } // GetFee returns an estimate of fee based on type of transaction -func (h *HUOBI) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (h *HUOBI) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 if feeBuilder.FeeType == exchange.CryptocurrencyTradeFee { fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount) diff --git a/exchanges/huobi/huobi_test.go b/exchanges/huobi/huobi_test.go index 68464a8a..39970f60 100644 --- a/exchanges/huobi/huobi_test.go +++ b/exchanges/huobi/huobi_test.go @@ -292,8 +292,8 @@ func TestPEMLoadAndSign(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.BTC.String(), @@ -401,7 +401,7 @@ func TestGetActiveOrders(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)}, } - _, err := h.GetActiveOrders(getOrdersRequest) + _, err := h.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -418,7 +418,7 @@ func TestGetOrderHistory(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)}, } - _, err := h.GetOrderHistory(getOrdersRequest) + _, err := h.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -478,7 +478,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -510,7 +510,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { CurrencyPair: currencyPair, } - resp, err := h.CancelAllOrders(orderCancellation) + resp, err := h.CancelAllOrders(&orderCancellation) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") @@ -559,7 +559,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := h.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := h.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -578,7 +578,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := h.WithdrawFiatFunds(withdrawFiatRequest) + _, err := h.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -594,7 +594,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := h.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/huobi/huobi_wrapper.go b/exchanges/huobi/huobi_wrapper.go index 9b9a371d..39d5e0ac 100644 --- a/exchanges/huobi/huobi_wrapper.go +++ b/exchanges/huobi/huobi_wrapper.go @@ -321,7 +321,7 @@ func (h *HUOBI) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (h *HUOBI) CancelOrder(order exchange.OrderCancellation) error { +func (h *HUOBI) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -334,7 +334,7 @@ func (h *HUOBI) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (h *HUOBI) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (h *HUOBI) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -369,20 +369,20 @@ func (h *HUOBI) GetDepositAddress(cryptocurrency currency.Code, accountID string // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (h *HUOBI) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HUOBI) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := h.Withdraw(withdrawRequest.Currency, withdrawRequest.Address, withdrawRequest.AddressTag, withdrawRequest.Amount, withdrawRequest.FeeAmount) return fmt.Sprintf("%v", resp), err } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBI) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HUOBI) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBI) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HUOBI) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -392,12 +392,12 @@ func (h *HUOBI) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (h *HUOBI) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (h *HUOBI) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return h.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (h *HUOBI) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (h *HUOBI) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } @@ -444,7 +444,7 @@ func (h *HUOBI) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]e // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (h *HUOBI) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (h *HUOBI) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } diff --git a/exchanges/huobihadax/huobihadax.go b/exchanges/huobihadax/huobihadax.go index 6f23b84c..f63502aa 100644 --- a/exchanges/huobihadax/huobihadax.go +++ b/exchanges/huobihadax/huobihadax.go @@ -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) } @@ -883,7 +883,7 @@ func (h *HUOBIHADAX) SendAuthenticatedHTTPRequest(method, endpoint string, value } // GetFee returns an estimate of fee based on type of transaction -func (h *HUOBIHADAX) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (h *HUOBIHADAX) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 if feeBuilder.FeeType == exchange.CryptocurrencyTradeFee { fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount) diff --git a/exchanges/huobihadax/huobihadax_test.go b/exchanges/huobihadax/huobihadax_test.go index afb21469..68d7b3d0 100644 --- a/exchanges/huobihadax/huobihadax_test.go +++ b/exchanges/huobihadax/huobihadax_test.go @@ -272,8 +272,8 @@ func TestCancelWithdraw(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.BTC.String(), @@ -381,7 +381,7 @@ func TestGetActiveOrders(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)}, } - _, err := h.GetActiveOrders(getOrdersRequest) + _, err := h.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -398,7 +398,7 @@ func TestGetOrderHistory(t *testing.T) { Currencies: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)}, } - _, err := h.GetOrderHistory(getOrdersRequest) + _, err := h.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -458,7 +458,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -484,7 +484,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -540,7 +540,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := h.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := h.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -559,7 +559,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := h.WithdrawFiatFunds(withdrawFiatRequest) + _, err := h.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -575,7 +575,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := h.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/huobihadax/huobihadax_wrapper.go b/exchanges/huobihadax/huobihadax_wrapper.go index eefc286b..6f82c515 100644 --- a/exchanges/huobihadax/huobihadax_wrapper.go +++ b/exchanges/huobihadax/huobihadax_wrapper.go @@ -277,7 +277,7 @@ func (h *HUOBIHADAX) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (h *HUOBIHADAX) CancelOrder(order exchange.OrderCancellation) error { +func (h *HUOBIHADAX) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -290,7 +290,7 @@ func (h *HUOBIHADAX) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (h *HUOBIHADAX) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (h *HUOBIHADAX) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -325,20 +325,20 @@ func (h *HUOBIHADAX) GetDepositAddress(cryptocurrency currency.Code, accountID s // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (h *HUOBIHADAX) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HUOBIHADAX) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := h.Withdraw(withdrawRequest.Currency, withdrawRequest.Address, withdrawRequest.AddressTag, withdrawRequest.Amount, withdrawRequest.FeeAmount) return fmt.Sprintf("%v", resp), err } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBIHADAX) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HUOBIHADAX) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBIHADAX) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (h *HUOBIHADAX) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -348,12 +348,12 @@ func (h *HUOBIHADAX) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (h *HUOBIHADAX) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (h *HUOBIHADAX) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return h.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (h *HUOBIHADAX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (h *HUOBIHADAX) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } @@ -403,7 +403,7 @@ func (h *HUOBIHADAX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (h *HUOBIHADAX) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (h *HUOBIHADAX) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if len(getOrdersRequest.Currencies) == 0 { return nil, errors.New("currency must be supplied") } diff --git a/exchanges/itbit/itbit.go b/exchanges/itbit/itbit.go index a3f91d5a..a7c47e65 100644 --- a/exchanges/itbit/itbit.go +++ b/exchanges/itbit/itbit.go @@ -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) } @@ -421,7 +421,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method, path string, params map[str } // GetFee returns an estimate of fee based on type of transaction -func (i *ItBit) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (i *ItBit) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/itbit/itbit_test.go b/exchanges/itbit/itbit_test.go index 07eebfbe..2a9aec1a 100644 --- a/exchanges/itbit/itbit_test.go +++ b/exchanges/itbit/itbit_test.go @@ -141,8 +141,8 @@ func TestWalletTransfer(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.BTC.String(), @@ -249,7 +249,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := i.GetActiveOrders(getOrdersRequest) + _, err := i.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -265,7 +265,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := i.GetOrderHistory(getOrdersRequest) + _, err := i.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -313,7 +313,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -340,7 +340,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -391,7 +391,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := i.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := i.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected 'Not supported', received %v", err) } @@ -407,7 +407,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := i.WithdrawFiatFunds(withdrawFiatRequest) + _, err := i.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -423,7 +423,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := i.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := i.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/itbit/itbit_wrapper.go b/exchanges/itbit/itbit_wrapper.go index 823e6dac..baea4752 100644 --- a/exchanges/itbit/itbit_wrapper.go +++ b/exchanges/itbit/itbit_wrapper.go @@ -238,12 +238,12 @@ func (i *ItBit) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (i *ItBit) CancelOrder(order exchange.OrderCancellation) error { +func (i *ItBit) CancelOrder(order *exchange.OrderCancellation) error { return i.CancelExistingOrder(order.WalletAddress, order.OrderID) } // CancelAllOrders cancels all orders associated with a currency pair -func (i *ItBit) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (i *ItBit) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -278,19 +278,19 @@ func (i *ItBit) GetDepositAddress(cryptocurrency currency.Code, accountID string // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (i *ItBit) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (i *ItBit) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (i *ItBit) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (i *ItBit) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (i *ItBit) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (i *ItBit) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -300,12 +300,12 @@ func (i *ItBit) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (i *ItBit) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (i *ItBit) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return i.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (i *ItBit) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (i *ItBit) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { wallets, err := i.GetWallets(url.Values{}) if err != nil { return nil, err @@ -353,7 +353,7 @@ func (i *ItBit) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]e // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (i *ItBit) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (i *ItBit) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { wallets, err := i.GetWallets(url.Values{}) if err != nil { return nil, err diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index 2251a88d..9a7de191 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -115,7 +115,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) } @@ -957,7 +957,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values, } // GetFee returns an estimate of fee based on type of transaction -func (k *Kraken) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (k *Kraken) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 c := feeBuilder.Pair.Base.String() + feeBuilder.Pair.Delimiter + diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index 93c14714..942b7498 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -220,8 +220,8 @@ func TestCancelExistingOrder(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPair(currency.XXBT, currency.ZUSD), @@ -332,7 +332,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := k.GetActiveOrders(getOrdersRequest) + _, err := k.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -348,7 +348,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := k.GetOrderHistory(getOrdersRequest) + _, err := k.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -397,7 +397,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -423,7 +423,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -480,7 +480,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := k.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := k.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -505,7 +505,7 @@ func TestWithdrawFiat(t *testing.T) { TradePassword: "someBank", } - _, err := k.WithdrawFiatFunds(withdrawFiatRequest) + _, err := k.WithdrawFiatFunds(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -530,7 +530,7 @@ func TestWithdrawInternationalBank(t *testing.T) { TradePassword: "someBank", } - _, err := k.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := k.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } diff --git a/exchanges/kraken/kraken_wrapper.go b/exchanges/kraken/kraken_wrapper.go index 22ffd72c..48fa1cd5 100644 --- a/exchanges/kraken/kraken_wrapper.go +++ b/exchanges/kraken/kraken_wrapper.go @@ -233,14 +233,14 @@ func (k *Kraken) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (k *Kraken) CancelOrder(order exchange.OrderCancellation) error { +func (k *Kraken) CancelOrder(order *exchange.OrderCancellation) error { _, err := k.CancelExistingOrder(order.OrderID) return err } // CancelAllOrders cancels all orders associated with a currency pair -func (k *Kraken) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (k *Kraken) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -289,19 +289,19 @@ func (k *Kraken) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal // Populate exchange.WithdrawRequest.TradePassword with withdrawal key name, as set up on your account -func (k *Kraken) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (k *Kraken) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount) } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (k *Kraken) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (k *Kraken) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return k.WithdrawCryptocurrencyFunds(withdrawRequest) } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (k *Kraken) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (k *Kraken) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return k.WithdrawCryptocurrencyFunds(withdrawRequest) } @@ -311,12 +311,12 @@ func (k *Kraken) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (k *Kraken) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (k *Kraken) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return k.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (k *Kraken) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (k *Kraken) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := k.GetOpenOrders(OrderInfoOptions{}) if err != nil { return nil, err @@ -352,7 +352,7 @@ func (k *Kraken) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([] // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (k *Kraken) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (k *Kraken) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { req := GetClosedOrdersOptions{} if getOrdersRequest.StartTicks.Unix() > 0 { req.Start = fmt.Sprintf("%v", getOrdersRequest.StartTicks.Unix()) diff --git a/exchanges/lakebtc/lakebtc.go b/exchanges/lakebtc/lakebtc.go index 1c57fa45..f12d7e48 100644 --- a/exchanges/lakebtc/lakebtc.go +++ b/exchanges/lakebtc/lakebtc.go @@ -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) } @@ -375,7 +375,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int } // GetFee returns an estimate of fee based on type of transaction -func (l *LakeBTC) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (l *LakeBTC) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/lakebtc/lakebtc_test.go b/exchanges/lakebtc/lakebtc_test.go index 33030ef3..f5c48fb4 100644 --- a/exchanges/lakebtc/lakebtc_test.go +++ b/exchanges/lakebtc/lakebtc_test.go @@ -134,8 +134,8 @@ func TestGetExternalAccounts(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.BTC.String(), @@ -243,7 +243,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := l.GetActiveOrders(getOrdersRequest) + _, err := l.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -259,7 +259,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := l.GetOrderHistory(getOrdersRequest) + _, err := l.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -308,7 +308,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -334,7 +334,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -376,7 +376,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := l.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := l.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -395,7 +395,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := l.WithdrawFiatFunds(withdrawFiatRequest) + _, err := l.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -411,7 +411,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := l.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/lakebtc/lakebtc_wrapper.go b/exchanges/lakebtc/lakebtc_wrapper.go index a8a97716..fdd7c488 100644 --- a/exchanges/lakebtc/lakebtc_wrapper.go +++ b/exchanges/lakebtc/lakebtc_wrapper.go @@ -190,7 +190,7 @@ func (l *LakeBTC) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (l *LakeBTC) CancelOrder(order exchange.OrderCancellation) error { +func (l *LakeBTC) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -201,7 +201,7 @@ func (l *LakeBTC) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (l *LakeBTC) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (l *LakeBTC) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -243,7 +243,7 @@ func (l *LakeBTC) GetDepositAddress(cryptocurrency currency.Code, _ string) (str // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (l *LakeBTC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (l *LakeBTC) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { if withdrawRequest.Currency != currency.BTC { return "", errors.New("only BTC supported for withdrawals") } @@ -258,13 +258,13 @@ func (l *LakeBTC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (l *LakeBTC) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (l *LakeBTC) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (l *LakeBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (l *LakeBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -275,12 +275,12 @@ func (l *LakeBTC) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (l *LakeBTC) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (l *LakeBTC) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return l.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (l *LakeBTC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (l *LakeBTC) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := l.GetOpenOrders() if err != nil { return nil, err @@ -312,7 +312,7 @@ func (l *LakeBTC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([ // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (l *LakeBTC) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (l *LakeBTC) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := l.GetOrders([]int64{}) if err != nil { return nil, err diff --git a/exchanges/localbitcoins/localbitcoins.go b/exchanges/localbitcoins/localbitcoins.go index 3f3e629c..3ebe5399 100644 --- a/exchanges/localbitcoins/localbitcoins.go +++ b/exchanges/localbitcoins/localbitcoins.go @@ -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) } @@ -764,7 +764,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params } // GetFee returns an estimate of fee based on type of transaction -func (l *LocalBitcoins) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (l *LocalBitcoins) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { // No fees will be used return 0, nil } diff --git a/exchanges/localbitcoins/localbitcoins_test.go b/exchanges/localbitcoins/localbitcoins_test.go index 1a12abd9..720357c5 100644 --- a/exchanges/localbitcoins/localbitcoins_test.go +++ b/exchanges/localbitcoins/localbitcoins_test.go @@ -95,8 +95,8 @@ func TestEditAd(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.LTC.String(), @@ -203,7 +203,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := l.GetActiveOrders(getOrdersRequest) + _, err := l.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -219,7 +219,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := l.GetOrderHistory(getOrdersRequest) + _, err := l.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -268,7 +268,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -294,7 +294,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -336,7 +336,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := l.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := l.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -355,7 +355,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := l.WithdrawFiatFunds(withdrawFiatRequest) + _, err := l.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -371,7 +371,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := l.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index 062e3967..756e242e 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -236,12 +236,12 @@ func (l *LocalBitcoins) ModifyOrder(action exchange.ModifyOrder) (string, error) } // CancelOrder cancels an order by its corresponding ID number -func (l *LocalBitcoins) CancelOrder(order exchange.OrderCancellation) error { +func (l *LocalBitcoins) CancelOrder(order *exchange.OrderCancellation) error { return l.DeleteAd(order.OrderID) } // CancelAllOrders cancels all orders associated with a currency pair -func (l *LocalBitcoins) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (l *LocalBitcoins) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -279,20 +279,20 @@ func (l *LocalBitcoins) GetDepositAddress(cryptocurrency currency.Code, _ string // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (l *LocalBitcoins) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (l *LocalBitcoins) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { _, err := l.WalletSend(withdrawRequest.Address, withdrawRequest.Amount, withdrawRequest.PIN) return "", err } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (l *LocalBitcoins) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (l *LocalBitcoins) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (l *LocalBitcoins) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (l *LocalBitcoins) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -302,12 +302,12 @@ func (l *LocalBitcoins) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (l *LocalBitcoins) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (l *LocalBitcoins) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return l.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (l *LocalBitcoins) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (l *LocalBitcoins) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := l.GetDashboardInfo() if err != nil { return nil, err @@ -354,7 +354,7 @@ func (l *LocalBitcoins) GetActiveOrders(getOrdersRequest exchange.GetOrdersReque // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (l *LocalBitcoins) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (l *LocalBitcoins) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var allTrades []DashBoardInfo resp, err := l.GetDashboardCancelledTrades() if err != nil { diff --git a/exchanges/okcoin/okcoin_test.go b/exchanges/okcoin/okcoin_test.go index 34907a32..e35c8fc3 100644 --- a/exchanges/okcoin/okcoin_test.go +++ b/exchanges/okcoin/okcoin_test.go @@ -312,7 +312,7 @@ func TestPlaceSpotOrderLimit(t *testing.T) { Size: "100", } - _, err := o.PlaceSpotOrder(request) + _, err := o.PlaceSpotOrder(&request) testStandardErrorHandling(t, err) } @@ -328,7 +328,7 @@ func TestPlaceSpotOrderMarket(t *testing.T) { Notional: "100", } - _, err := o.PlaceSpotOrder(request) + _, err := o.PlaceSpotOrder(&request) testStandardErrorHandling(t, err) } @@ -639,7 +639,7 @@ func TestPlaceMarginOrderLimit(t *testing.T) { Size: "100", } - _, err := o.PlaceMarginOrder(request) + _, err := o.PlaceMarginOrder(&request) testStandardErrorHandling(t, err) } @@ -655,7 +655,7 @@ func TestPlaceMarginOrderMarket(t *testing.T) { Notional: "100", } - _, err := o.PlaceMarginOrder(request) + _, err := o.PlaceMarginOrder(&request) testStandardErrorHandling(t, err) } @@ -1039,8 +1039,8 @@ func TestOrderBookPartialChecksumCalculator(t *testing.T) { } // Function tests ---------------------------------------------------------------------------------------------- -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.LTC.String(), @@ -1146,7 +1146,7 @@ func TestCancelExchangeOrder(t *testing.T) { CurrencyPair: currencyPair, } - err := o.CancelOrder(orderCancellation) + err := o.CancelOrder(&orderCancellation) testStandardErrorHandling(t, err) } @@ -1162,7 +1162,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { CurrencyPair: currencyPair, } - resp, err := o.CancelAllOrders(orderCancellation) + resp, err := o.CancelAllOrders(&orderCancellation) testStandardErrorHandling(t, err) if len(resp.OrderStatus) > 0 { t.Errorf("%v orders failed to cancel", len(resp.OrderStatus)) @@ -1195,7 +1195,7 @@ func TestWithdraw(t *testing.T) { TradePassword: "Password", FeeAmount: 1, } - _, err := o.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := o.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) testStandardErrorHandling(t, err) } @@ -1203,7 +1203,7 @@ func TestWithdraw(t *testing.T) { func TestWithdrawFiat(t *testing.T) { TestSetRealOrderDefaults(t) var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := o.WithdrawFiatFunds(withdrawFiatRequest) + _, err := o.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -1213,7 +1213,7 @@ func TestWithdrawFiat(t *testing.T) { func TestWithdrawInternationalBank(t *testing.T) { TestSetRealOrderDefaults(t) var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := o.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := o.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/okex/okex_test.go b/exchanges/okex/okex_test.go index a291b862..57c0cfc1 100644 --- a/exchanges/okex/okex_test.go +++ b/exchanges/okex/okex_test.go @@ -322,7 +322,7 @@ func TestPlaceSpotOrderLimit(t *testing.T) { Size: "100", } - _, err := o.PlaceSpotOrder(request) + _, err := o.PlaceSpotOrder(&request) testStandardErrorHandling(t, err) } @@ -339,7 +339,7 @@ func TestPlaceSpotOrderMarket(t *testing.T) { Notional: "100", } - _, err := o.PlaceSpotOrder(request) + _, err := o.PlaceSpotOrder(&request) testStandardErrorHandling(t, err) } @@ -676,7 +676,7 @@ func TestPlaceMarginOrderLimit(t *testing.T) { Size: "100", } - _, err := o.PlaceMarginOrder(request) + _, err := o.PlaceMarginOrder(&request) testStandardErrorHandling(t, err) } @@ -693,7 +693,7 @@ func TestPlaceMarginOrderMarket(t *testing.T) { Notional: "100", } - _, err := o.PlaceMarginOrder(request) + _, err := o.PlaceMarginOrder(&request) testStandardErrorHandling(t, err) } @@ -1797,8 +1797,8 @@ func TestOrderBookPartialChecksumCalculator(t *testing.T) { } // Function tests ---------------------------------------------------------------------------------------------- -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.LTC.String(), @@ -1914,7 +1914,7 @@ func TestCancelExchangeOrder(t *testing.T) { CurrencyPair: currencyPair, } - err := o.CancelOrder(orderCancellation) + err := o.CancelOrder(&orderCancellation) testStandardErrorHandling(t, err) } @@ -1931,7 +1931,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { CurrencyPair: currencyPair, } - resp, err := o.CancelAllOrders(orderCancellation) + resp, err := o.CancelAllOrders(&orderCancellation) testStandardErrorHandling(t, err) if len(resp.OrderStatus) > 0 { @@ -1967,7 +1967,7 @@ func TestWithdraw(t *testing.T) { TradePassword: "Password", FeeAmount: 1, } - _, err := o.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := o.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) testStandardErrorHandling(t, err) } @@ -1976,7 +1976,8 @@ func TestWithdrawFiat(t *testing.T) { TestSetRealOrderDefaults(t) t.Parallel() var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := o.WithdrawFiatFunds(withdrawFiatRequest) + + _, err := o.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -1987,7 +1988,8 @@ func TestWithdrawInternationalBank(t *testing.T) { TestSetRealOrderDefaults(t) t.Parallel() var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := o.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + + _, err := o.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/okgroup/okgroup.go b/exchanges/okgroup/okgroup.go index b056caf7..acd48525 100644 --- a/exchanges/okgroup/okgroup.go +++ b/exchanges/okgroup/okgroup.go @@ -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) } @@ -247,7 +247,7 @@ func (o *OKGroup) GetSpotBillDetailsForCurrency(request GetSpotBillDetailsForCur // PlaceSpotOrder token trading only supports limit and market orders (more order types will become available in the future). // You can place an order only if you have enough funds. // Once your order is placed, the amount will be put on hold. -func (o *OKGroup) PlaceSpotOrder(request PlaceSpotOrderRequest) (resp PlaceSpotOrderResponse, _ error) { +func (o *OKGroup) PlaceSpotOrder(request *PlaceSpotOrderRequest) (resp PlaceSpotOrderResponse, _ error) { return resp, o.SendHTTPRequest(http.MethodPost, okGroupTokenSubsection, OKGroupOrders, request, &resp, true) } @@ -448,7 +448,7 @@ func (o *OKGroup) RepayMarginLoan(request RepayMarginLoanRequest) (resp RepayMar // PlaceMarginOrder OKEx API only supports limit and market orders (more orders will become available in the future). // You can place an order only if you have enough funds. Once your order is placed, the amount will be put on hold. -func (o *OKGroup) PlaceMarginOrder(request PlaceSpotOrderRequest) (resp PlaceSpotOrderResponse, _ error) { +func (o *OKGroup) PlaceMarginOrder(request *PlaceSpotOrderRequest) (resp PlaceSpotOrderResponse, _ error) { return resp, o.SendHTTPRequest(http.MethodPost, okGroupMarginTradingSubsection, OKGroupOrders, request, &resp, true) } @@ -665,7 +665,7 @@ func (o *OKGroup) SetCheckVarDefaults() { } // GetFee returns an estimate of fee based on type of transaction -func (o *OKGroup) GetFee(feeBuilder exchange.FeeBuilder) (fee float64, _ error) { +func (o *OKGroup) GetFee(feeBuilder *exchange.FeeBuilder) (fee float64, _ error) { switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount, feeBuilder.IsMaker) diff --git a/exchanges/okgroup/okgroup_wrapper.go b/exchanges/okgroup/okgroup_wrapper.go index 42555658..a0cda0d4 100644 --- a/exchanges/okgroup/okgroup_wrapper.go +++ b/exchanges/okgroup/okgroup_wrapper.go @@ -230,7 +230,7 @@ func (o *OKGroup) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderTyp request.Price = strconv.FormatFloat(price, 'f', -1, 64) } - orderResponse, err := o.PlaceSpotOrder(request) + orderResponse, err := o.PlaceSpotOrder(&request) if err != nil { return } @@ -247,7 +247,7 @@ func (o *OKGroup) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (o *OKGroup) CancelOrder(orderCancellation exchange.OrderCancellation) (err error) { +func (o *OKGroup) CancelOrder(orderCancellation *exchange.OrderCancellation) (err error) { orderID, err := strconv.ParseInt(orderCancellation.OrderID, 10, 64) if err != nil { return @@ -264,7 +264,7 @@ func (o *OKGroup) CancelOrder(orderCancellation exchange.OrderCancellation) (err } // CancelAllOrders cancels all orders associated with a currency pair -func (o *OKGroup) CancelAllOrders(orderCancellation exchange.OrderCancellation) (resp exchange.CancelAllOrdersResponse, _ error) { +func (o *OKGroup) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (resp exchange.CancelAllOrdersResponse, _ error) { orderIDs := strings.Split(orderCancellation.OrderID, ",") var orderIDNumbers []int64 for _, i := range orderIDs { @@ -322,7 +322,7 @@ func (o *OKGroup) GetDepositAddress(p currency.Code, accountID string) (_ string // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (o *OKGroup) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (o *OKGroup) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { withdrawal, err := o.AccountWithdraw(AccountWithdrawRequest{ Amount: withdrawRequest.Amount, Currency: withdrawRequest.Currency.Lower().String(), @@ -343,18 +343,18 @@ func (o *OKGroup) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (o *OKGroup) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (o *OKGroup) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (o *OKGroup) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (o *OKGroup) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // GetActiveOrders retrieves any orders that are active/open -func (o *OKGroup) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) (resp []exchange.OrderDetail, err error) { +func (o *OKGroup) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) (resp []exchange.OrderDetail, err error) { for _, currency := range getOrdersRequest.Currencies { spotOpenOrders, err := o.GetSpotOpenOrders(GetSpotOpenOrdersRequest{ InstrumentID: exchange.FormatExchangeCurrency(o.Name, currency).String(), @@ -379,7 +379,7 @@ func (o *OKGroup) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) (r // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (o *OKGroup) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) (resp []exchange.OrderDetail, err error) { +func (o *OKGroup) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) (resp []exchange.OrderDetail, err error) { for _, currency := range getOrdersRequest.Currencies { spotOpenOrders, err := o.GetSpotOrders(GetSpotOrdersRequest{ InstrumentID: exchange.FormatExchangeCurrency(o.Name, currency).String(), @@ -408,7 +408,7 @@ func (o *OKGroup) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (o *OKGroup) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (o *OKGroup) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return o.GetFee(feeBuilder) } diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index c4cbc938..22c01f35 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -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) } @@ -899,7 +899,7 @@ func (p *Poloniex) SendAuthenticatedHTTPRequest(method, endpoint string, values } // GetFee returns an estimate of fee based on type of transaction -func (p *Poloniex) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (p *Poloniex) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/poloniex/poloniex_test.go b/exchanges/poloniex/poloniex_test.go index a5c617f2..ef12ed84 100644 --- a/exchanges/poloniex/poloniex_test.go +++ b/exchanges/poloniex/poloniex_test.go @@ -86,8 +86,8 @@ func TestGetLoanOrders(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.LTC.String(), @@ -198,7 +198,7 @@ func TestGetActiveOrders(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := p.GetActiveOrders(getOrdersRequest) + _, err := p.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -214,7 +214,7 @@ func TestGetOrderHistory(t *testing.T) { OrderType: exchange.AnyOrderType, } - _, err := p.GetOrderHistory(getOrdersRequest) + _, err := p.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -270,7 +270,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -297,7 +297,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -339,7 +339,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := p.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := p.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -358,7 +358,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := p.WithdrawFiatFunds(withdrawFiatRequest) + _, err := p.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -374,7 +374,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := p.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := p.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/poloniex/poloniex_wrapper.go b/exchanges/poloniex/poloniex_wrapper.go index ab1a628b..97ca9cec 100644 --- a/exchanges/poloniex/poloniex_wrapper.go +++ b/exchanges/poloniex/poloniex_wrapper.go @@ -229,7 +229,7 @@ func (p *Poloniex) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (p *Poloniex) CancelOrder(order exchange.OrderCancellation) error { +func (p *Poloniex) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -242,7 +242,7 @@ func (p *Poloniex) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (p *Poloniex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (p *Poloniex) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -287,20 +287,20 @@ func (p *Poloniex) GetDepositAddress(cryptocurrency currency.Code, _ string) (st // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (p *Poloniex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (p *Poloniex) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { _, err := p.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.Amount) return "", err } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (p *Poloniex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (p *Poloniex) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (p *Poloniex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (p *Poloniex) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -310,12 +310,12 @@ func (p *Poloniex) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (p *Poloniex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (p *Poloniex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return p.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (p *Poloniex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (p *Poloniex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := p.GetOpenOrdersForAllCurrencies() if err != nil { return nil, err @@ -355,7 +355,7 @@ func (p *Poloniex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ( // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (p *Poloniex) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (p *Poloniex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { resp, err := p.GetAuthenticatedTradeHistory(getOrdersRequest.StartTicks.Unix(), getOrdersRequest.EndTicks.Unix(), 10000) diff --git a/exchanges/yobit/yobit.go b/exchanges/yobit/yobit.go index 61b26011..8fa6a9bf 100644 --- a/exchanges/yobit/yobit.go +++ b/exchanges/yobit/yobit.go @@ -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) } @@ -385,7 +385,7 @@ func (y *Yobit) SendAuthenticatedHTTPRequest(path string, params url.Values, res } // GetFee returns an estimate of fee based on type of transaction -func (y *Yobit) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (y *Yobit) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/yobit/yobit_test.go b/exchanges/yobit/yobit_test.go index 0bbdfe91..c29b5b79 100644 --- a/exchanges/yobit/yobit_test.go +++ b/exchanges/yobit/yobit_test.go @@ -134,8 +134,8 @@ func TestRedeemYobicode(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.LTC.String(), @@ -306,7 +306,7 @@ func TestGetActiveOrders(t *testing.T) { currency.BTC)}, } - _, err := y.GetActiveOrders(getOrdersRequest) + _, err := y.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -326,7 +326,7 @@ func TestGetOrderHistory(t *testing.T) { EndTicks: time.Unix(math.MaxInt64, 0), } - _, err := y.GetOrderHistory(getOrdersRequest) + _, err := y.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -375,7 +375,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -401,7 +401,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -443,7 +443,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := y.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := y.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -462,7 +462,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := y.WithdrawFiatFunds(withdrawFiatRequest) + _, err := y.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -478,7 +478,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := y.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := y.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/yobit/yobit_wrapper.go b/exchanges/yobit/yobit_wrapper.go index 74211b24..c00743af 100644 --- a/exchanges/yobit/yobit_wrapper.go +++ b/exchanges/yobit/yobit_wrapper.go @@ -189,7 +189,7 @@ func (y *Yobit) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (y *Yobit) CancelOrder(order exchange.OrderCancellation) error { +func (y *Yobit) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { return err @@ -200,7 +200,7 @@ func (y *Yobit) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (y *Yobit) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (y *Yobit) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -250,7 +250,7 @@ func (y *Yobit) GetDepositAddress(cryptocurrency currency.Code, _ string) (strin // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { resp, err := y.WithdrawCoinsToAddress(withdrawRequest.Currency.String(), withdrawRequest.Amount, withdrawRequest.Address) if err != nil { return "", err @@ -263,13 +263,13 @@ func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReq // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (y *Yobit) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (y *Yobit) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (y *Yobit) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (y *Yobit) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -279,12 +279,12 @@ func (y *Yobit) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (y *Yobit) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (y *Yobit) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return y.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open -func (y *Yobit) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (y *Yobit) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var orders []exchange.OrderDetail for _, c := range getOrdersRequest.Currencies { resp, err := y.GetOpenOrders(exchange.FormatExchangeCurrency(y.Name, @@ -319,7 +319,7 @@ func (y *Yobit) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]e // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func (y *Yobit) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (y *Yobit) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var allOrders []TradeHistory for _, currency := range getOrdersRequest.Currencies { resp, err := y.GetTradeHistory(0, diff --git a/exchanges/zb/zb.go b/exchanges/zb/zb.go index e37b7bda..31b5292e 100644 --- a/exchanges/zb/zb.go +++ b/exchanges/zb/zb.go @@ -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) } @@ -415,7 +415,7 @@ func (z *ZB) SendAuthenticatedHTTPRequest(httpMethod string, params url.Values, } // GetFee returns an estimate of fee based on type of transaction -func (z *ZB) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { +func (z *ZB) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: diff --git a/exchanges/zb/zb_test.go b/exchanges/zb/zb_test.go index 9a2a0a06..79f788f6 100644 --- a/exchanges/zb/zb_test.go +++ b/exchanges/zb/zb_test.go @@ -125,8 +125,8 @@ func TestGetSpotKline(t *testing.T) { } } -func setFeeBuilder() exchange.FeeBuilder { - return exchange.FeeBuilder{ +func setFeeBuilder() *exchange.FeeBuilder { + return &exchange.FeeBuilder{ Amount: 1, FeeType: exchange.CryptocurrencyTradeFee, Pair: currency.NewPairWithDelimiter(currency.LTC.String(), @@ -237,7 +237,7 @@ func TestGetActiveOrders(t *testing.T) { currency.BTC)}, } - _, err := z.GetActiveOrders(getOrdersRequest) + _, err := z.GetActiveOrders(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get open orders: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -256,7 +256,7 @@ func TestGetOrderHistory(t *testing.T) { currency.BTC)}, } - _, err := z.GetOrderHistory(getOrdersRequest) + _, err := z.GetOrderHistory(&getOrdersRequest) if areTestAPIKeysSet() && err != nil { t.Errorf("Could not get order history: %s", err) } else if !areTestAPIKeysSet() && err == nil { @@ -313,7 +313,7 @@ func TestCancelExchangeOrder(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -339,7 +339,7 @@ func TestCancelAllExchangeOrders(t *testing.T) { currencyPair := currency.NewPair(currency.LTC, currency.BTC) - var orderCancellation = exchange.OrderCancellation{ + var orderCancellation = &exchange.OrderCancellation{ OrderID: "1", WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", AccountID: "1", @@ -396,7 +396,7 @@ func TestWithdraw(t *testing.T) { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } - _, err := z.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) + _, err := z.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } @@ -415,7 +415,7 @@ func TestWithdrawFiat(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := z.WithdrawFiatFunds(withdrawFiatRequest) + _, err := z.WithdrawFiatFunds(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } @@ -431,7 +431,7 @@ func TestWithdrawInternationalBank(t *testing.T) { var withdrawFiatRequest = exchange.WithdrawRequest{} - _, err := z.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + _, err := z.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest) if err != common.ErrFunctionNotSupported { t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err) } diff --git a/exchanges/zb/zb_wrapper.go b/exchanges/zb/zb_wrapper.go index f5617caf..3d62305a 100644 --- a/exchanges/zb/zb_wrapper.go +++ b/exchanges/zb/zb_wrapper.go @@ -222,7 +222,7 @@ func (z *ZB) ModifyOrder(action exchange.ModifyOrder) (string, error) { } // CancelOrder cancels an order by its corresponding ID number -func (z *ZB) CancelOrder(order exchange.OrderCancellation) error { +func (z *ZB) CancelOrder(order *exchange.OrderCancellation) error { orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64) if err != nil { @@ -233,7 +233,7 @@ func (z *ZB) CancelOrder(order exchange.OrderCancellation) error { } // CancelAllOrders cancels all orders associated with a currency pair -func (z *ZB) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func (z *ZB) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{ OrderStatus: make(map[string]string), } @@ -284,19 +284,19 @@ func (z *ZB) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (z *ZB) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (z *ZB) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return z.Withdraw(withdrawRequest.Currency.Lower().String(), withdrawRequest.Address, withdrawRequest.TradePassword, withdrawRequest.Amount, withdrawRequest.FeeAmount, false) } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (z *ZB) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (z *ZB) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (z *ZB) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func (z *ZB) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrFunctionNotSupported } @@ -306,13 +306,13 @@ func (z *ZB) GetWebsocket() (*exchange.Websocket, error) { } // GetFeeByType returns an estimate of fee based on type of transaction -func (z *ZB) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { +func (z *ZB) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) { return z.GetFee(feeBuilder) } // GetActiveOrders retrieves any orders that are active/open // This function is not concurrency safe due to orderSide/orderType maps -func (z *ZB) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (z *ZB) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { var allOrders []Order for _, currency := range getOrdersRequest.Currencies { var pageNumber int64 @@ -358,7 +358,7 @@ func (z *ZB) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exch // GetOrderHistory retrieves account order information // Can Limit response to specific order status // This function is not concurrency safe due to orderSide/orderType maps -func (z *ZB) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func (z *ZB) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { if getOrdersRequest.OrderSide == exchange.AnyOrderSide || getOrdersRequest.OrderSide == "" { return nil, errors.New("specific order side is required") } diff --git a/restful_server.go b/restful_server.go index 9594d6bf..bf21e703 100644 --- a/restful_server.go +++ b/restful_server.go @@ -75,7 +75,7 @@ func RESTSaveAllSettings(w http.ResponseWriter, r *http.Request) { } // Save change the settings - err = bot.config.UpdateConfig(bot.configFile, responseData.Data) + err = bot.config.UpdateConfig(bot.configFile, &responseData.Data) if err != nil { RESTfulError(r.Method, err) } diff --git a/tools/exchange_template/main_file.tmpl b/tools/exchange_template/main_file.tmpl index a65a298d..ddae83ca 100644 --- a/tools/exchange_template/main_file.tmpl +++ b/tools/exchange_template/main_file.tmpl @@ -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 0a512171..131017e0 100644 --- a/tools/exchange_template/wrapper_file.tmpl +++ b/tools/exchange_template/wrapper_file.tmpl @@ -127,12 +127,12 @@ func ({{.Variable}} *{{.CapitalName}}) ModifyOrder(action exchange.ModifyOrder) } // CancelOrder cancels an order by its corresponding ID number -func ({{.Variable}} *{{.CapitalName}}) CancelOrder(order exchange.OrderCancellation) error { +func ({{.Variable}} *{{.CapitalName}}) CancelOrder(order *exchange.OrderCancellation) error { return common.ErrNotYetImplemented } // CancelAllOrders cancels all orders associated with a currency pair -func ({{.Variable}} *{{.CapitalName}}) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { +func ({{.Variable}} *{{.CapitalName}}) CancelAllOrders(orderCancellation *exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) { return exchange.CancelAllOrdersResponse{}, common.ErrNotYetImplemented } @@ -148,19 +148,19 @@ func ({{.Variable}} *{{.CapitalName}}) GetDepositAddress(cryptocurrency pair.Cur // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func ({{.Variable}} *{{.CapitalName}}) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func ({{.Variable}} *{{.CapitalName}}) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { +func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { +func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error) { return "", common.ErrNotYetImplemented } @@ -170,13 +170,13 @@ func ({{.Variable}} *{{.CapitalName}}) GetWebsocket() (*exchange.Websocket, erro } // GetActiveOrders retrieves any orders that are active/open -func ({{.Variable}} *{{.CapitalName}}) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func ({{.Variable}} *{{.CapitalName}}) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrNotYetImplemented } // GetOrderHistory retrieves account order information // Can Limit response to specific order status -func ({{.Variable}} *{{.CapitalName}}) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { +func ({{.Variable}} *{{.CapitalName}}) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) { return nil, common.ErrNotYetImplemented } diff --git a/websocket.go b/websocket.go index 724f2dd2..a817ce46 100644 --- a/websocket.go +++ b/websocket.go @@ -349,7 +349,7 @@ func wsSaveConfig(client *WebsocketClient, data interface{}) error { return err } - err = bot.config.UpdateConfig(bot.configFile, cfg) + err = bot.config.UpdateConfig(bot.configFile, &cfg) if err != nil { wsResp.Error = err.Error() client.SendWebsocketMessage(wsResp)