diff --git a/common/common.go b/common/common.go index 7b96d7f3..432e161e 100644 --- a/common/common.go +++ b/common/common.go @@ -34,6 +34,14 @@ import ( // Vars for common.go operations var ( HTTPClient *http.Client + + // ErrNotYetImplemented defines a common error across the code base that + // alerts of a function that has not been completed or tied into main code + ErrNotYetImplemented = errors.New("Not Yet Implemented") + + // ErrFunctionNotSupported defines a standardised error for an unsupported + // wrapper function by an API + ErrFunctionNotSupported = errors.New("Unsupported Wrapper Function") ) // Const declarations for common.go operations diff --git a/communications/slack/slack.go b/communications/slack/slack.go index 0ea2a1fc..043605a6 100644 --- a/communications/slack/slack.go +++ b/communications/slack/slack.go @@ -77,7 +77,7 @@ func (s *Slack) Connect() error { // PushEvent pushes an event to either a slack channel or specific client func (s *Slack) PushEvent(base.Event) error { - return errors.New("not yet implemented") + return common.ErrNotYetImplemented } // BuildURL returns an appended token string with the SlackURL diff --git a/communications/smsglobal/smsglobal.go b/communications/smsglobal/smsglobal.go index 5598a780..8bbef1ab 100644 --- a/communications/smsglobal/smsglobal.go +++ b/communications/smsglobal/smsglobal.go @@ -60,7 +60,7 @@ func (s *SMSGlobal) Connect() error { // PushEvent pushes an event to a contact list via SMS func (s *SMSGlobal) PushEvent(base.Event) error { - return errors.New("not yet implemented") + return common.ErrNotYetImplemented } // GetEnabledContacts returns how many SMS contacts are enabled in the diff --git a/communications/smtpservice/smtpservice.go b/communications/smtpservice/smtpservice.go index 25f9b56a..e6e35af6 100644 --- a/communications/smtpservice/smtpservice.go +++ b/communications/smtpservice/smtpservice.go @@ -46,7 +46,7 @@ func (s *SMTPservice) Connect() error { // PushEvent sends an event to supplied recipient list via SMTP func (s *SMTPservice) PushEvent(base.Event) error { - return errors.New("not yet implemented") + return common.ErrNotYetImplemented } // Send sends an email template to the recipient list via your SMTP host when diff --git a/exchanges/alphapoint/alphapoint.go b/exchanges/alphapoint/alphapoint.go index 8fc7f54d..2b0a42ea 100644 --- a/exchanges/alphapoint/alphapoint.go +++ b/exchanges/alphapoint/alphapoint.go @@ -270,8 +270,8 @@ func (a *Alphapoint) SetUserInfo(firstName, lastName, cell2FACountryCode, cell2F return response, nil } -// GetAccountInfo returns account info -func (a *Alphapoint) GetAccountInfo() (AccountInfo, error) { +// GetAccountInformation returns account info +func (a *Alphapoint) GetAccountInformation() (AccountInfo, error) { response := AccountInfo{} err := a.SendAuthenticatedHTTPRequest( @@ -398,7 +398,7 @@ func (a *Alphapoint) CreateOrder(symbol, side, orderType string, quantity, price return response.ServerOrderID, nil } -// ModifyOrder modifies and existing Order +// ModifyExistingOrder modifies and existing Order // OrderId - tracked order id number // symbol - Instrument code (ex: “BTCUSD”) // modifyAction - “0” or “1” @@ -406,7 +406,7 @@ func (a *Alphapoint) CreateOrder(symbol, side, orderType string, quantity, price // book. A buy order will be modified to the highest bid and a sell order will // be modified to the lowest ask price. “1” means "Execute now", which will // convert a limit order into a market order. -func (a *Alphapoint) ModifyOrder(symbol string, OrderID, action int64) (int64, error) { +func (a *Alphapoint) ModifyExistingOrder(symbol string, OrderID, action int64) (int64, error) { request := make(map[string]interface{}) request["ins"] = symbol request["serverOrderId"] = OrderID @@ -428,10 +428,10 @@ func (a *Alphapoint) ModifyOrder(symbol string, OrderID, action int64) (int64, e return response.ModifyOrderID, nil } -// CancelOrder cancels an order that has not been executed. +// CancelExistingOrder cancels an order that has not been executed. // symbol - Instrument code (ex: “BTCUSD”) // OrderId - Order id (ex: 1000) -func (a *Alphapoint) CancelOrder(symbol string, OrderID int64) (int64, error) { +func (a *Alphapoint) CancelExistingOrder(symbol string, OrderID int64) (int64, error) { request := make(map[string]interface{}) request["ins"] = symbol request["serverOrderId"] = OrderID @@ -452,9 +452,9 @@ func (a *Alphapoint) CancelOrder(symbol string, OrderID int64) (int64, error) { return response.CancelOrderID, nil } -// CancelAllOrders cancels all open orders by symbol +// CancelAllExistingOrders cancels all open orders by symbol // symbol - Instrument code (ex: “BTCUSD”) -func (a *Alphapoint) CancelAllOrders(symbol string) error { +func (a *Alphapoint) CancelAllExistingOrders(symbol string) error { request := make(map[string]interface{}) request["ins"] = symbol response := Response{} diff --git a/exchanges/alphapoint/alphapoint_test.go b/exchanges/alphapoint/alphapoint_test.go index f6c0bbe0..f4d4f476 100644 --- a/exchanges/alphapoint/alphapoint_test.go +++ b/exchanges/alphapoint/alphapoint_test.go @@ -417,7 +417,7 @@ func TestCreateOrder(t *testing.T) { } } -func TestModifyOrder(t *testing.T) { +func TestModifyExistingOrder(t *testing.T) { a := &Alphapoint{} a.SetDefaults() testSetAPIKey(a) @@ -426,13 +426,13 @@ func TestModifyOrder(t *testing.T) { return } - _, err := a.ModifyOrder("", 1, 1) + _, err := a.ModifyExistingOrder("", 1, 1) if err == nil { t.Error("Test Failed - GetUserInfo() error") } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { a := &Alphapoint{} a.SetDefaults() testSetAPIKey(a) @@ -441,13 +441,13 @@ func TestCancelOrder(t *testing.T) { return } - _, err := a.CancelOrder("", 1) + _, err := a.CancelExistingOrder("", 1) if err == nil { t.Error("Test Failed - GetUserInfo() error") } } -func TestCancelAllOrders(t *testing.T) { +func TestCancelAllExistingOrders(t *testing.T) { a := &Alphapoint{} a.SetDefaults() testSetAPIKey(a) @@ -456,7 +456,7 @@ func TestCancelAllOrders(t *testing.T) { return } - err := a.CancelAllOrders("") + err := a.CancelAllExistingOrders("") if err == nil { t.Error("Test Failed - GetUserInfo() error") } diff --git a/exchanges/alphapoint/alphapoint_wrapper.go b/exchanges/alphapoint/alphapoint_wrapper.go index 496a29b7..dc877815 100644 --- a/exchanges/alphapoint/alphapoint_wrapper.go +++ b/exchanges/alphapoint/alphapoint_wrapper.go @@ -4,18 +4,19 @@ import ( "errors" "fmt" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" "github.com/thrasher-/gocryptotrader/exchanges/ticker" ) -// GetExchangeAccountInfo retrieves balances for all enabled currencies on the +// GetAccountInfo retrieves balances for all enabled currencies on the // Alphapoint exchange -func (a *Alphapoint) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (a *Alphapoint) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = a.GetName() - account, err := a.GetAccountInfo() + account, err := a.GetAccountInformation() if err != nil { return response, err } @@ -27,7 +28,6 @@ func (a *Alphapoint) GetExchangeAccountInfo() (exchange.AccountInfo, error) { response.Currencies = append(response.Currencies, exchangeCurrency) } - //If it all works out return response, nil } @@ -90,23 +90,23 @@ func (a *Alphapoint) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orde return ob, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (a *Alphapoint) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (a *Alphapoint) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (a *Alphapoint) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order and returns a true value when +// SubmitOrder submits a new order and returns a true value when // successfully submitted -func (a *Alphapoint) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +func (a *Alphapoint) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := a.CreateOrder(p.Pair().String(), side.ToString(), orderType.ToString(), amount, price) @@ -121,27 +121,27 @@ func (a *Alphapoint) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.Orde return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (a *Alphapoint) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - //return a.ModifyOrder(p.Pair().String(), orderID, action) - return 0, errors.New("not yet implemented") +func (a *Alphapoint) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + // return a.ModifyExistingOrder(p.Pair().String(), orderID, action) + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (a *Alphapoint) CancelExchangeOrder(orderID int64) error { - //return a.CancelOrder(p.Pair().String(), orderID) - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (a *Alphapoint) CancelOrder(orderID int64) error { + // return a.CancelExistingOrder(p.Pair().String(), orderID) + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (a *Alphapoint) CancelAllExchangeOrders() error { - //return a.CancelAllOrders(p.Pair().String()) - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (a *Alphapoint) CancelAllOrders() error { + // return a.CancelAllExistingOrders(p.Pair().String()) + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (a *Alphapoint) GetExchangeOrderInfo(orderID int64) (float64, error) { +// GetOrderInfo returns information on a current open order +func (a *Alphapoint) GetOrderInfo(orderID int64) (float64, error) { orders, err := a.GetOrders() if err != nil { return 0, err @@ -157,8 +157,8 @@ func (a *Alphapoint) GetExchangeOrderInfo(orderID int64) (float64, error) { return 0, errors.New("order not found") } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (a *Alphapoint) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { +// GetDepositAddress returns a deposit address for a specified currency +func (a *Alphapoint) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { addreses, err := a.GetDepositAddresses() if err != nil { return "", err @@ -172,25 +172,25 @@ func (a *Alphapoint) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) return "", errors.New("associated currency address not found") } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (a *Alphapoint) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (a *Alphapoint) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted -func (a *Alphapoint) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted +func (a *Alphapoint) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (a *Alphapoint) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction func (a *Alphapoint) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) { - return 0, errors.New("not yet implemented") + return 0, common.ErrNotYetImplemented } // GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange diff --git a/exchanges/anx/README.md b/exchanges/anx/README.md index 785ed640..8bb7617e 100644 --- a/exchanges/anx/README.md +++ b/exchanges/anx/README.md @@ -75,7 +75,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := a.GetExchangeAccountInfo() +accountInfo, err := a.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/anx/anx.go b/exchanges/anx/anx.go index e28a0ed7..276ffafe 100644 --- a/exchanges/anx/anx.go +++ b/exchanges/anx/anx.go @@ -321,8 +321,8 @@ func (a *ANX) CreateNewSubAccount(currency, name string) (string, error) { return response.SubAccount, nil } -// GetDepositAddress returns a deposit address for a specific currency -func (a *ANX) GetDepositAddress(currency, name string, new bool) (string, error) { +// GetDepositAddressByCurrency returns a deposit address for a specific currency +func (a *ANX) GetDepositAddressByCurrency(currency, name string, new bool) (string, error) { request := make(map[string]interface{}) request["ccy"] = currency @@ -449,12 +449,8 @@ func getInternationalBankWithdrawalFee(currency string, amount float64) float64 // GetAccountInformation retrieves details including API permissions func (a *ANX) GetAccountInformation() (AccountInformation, error) { - request := make(map[string]interface{}) - var response AccountInformation - - err := a.SendAuthenticatedHTTPRequest(anxOrderInfo, request, &response) - + err := a.SendAuthenticatedHTTPRequest(anxOrderInfo, nil, &response) if err != nil { return response, err } diff --git a/exchanges/anx/anx_test.go b/exchanges/anx/anx_test.go index 44b75bd2..f49ca9cc 100644 --- a/exchanges/anx/anx_test.go +++ b/exchanges/anx/anx_test.go @@ -9,6 +9,12 @@ import ( exchange "github.com/thrasher-/gocryptotrader/exchanges" ) +// Please supply your own keys here for due diligence testing +const ( + testAPIKey = "" + testAPISecret = "" +) + var a ANX const ( @@ -51,11 +57,15 @@ func TestSetup(t *testing.T) { t.Error("Test Failed - ANX Setup() init error") } a.Setup(anxConfig) + if testAPIKey != "" && testAPISecret != "" { + a.APIKey = testAPIKey + a.APISecret = testAPISecret + a.AuthenticatedAPISupport = true + } if a.Enabled != true { t.Error("Test Failed - ANX Setup() incorrect values set") } - if a.RESTPollingDelay != 10 { t.Error("Test Failed - ANX Setup() incorrect values set") } @@ -236,7 +246,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USD, } - response, err := a.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := a.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/anx/anx_wrapper.go b/exchanges/anx/anx_wrapper.go index 145b2759..bf407468 100644 --- a/exchanges/anx/anx_wrapper.go +++ b/exchanges/anx/anx_wrapper.go @@ -1,7 +1,6 @@ package anx import ( - "errors" "log" "strconv" "sync" @@ -174,29 +173,29 @@ func (a *ANX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook. return orderbook.GetOrderbook(a.Name, p, assetType) } -//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the ANX exchange -func (a *ANX) GetExchangeAccountInfo() (exchange.AccountInfo, error) { - var response exchange.AccountInfo - response.ExchangeName = a.GetName() - return response, nil +// GetAccountInfo retrieves balances for all enabled currencies on the +// exchange +func (a *ANX) GetAccountInfo() (exchange.AccountInfo, error) { + var info exchange.AccountInfo + return info, common.ErrNotYetImplemented } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (a *ANX) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (a *ANX) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (a *ANX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (a *ANX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (a *ANX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var isBuying bool @@ -222,54 +221,54 @@ func (a *ANX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (a *ANX) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (a *ANX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (a *ANX) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (a *ANX) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (a *ANX) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (a *ANX) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (a *ANX) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (a *ANX) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (a *ANX) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (a *ANX) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (a *ANX) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (a *ANX) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (a *ANX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (a *ANX) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func (a *ANX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (a *ANX) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (a *ANX) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrFunctionNotSupported } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/binance/README.md b/exchanges/binance/README.md index 73c15cf3..e8352692 100644 --- a/exchanges/binance/README.md +++ b/exchanges/binance/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index da9f9dc8..bda24ff9 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -478,9 +478,8 @@ func (b *Binance) NewOrder(o NewOrderRequest) (NewOrderResponse, error) { return resp, nil } -// CancelOrder sends a cancel order to Binance -func (b *Binance) CancelOrder(symbol string, orderID int64, origClientOrderID string) (CancelOrderResponse, error) { - +// CancelExistingOrder sends a cancel order to Binance +func (b *Binance) CancelExistingOrder(symbol string, orderID int64, origClientOrderID string) (CancelOrderResponse, error) { var resp CancelOrderResponse path := fmt.Sprintf("%s%s", b.APIUrl, cancelOrder) @@ -496,10 +495,7 @@ func (b *Binance) CancelOrder(symbol string, orderID int64, origClientOrderID st params.Set("origClientOrderId", origClientOrderID) } - if err := b.SendAuthHTTPRequest("DELETE", path, params, &resp); err != nil { - return resp, err - } - return resp, nil + return resp, b.SendAuthHTTPRequest("DELETE", path, params, &resp) } // OpenOrders Current open orders diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index 57d01ff9..de79b353 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -166,16 +166,16 @@ func TestNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() if testAPIKey == "" || testAPISecret == "" { t.Skip() } - _, err := b.CancelOrder("BTCUSDT", 82584683, "") + _, err := b.CancelExistingOrder("BTCUSDT", 82584683, "") if err == nil { - t.Error("Test Failed - Binance CancelOrder() error", err) + t.Error("Test Failed - Binance CancelExistingOrder() error", err) } } @@ -355,7 +355,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.LTC, SecondCurrency: symbol.BTC, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/binance/binance_types.go b/exchanges/binance/binance_types.go index 92ab3365..dafa9679 100644 --- a/exchanges/binance/binance_types.go +++ b/exchanges/binance/binance_types.go @@ -231,7 +231,7 @@ type CandleStick struct { TakerBuyQuoteAssetVolume float64 } -// AvgPrice holds current average symbol price +// AveragePrice holds current average symbol price type AveragePrice struct { Mins int64 `json:"mins"` Price float64 `json:"price,string"` diff --git a/exchanges/binance/binance_wrapper.go b/exchanges/binance/binance_wrapper.go index ef3a6f75..f625bbc3 100644 --- a/exchanges/binance/binance_wrapper.go +++ b/exchanges/binance/binance_wrapper.go @@ -120,29 +120,29 @@ func (b *Binance) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderb return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Bithumb exchange -func (b *Binance) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Binance) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo - return response, errors.New("not implemented") + return response, common.ErrNotYetImplemented } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Binance) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Binance) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Binance) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Binance) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Binance) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var sideType RequestParamsSideType @@ -183,49 +183,49 @@ func (b *Binance) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSi return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Binance) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Binance) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Binance) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Binance) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Binance) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Binance) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Binance) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Binance) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Binance) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Binance) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Binance) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Binance) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Binance) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Binance) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Binance) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Binance) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitfinex/README.md b/exchanges/bitfinex/README.md index 1a5f7f85..b1ee3479 100644 --- a/exchanges/bitfinex/README.md +++ b/exchanges/bitfinex/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index af96f0e1..7e5bd42d 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -489,8 +489,8 @@ func (b *Bitfinex) GetSymbolsDetails() ([]SymbolDetails, error) { return response, b.SendHTTPRequest(path, &response, b.Verbose) } -// GetAccountInfo returns information about your account incl. trading fees -func (b *Bitfinex) GetAccountInfo() ([]AccountInfo, error) { +// GetAccountInformation returns information about your account incl. trading fees +func (b *Bitfinex) GetAccountInformation() ([]AccountInfo, error) { var responses []AccountInfo err := b.SendAuthenticatedHTTPRequest("POST", bitfinexAccountInfo, nil, &responses) @@ -628,8 +628,8 @@ func (b *Bitfinex) NewOrderMulti(orders []PlaceOrder) (OrderMultiResponse, error b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderNewMulti, request, &response) } -// CancelOrder cancels a single order -func (b *Bitfinex) CancelOrder(OrderID int64) (Order, error) { +// CancelExistingOrder cancels a single order by OrderID +func (b *Bitfinex) CancelExistingOrder(OrderID int64) (Order, error) { response := Order{} request := make(map[string]interface{}) request["order_id"] = OrderID @@ -648,8 +648,8 @@ func (b *Bitfinex) CancelMultipleOrders(OrderIDs []int64) (string, error) { b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderCancelMulti, request, nil) } -// CancelAllOrders cancels all active and open orders -func (b *Bitfinex) CancelAllOrders() (string, error) { +// CancelAllExistingOrders cancels all active and open orders +func (b *Bitfinex) CancelAllExistingOrders() (string, error) { response := GenericResponse{} return response.Result, @@ -925,7 +925,7 @@ func (b *Bitfinex) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) { switch feeBuilder.FeeType { case exchange.CryptocurrencyTradeFee: - accountInfos, err := b.GetAccountInfo() + accountInfos, err := b.GetAccountInformation() if err != nil { return 0, err } diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index cb160a87..aa24bcf1 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -383,15 +383,15 @@ func TestNewOrderMulti(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { if b.APIKey == "" || b.APISecret == "" { t.SkipNow() } t.Parallel() - _, err := b.CancelOrder(1337) + _, err := b.CancelExistingOrder(1337) if err == nil { - t.Error("Test Failed - CancelOrder() error") + t.Error("Test Failed - CancelExistingOrder() error") } } @@ -407,15 +407,15 @@ func TestCancelMultipleOrders(t *testing.T) { } } -func TestCancelAllOrders(t *testing.T) { +func TestCancelAllExistingOrders(t *testing.T) { if b.APIKey == "" || b.APISecret == "" { t.SkipNow() } t.Parallel() - _, err := b.CancelAllOrders() + _, err := b.CancelAllExistingOrders() if err == nil { - t.Error("Test Failed - CancelAllOrders() error") + t.Error("Test Failed - CancelAllExistingOrders() error") } } @@ -737,7 +737,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.LTC, SecondCurrency: symbol.BTC, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/bitfinex/bitfinex_wrapper.go b/exchanges/bitfinex/bitfinex_wrapper.go index 09b967fa..c6a366fb 100644 --- a/exchanges/bitfinex/bitfinex_wrapper.go +++ b/exchanges/bitfinex/bitfinex_wrapper.go @@ -1,7 +1,6 @@ package bitfinex import ( - "errors" "fmt" "log" "net/url" @@ -113,9 +112,9 @@ func (b *Bitfinex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (order return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies on the +// GetAccountInfo retrieves balances for all enabled currencies on the // Bitfinex exchange -func (b *Bitfinex) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Bitfinex) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = b.GetName() accountBalance, err := b.GetAccountBalance() @@ -160,22 +159,22 @@ func (b *Bitfinex) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Bitfinex) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Bitfinex) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Bitfinex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Bitfinex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Bitfinex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var isBuying bool @@ -196,48 +195,48 @@ func (b *Bitfinex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderS return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Bitfinex) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Bitfinex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Bitfinex) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Bitfinex) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Bitfinex) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Bitfinex) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Bitfinex) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Bitfinex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Bitfinex) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Bitfinex) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted -func (b *Bitfinex) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted +func (b *Bitfinex) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitfinex) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitfinex) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitfinex) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitflyer/README.md b/exchanges/bitflyer/README.md index 1563d5de..16554813 100644 --- a/exchanges/bitflyer/README.md +++ b/exchanges/bitflyer/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/bitflyer/bitflyer.go b/exchanges/bitflyer/bitflyer.go index 9313a795..e79d3dce 100644 --- a/exchanges/bitflyer/bitflyer.go +++ b/exchanges/bitflyer/bitflyer.go @@ -279,8 +279,8 @@ func (b *Bitflyer) GetCollateralAccounts() { // Needs to be updated } -// GetDepositAddress returns an address for cryptocurrency deposits -func (b *Bitflyer) GetDepositAddress() { +// GetCryptoDepositAddress returns an address for cryptocurrency deposits +func (b *Bitflyer) GetCryptoDepositAddress() { // Needs to be updated } @@ -319,8 +319,8 @@ func (b *Bitflyer) SendOrder() { // Needs to be updated } -// CancelOrder cancels an order -func (b *Bitflyer) CancelOrder() { +// CancelExistingOrder cancels an order +func (b *Bitflyer) CancelExistingOrder() { // Needs to be updated } @@ -334,8 +334,8 @@ func (b *Bitflyer) CancelParentOrder() { // Needs to be updated } -// CancelAllOrders cancels all orders on the exchange -func (b *Bitflyer) CancelAllOrders() { +// CancelAllExistingOrders cancels all orders on the exchange +func (b *Bitflyer) CancelAllExistingOrders() { // Needs to be updated } diff --git a/exchanges/bitflyer/bitflyer_test.go b/exchanges/bitflyer/bitflyer_test.go index 575ace59..d19dc787 100644 --- a/exchanges/bitflyer/bitflyer_test.go +++ b/exchanges/bitflyer/bitflyer_test.go @@ -264,7 +264,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.LTC, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/bitflyer/bitflyer_wrapper.go b/exchanges/bitflyer/bitflyer_wrapper.go index acbd3885..43ca45e6 100644 --- a/exchanges/bitflyer/bitflyer_wrapper.go +++ b/exchanges/bitflyer/bitflyer_wrapper.go @@ -120,9 +120,9 @@ func (b *Bitflyer) UpdateOrderbook(p pair.CurrencyPair, assetType string) (order return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies on the +// GetAccountInfo retrieves balances for all enabled currencies on the // Bitflyer exchange -func (b *Bitflyer) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Bitflyer) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = b.GetName() // accountBalance, err := b.GetAccountBalance() @@ -138,75 +138,75 @@ func (b *Bitflyer) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Bitflyer) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Bitflyer) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Bitflyer) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Bitflyer) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Bitflyer) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse - return submitOrderResponse, errors.New("not yet implemented") + return submitOrderResponse, common.ErrNotYetImplemented } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Bitflyer) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Bitflyer) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Bitflyer) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Bitflyer) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Bitflyer) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Bitflyer) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Bitflyer) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Bitflyer) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Bitflyer) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Bitflyer) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitflyer) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitflyer) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitflyer) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitflyer) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitflyer) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitflyer) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (b *Bitflyer) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange diff --git a/exchanges/bithumb/README.md b/exchanges/bithumb/README.md index 15e69d7a..0877a733 100644 --- a/exchanges/bithumb/README.md +++ b/exchanges/bithumb/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/bithumb/bithumb.go b/exchanges/bithumb/bithumb.go index 84126c17..d728df01 100644 --- a/exchanges/bithumb/bithumb.go +++ b/exchanges/bithumb/bithumb.go @@ -233,8 +233,8 @@ func (b *Bithumb) GetTransactionHistory(symbol string) (TransactionHistory, erro return response, nil } -// GetAccountInfo returns account information -func (b *Bithumb) GetAccountInfo() (Account, error) { +// GetAccountInformation returns account information +func (b *Bithumb) GetAccountInformation() (Account, error) { response := Account{} err := b.SendAuthenticatedHTTPRequest(privateAccInfo, nil, &response) diff --git a/exchanges/bithumb/bithumb_test.go b/exchanges/bithumb/bithumb_test.go index 3f53ab4a..421590b1 100644 --- a/exchanges/bithumb/bithumb_test.go +++ b/exchanges/bithumb/bithumb_test.go @@ -300,7 +300,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.LTC, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/bithumb/bithumb_wrapper.go b/exchanges/bithumb/bithumb_wrapper.go index b528e59a..b91b4bfd 100644 --- a/exchanges/bithumb/bithumb_wrapper.go +++ b/exchanges/bithumb/bithumb_wrapper.go @@ -119,29 +119,29 @@ func (b *Bithumb) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderb return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Bithumb exchange -func (b *Bithumb) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Bithumb) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo return response, errors.New("not implemented") } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Bithumb) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Bithumb) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Bithumb) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Bithumb) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Bithumb) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var err error var orderID string @@ -166,54 +166,54 @@ func (b *Bithumb) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSi return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Bithumb) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Bithumb) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Bithumb) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Bithumb) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Bithumb) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Bithumb) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Bithumb) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Bithumb) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Bithumb) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Bithumb) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bithumb) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bithumb) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bithumb) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bithumb) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bithumb) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bithumb) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (b *Bithumb) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/bitmex/README.md b/exchanges/bitmex/README.md index 04bd5c71..1e18b0ed 100644 --- a/exchanges/bitmex/README.md +++ b/exchanges/bitmex/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index 04ad86e7..1c8a7134 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -290,8 +290,8 @@ func (b *Bitmex) GetAccountExecutionTradeHistory(params GenericRequestParams) ([ &tradeHistory) } -// GetFundingHistory returns funding history -func (b *Bitmex) GetFundingHistory() ([]Funding, error) { +// GetFullFundingHistory returns funding history +func (b *Bitmex) GetFullFundingHistory() ([]Funding, error) { var fundingHistory []Funding return fundingHistory, b.SendHTTPRequest(bitmexEndpointFundingHistory, @@ -433,8 +433,8 @@ func (b *Bitmex) CancelOrders(params OrderCancelParams) ([]Order, error) { &cancelledOrders) } -// CancelAllOrders cancels all open orders on the exchange -func (b *Bitmex) CancelAllOrders(params OrderCancelAllParams) ([]Order, error) { +// CancelAllExistingOrders cancels all open orders on the exchange +func (b *Bitmex) CancelAllExistingOrders(params OrderCancelAllParams) ([]Order, error) { var cancelledOrders []Order return cancelledOrders, b.SendAuthenticatedHTTPRequest("DELETE", @@ -696,8 +696,8 @@ func (b *Bitmex) ConfirmWithdrawal(token string) (TransactionInfo, error) { &info) } -// GetDepositAddress returns a deposit address for a cryptocurency -func (b *Bitmex) GetDepositAddress(currency string) (string, error) { +// GetCryptoDepositAddress returns a deposit address for a cryptocurency +func (b *Bitmex) GetCryptoDepositAddress(currency string) (string, error) { var address string return address, b.SendAuthenticatedHTTPRequest("GET", diff --git a/exchanges/bitmex/bitmex_test.go b/exchanges/bitmex/bitmex_test.go index 1954f6d6..c142a24f 100644 --- a/exchanges/bitmex/bitmex_test.go +++ b/exchanges/bitmex/bitmex_test.go @@ -126,7 +126,7 @@ func TestGetAccountExecutionTradeHistory(t *testing.T) { func TestGetFundingHistory(t *testing.T) { _, err := b.GetFundingHistory() - if err != nil { + if err == nil { t.Error("test failed - GetFundingHistory() error", err) } } @@ -240,7 +240,7 @@ func TestCancelOrders(t *testing.T) { } func TestCancelAllOrders(t *testing.T) { - _, err := b.CancelAllOrders(OrderCancelAllParams{}) + _, err := b.CancelAllExistingOrders(OrderCancelAllParams{}) if err == nil { t.Error("test failed - CancelAllOrders() error", err) } @@ -480,7 +480,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.XBT, SecondCurrency: symbol.USD, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/bitmex/bitmex_wrapper.go b/exchanges/bitmex/bitmex_wrapper.go index c188715c..8cd23019 100644 --- a/exchanges/bitmex/bitmex_wrapper.go +++ b/exchanges/bitmex/bitmex_wrapper.go @@ -122,29 +122,30 @@ func (b *Bitmex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbo return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Bitmex exchange -func (b *Bitmex) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Bitmex) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo - return response, errors.New("not implemented") + return response, common.ErrNotYetImplemented } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Bitmex) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Bitmex) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + // b.GetFullFundingHistory() + return fundHistory, common.ErrNotYetImplemented } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Bitmex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Bitmex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Bitmex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var orderNewParams = OrderNewParams{ OrdType: side.ToString(), @@ -169,49 +170,49 @@ func (b *Bitmex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Bitmex) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Bitmex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Bitmex) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Bitmex) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Bitmex) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Bitmex) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Bitmex) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Bitmex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Bitmex) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Bitmex) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitmex) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitmex) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitmex) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitmex) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // WithdrawExchangeFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted func (b *Bitmex) WithdrawExchangeFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitstamp/README.md b/exchanges/bitstamp/README.md index 5576327b..ffdf12c6 100644 --- a/exchanges/bitstamp/README.md +++ b/exchanges/bitstamp/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index 6a3376e8..613f82c2 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -417,8 +417,8 @@ func (b *Bitstamp) GetOrderStatus(OrderID int64) (OrderStatus, error) { b.SendAuthenticatedHTTPRequest(bitstampAPIOrderStatus, false, req, &resp) } -// CancelOrder cancels order by ID -func (b *Bitstamp) CancelOrder(OrderID int64) (bool, error) { +// CancelExistingOrder cancels order by ID +func (b *Bitstamp) CancelExistingOrder(OrderID int64) (bool, error) { result := false var req = url.Values{} req.Add("id", strconv.FormatInt(OrderID, 10)) @@ -427,8 +427,8 @@ func (b *Bitstamp) CancelOrder(OrderID int64) (bool, error) { b.SendAuthenticatedHTTPRequest(bitstampAPICancelOrder, true, req, &result) } -// CancelAllOrders cancels all open orders on the exchange -func (b *Bitstamp) CancelAllOrders() (bool, error) { +// CancelAllExistingOrders cancels all open orders on the exchange +func (b *Bitstamp) CancelAllExistingOrders() (bool, error) { result := false return result, diff --git a/exchanges/bitstamp/bitstamp_test.go b/exchanges/bitstamp/bitstamp_test.go index b6ca82d3..fe95bccc 100644 --- a/exchanges/bitstamp/bitstamp_test.go +++ b/exchanges/bitstamp/bitstamp_test.go @@ -262,21 +262,21 @@ func TestGetOrderStatus(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - resp, err := b.CancelOrder(1337) + resp, err := b.CancelExistingOrder(1337) if err == nil || resp != false { - t.Error("Test Failed - CancelOrder() error") + t.Error("Test Failed - CancelExistingOrder() error") } } -func TestCancelAllOrders(t *testing.T) { +func TestCancelAllExistingOrders(t *testing.T) { t.Parallel() - _, err := b.CancelAllOrders() + _, err := b.CancelAllExistingOrders() if err == nil { - t.Error("Test Failed - CancelAllOrders() error", err) + t.Error("Test Failed - CancelAllExistingOrders() error", err) } } @@ -381,7 +381,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USD, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/bitstamp/bitstamp_wrapper.go b/exchanges/bitstamp/bitstamp_wrapper.go index 2036dd4e..11adf00e 100644 --- a/exchanges/bitstamp/bitstamp_wrapper.go +++ b/exchanges/bitstamp/bitstamp_wrapper.go @@ -1,7 +1,6 @@ package bitstamp import ( - "errors" "fmt" "log" "strings" @@ -115,9 +114,9 @@ func (b *Bitstamp) UpdateOrderbook(p pair.CurrencyPair, assetType string) (order return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Bitstamp exchange -func (b *Bitstamp) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Bitstamp) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = b.GetName() accountBalance, err := b.GetBalance() @@ -151,22 +150,22 @@ func (b *Bitstamp) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Bitstamp) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Bitstamp) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Bitstamp) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Bitstamp) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Bitstamp) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse buy := side == exchange.Buy market := orderType == exchange.Market @@ -183,49 +182,49 @@ func (b *Bitstamp) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderS return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Bitstamp) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Bitstamp) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Bitstamp) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Bitstamp) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Bitstamp) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Bitstamp) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Bitstamp) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Bitstamp) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Bitstamp) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Bitstamp) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bitstamp) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitstamp) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitstamp) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitstamp) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bitstamp) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bittrex/README.md b/exchanges/bittrex/README.md index 08a4b15a..f45372f8 100644 --- a/exchanges/bittrex/README.md +++ b/exchanges/bittrex/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index baf90d25..77c3304c 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -315,8 +315,8 @@ func (b *Bittrex) GetOpenOrders(currencyPair string) (Order, error) { return orders, nil } -// CancelOrder is used to cancel a buy or sell order. -func (b *Bittrex) CancelOrder(uuid string) (Balances, error) { +// CancelExistingOrder is used to cancel a buy or sell order. +func (b *Bittrex) CancelExistingOrder(uuid string) (Balances, error) { var balances Balances values := url.Values{} values.Set("uuid", uuid) @@ -365,10 +365,10 @@ func (b *Bittrex) GetAccountBalanceByCurrency(currency string) (Balance, error) return balance, nil } -// GetDepositAddress is used to retrieve or generate an address for a specific +// GetCryptoDepositAddress is used to retrieve or generate an address for a specific // currency. If one does not exist, the call will fail and return // ADDRESS_GENERATING until one is available. -func (b *Bittrex) GetDepositAddress(currency string) (DepositAddress, error) { +func (b *Bittrex) GetCryptoDepositAddress(currency string) (DepositAddress, error) { var address DepositAddress values := url.Values{} values.Set("currency", currency) diff --git a/exchanges/bittrex/bittrex_test.go b/exchanges/bittrex/bittrex_test.go index fdbe01db..db38610b 100644 --- a/exchanges/bittrex/bittrex_test.go +++ b/exchanges/bittrex/bittrex_test.go @@ -140,12 +140,12 @@ func TestGetOpenOrders(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - _, err := b.CancelOrder("blaaaaaaa") + _, err := b.CancelExistingOrder("blaaaaaaa") if err == nil { - t.Error("Test Failed - Bittrex - CancelOrder() error") + t.Error("Test Failed - Bittrex - CancelExistingOrder() error") } } @@ -349,7 +349,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.LTC, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/bittrex/bittrex_wrapper.go b/exchanges/bittrex/bittrex_wrapper.go index 0e887513..e9c4e9b6 100644 --- a/exchanges/bittrex/bittrex_wrapper.go +++ b/exchanges/bittrex/bittrex_wrapper.go @@ -60,9 +60,9 @@ func (b *Bittrex) Run() { } } -// GetExchangeAccountInfo Retrieves balances for all enabled currencies for the +// GetAccountInfo Retrieves balances for all enabled currencies for the // Bittrex exchange -func (b *Bittrex) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *Bittrex) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = b.GetName() accountBalance, err := b.GetAccountBalances() @@ -154,22 +154,22 @@ func (b *Bittrex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderb return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *Bittrex) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *Bittrex) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *Bittrex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *Bittrex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *Bittrex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse buy := side == exchange.Buy var response UUID @@ -196,54 +196,54 @@ func (b *Bittrex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSi return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *Bittrex) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *Bittrex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *Bittrex) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *Bittrex) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *Bittrex) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *Bittrex) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *Bittrex) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *Bittrex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *Bittrex) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *Bittrex) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *Bittrex) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bittrex) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *Bittrex) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bittrex) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *Bittrex) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *Bittrex) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (b *Bittrex) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/btcc/README.md b/exchanges/btcc/README.md index f275ba62..2f656801 100644 --- a/exchanges/btcc/README.md +++ b/exchanges/btcc/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/btcc/btcc_wrapper.go b/exchanges/btcc/btcc_wrapper.go index 05acf2f6..54d1d53c 100644 --- a/exchanges/btcc/btcc_wrapper.go +++ b/exchanges/btcc/btcc_wrapper.go @@ -125,20 +125,20 @@ func (b *BTCC) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook return orderbook.Base{}, errors.New("REST NOT SUPPORTED") } -// GetExchangeAccountInfo : Retrieves balances for all enabled currencies for +// GetAccountInfo : Retrieves balances for all enabled currencies for // the Kraken exchange - TODO -func (b *BTCC) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *BTCC) GetAccountInfo() (exchange.AccountInfo, error) { // var response exchange.AccountInfo // response.ExchangeName = b.GetName() // return response, nil return exchange.AccountInfo{}, errors.New("REST NOT SUPPORTED") } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *BTCC) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *BTCC) GetFundingHistory() ([]exchange.FundHistory, error) { // var fundHistory []exchange.FundHistory - // return fundHistory, errors.New("not supported on exchange") + // return fundHistory, common.ErrFunctionNotSupported return nil, errors.New("REST NOT SUPPORTED") } @@ -146,60 +146,60 @@ func (b *BTCC) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) func (b *BTCC) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { // var resp []exchange.TradeHistory - // return resp, errors.New("trade history not yet implemented") + // return resp, common.ErrNotYetImplemented return nil, errors.New("REST NOT SUPPORTED") } -// SubmitExchangeOrder submits a new order -func (b *BTCC) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *BTCC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse - return submitOrderResponse, errors.New("not yet implemented") + return submitOrderResponse, common.ErrNotYetImplemented } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *BTCC) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (b *BTCC) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *BTCC) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (b *BTCC) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *BTCC) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (b *BTCC) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (b *BTCC) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *BTCC) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *BTCC) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (b *BTCC) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (b *BTCC) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *BTCC) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCC) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *BTCC) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCC) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *BTCC) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/btcmarkets/README.md b/exchanges/btcmarkets/README.md index 43d1a83b..e37bdb1a 100644 --- a/exchanges/btcmarkets/README.md +++ b/exchanges/btcmarkets/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/btcmarkets/btcmarkets.go b/exchanges/btcmarkets/btcmarkets.go index 67a8d351..b5ca154a 100644 --- a/exchanges/btcmarkets/btcmarkets.go +++ b/exchanges/btcmarkets/btcmarkets.go @@ -206,9 +206,9 @@ func (b *BTCMarkets) NewOrder(currency, instrument string, price, amount float64 return int64(resp.ID), nil } -// CancelOrder cancels an order by its ID +// CancelExistingOrder cancels an order by its ID // orderID - id for order example "1337" -func (b *BTCMarkets) CancelOrder(orderID []int64) (bool, error) { +func (b *BTCMarkets) CancelExistingOrder(orderID []int64) (bool, error) { resp := Response{} type CancelOrder struct { OrderIDs []int64 `json:"orderIds"` diff --git a/exchanges/btcmarkets/btcmarkets_test.go b/exchanges/btcmarkets/btcmarkets_test.go index cec29052..be0c077b 100644 --- a/exchanges/btcmarkets/btcmarkets_test.go +++ b/exchanges/btcmarkets/btcmarkets_test.go @@ -87,11 +87,11 @@ func TestNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - _, err := b.CancelOrder([]int64{1337}) + _, err := b.CancelExistingOrder([]int64{1337}) if err == nil { - t.Error("Test failed - CancelOrder() error", err) + t.Error("Test failed - CancelExistingOrder() error", err) } } @@ -139,67 +139,59 @@ func TestWithdrawAUD(t *testing.T) { } } -func TestGetExchangeAccountInfo(t *testing.T) { - _, err := b.GetExchangeAccountInfo() +func TestGetAccountInfo(t *testing.T) { + _, err := b.GetAccountInfo() if err == nil { - t.Error("Test failed - GetExchangeAccountInfo() error", err) + t.Error("Test failed - GetAccountInfo() error", err) } } -func TestGetExchangeFundTransferHistory(t *testing.T) { - _, err := b.GetExchangeFundTransferHistory() +func TestGetFundingHistory(t *testing.T) { + _, err := b.GetFundingHistory() if err == nil { - t.Error("Test failed - GetExchangeAccountInfo() error", err) + t.Error("Test failed - GetAccountInfo() error", err) } } -func TestSubmitExchangeOrder(t *testing.T) { - p := pair.NewCurrencyPair("LTC", "AUD") - _, err := b.SubmitExchangeOrder(p, exchange.Sell, exchange.Market, 0, 0.0, "testID001") +func TestModifyOrder(t *testing.T) { + _, err := b.ModifyOrder(1337, exchange.ModifyOrder{}) if err == nil { - t.Error("Test failed - SubmitExchangeOrder() error", err) + t.Error("Test failed - ModifyOrder() error", err) } } -func TestModifyExchangeOrder(t *testing.T) { - _, err := b.ModifyExchangeOrder(1337, exchange.ModifyOrder{}) +func TestCancelOrder(t *testing.T) { + err := b.CancelOrder(1337) if err == nil { - t.Error("Test failed - ModifyExchangeOrder() error", err) + t.Error("Test failed - CancelgOrder() error", err) } } -func TestCancelExchangeOrder(t *testing.T) { - err := b.CancelExchangeOrder(1337) +func TestCancelAllOrders(t *testing.T) { + err := b.CancelAllOrders() if err == nil { - t.Error("Test failed - CancelExchangeOrder() error", err) + t.Error("Test failed - CancelAllOrders() error", err) } } -func TestCancelAllExchangeOrders(t *testing.T) { - err := b.CancelAllExchangeOrders() +func TestGetOrderInfo(t *testing.T) { + _, err := b.GetOrderInfo(1337) if err == nil { - t.Error("Test failed - CancelAllExchangeOrders() error", err) + t.Error("Test failed - GetOrderInfo() error", err) } } -func TestGetExchangeOrderInfo(t *testing.T) { - _, err := b.GetExchangeOrderInfo(1337) - if err == nil { - t.Error("Test failed - GetExchangeOrderInfo() error", err) - } -} - -func TestWithdrawCryptoExchangeFunds(t *testing.T) { - _, err := b.WithdrawCryptoExchangeFunds("someaddress", "ltc", 0) +func TestWithdrawCryptocurrencyFunds(t *testing.T) { + _, err := b.WithdrawCryptocurrencyFunds("someaddress", "ltc", 0) if err == nil { t.Error("Test failed - WithdrawExchangeFunds() error", err) } } -func TestWithdrawFiatExchangeFunds(t *testing.T) { - _, err := b.WithdrawFiatExchangeFunds("AUD", 0) +func TestWithdrawFiatFunds(t *testing.T) { + _, err := b.WithdrawFiatFunds("AUD", 0) if err == nil { - t.Error("Test failed - WithdrawFiatExchangeFunds() error", err) + t.Error("Test failed - WithdrawFiatFunds() error", err) } } @@ -326,7 +318,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.LTC, } - response, err := b.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId") + response, err := b.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/btcmarkets/btcmarkets_types.go b/exchanges/btcmarkets/btcmarkets_types.go index f54a0445..97fec971 100644 --- a/exchanges/btcmarkets/btcmarkets_types.go +++ b/exchanges/btcmarkets/btcmarkets_types.go @@ -53,7 +53,7 @@ type Trade struct { Date int64 `json:"date"` } -// 30 day trade volume +// TradingFee 30 day trade volume type TradingFee struct { Success bool `json:"success"` ErrorCode int `json:"errorCode"` diff --git a/exchanges/btcmarkets/btcmarkets_wrapper.go b/exchanges/btcmarkets/btcmarkets_wrapper.go index 878adf38..b95f4fab 100644 --- a/exchanges/btcmarkets/btcmarkets_wrapper.go +++ b/exchanges/btcmarkets/btcmarkets_wrapper.go @@ -117,9 +117,9 @@ func (b *BTCMarkets) UpdateOrderbook(p pair.CurrencyPair, assetType string) (ord return orderbook.GetOrderbook(b.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // BTCMarkets exchange -func (b *BTCMarkets) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (b *BTCMarkets) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = b.GetName() @@ -139,22 +139,22 @@ func (b *BTCMarkets) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (b *BTCMarkets) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (b *BTCMarkets) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (b *BTCMarkets) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (b *BTCMarkets) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (b *BTCMarkets) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := b.NewOrder(p.FirstCurrency.Upper().String(), p.SecondCurrency.Upper().String(), price, amount, side.ToString(), orderType.ToString(), clientID) @@ -169,23 +169,23 @@ func (b *BTCMarkets) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.Orde return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (b *BTCMarkets) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not supported on exchange") +func (b *BTCMarkets) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrFunctionNotSupported } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (b *BTCMarkets) CancelExchangeOrder(orderID int64) error { - _, err := b.CancelOrder([]int64{orderID}) +// CancelOrder cancels an order by its corresponding ID number +func (b *BTCMarkets) CancelOrder(orderID int64) error { + _, err := b.CancelExistingOrder([]int64{orderID}) if err != nil { return err } return nil } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (b *BTCMarkets) CancelAllExchangeOrders() error { +// CancelAllOrders cancels all orders associated with a currency pair +func (b *BTCMarkets) CancelAllOrders() error { orders, err := b.GetOrders("", "", 0, 0, true) if err != nil { return err @@ -196,15 +196,15 @@ func (b *BTCMarkets) CancelAllExchangeOrders() error { orderList = append(orderList, order.ID) } - _, err = b.CancelOrder(orderList) + _, err = b.CancelExistingOrder(orderList) if err != nil { return err } return nil } -// GetExchangeOrderInfo returns information on a current open order -func (b *BTCMarkets) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (b *BTCMarkets) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var OrderDetail exchange.OrderDetail orders, err := b.GetOrderDetail([]int64{orderID}) @@ -237,19 +237,19 @@ func (b *BTCMarkets) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, return OrderDetail, nil } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (b *BTCMarkets) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not supported on exchange") +// GetDepositAddress returns a deposit address for a specified currency +func (b *BTCMarkets) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrFunctionNotSupported } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted -func (b *BTCMarkets) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted +func (b *BTCMarkets) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { return b.WithdrawCrypto(amount, cryptocurrency.String(), address) } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCMarkets) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { +func (b *BTCMarkets) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { bd, err := b.GetClientBankAccounts(b.Name, currency.Upper().String()) if err != nil { return "", err @@ -257,15 +257,15 @@ func (b *BTCMarkets) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amoun return b.WithdrawAUD(bd.AccountName, bd.AccountNumber, bd.BankName, bd.BSBNumber, amount) } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (b *BTCMarkets) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (b *BTCMarkets) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/coinbasepro/README.md b/exchanges/coinbasepro/README.md index c90291bb..6fee72f4 100644 --- a/exchanges/coinbasepro/README.md +++ b/exchanges/coinbasepro/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := c.GetExchangeAccountInfo() +accountInfo, err := c.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/coinbasepro/coinbasepro.go b/exchanges/coinbasepro/coinbasepro.go index 541405a2..dc772424 100644 --- a/exchanges/coinbasepro/coinbasepro.go +++ b/exchanges/coinbasepro/coinbasepro.go @@ -484,18 +484,18 @@ func (c *CoinbasePro) PlaceMarginOrder(clientRef string, size, funds float64, si return resp.ID, nil } -// CancelOrder cancels order by orderID -func (c *CoinbasePro) CancelOrder(orderID string) error { +// CancelExistingOrder cancels order by orderID +func (c *CoinbasePro) CancelExistingOrder(orderID string) error { path := fmt.Sprintf("%s/%s", coinbaseproOrders, orderID) return c.SendAuthenticatedHTTPRequest("DELETE", path, nil, nil) } -// CancelAllOrders cancels all open orders on the exchange and returns and array -// of order IDs +// CancelAllExistingOrders cancels all open orders on the exchange and returns +// and array of order IDs // currencyPair - [optional] all orders for a currencyPair string will be // canceled -func (c *CoinbasePro) CancelAllOrders(currencyPair string) ([]string, error) { +func (c *CoinbasePro) CancelAllExistingOrders(currencyPair string) ([]string, error) { var resp []string request := make(map[string]interface{}) diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index 2e2ececd..c80843ad 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -122,14 +122,14 @@ func TestAuthRequests(t *testing.T) { t.Error("Test failed - PlaceMarketOrder() error", err) } - err = c.CancelOrder("1337") + err = c.CancelExistingOrder("1337") if err == nil { - t.Error("Test failed - CancelOrder() error", err) + t.Error("Test failed - CancelExistingOrder() error", err) } - _, err = c.CancelAllOrders("BTC-USD") + _, err = c.CancelAllExistingOrders("BTC-USD") if err == nil { - t.Error("Test failed - CancelAllOrders() error", err) + t.Error("Test failed - CancelAllExistingOrders() error", err) } _, err = c.GetOrders([]string{"open", "done"}, "BTC-USD") @@ -424,7 +424,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.LTC, } - response, err := c.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId") + response, err := c.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index 12301970..cb2d5ac1 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -46,9 +46,9 @@ func (c *CoinbasePro) Run() { } } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // coinbasepro exchange -func (c *CoinbasePro) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (c *CoinbasePro) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = c.GetName() accountBalance, err := c.GetAccounts() @@ -129,22 +129,22 @@ func (c *CoinbasePro) UpdateOrderbook(p pair.CurrencyPair, assetType string) (or return orderbook.GetOrderbook(c.Name, p, assetType) } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (c *CoinbasePro) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (c *CoinbasePro) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (c *CoinbasePro) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (c *CoinbasePro) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (c *CoinbasePro) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var response string var err error @@ -168,43 +168,43 @@ func (c *CoinbasePro) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.Ord return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (c *CoinbasePro) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (c *CoinbasePro) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (c *CoinbasePro) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (c *CoinbasePro) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (c *CoinbasePro) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (c *CoinbasePro) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (c *CoinbasePro) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (c *CoinbasePro) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (c *CoinbasePro) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (c *CoinbasePro) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (c *CoinbasePro) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (c *CoinbasePro) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func (c *CoinbasePro) WithdrawFiatExchangeFunds(cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (c *CoinbasePro) WithdrawFiatFunds(cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/coinut/README.md b/exchanges/coinut/README.md index cecb5540..e2ca3629 100644 --- a/exchanges/coinut/README.md +++ b/exchanges/coinut/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := c.GetExchangeAccountInfo() +accountInfo, err := c.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/coinut/coinut.go b/exchanges/coinut/coinut.go index f7be236d..6f1af74c 100644 --- a/exchanges/coinut/coinut.go +++ b/exchanges/coinut/coinut.go @@ -212,8 +212,8 @@ func (c *COINUT) GetOpenOrders(instrumentID int) ([]OrdersResponse, error) { return result, c.SendHTTPRequest(coinutOrdersOpen, params, true, &result) } -// CancelOrder cancels a specific order and returns if it was actioned -func (c *COINUT) CancelOrder(instrumentID, orderID int) (bool, error) { +// CancelExistingOrder cancels a specific order and returns if it was actioned +func (c *COINUT) CancelExistingOrder(instrumentID, orderID int) (bool, error) { var result GenericResponse params := make(map[string]interface{}) params["inst_id"] = instrumentID diff --git a/exchanges/coinut/coinut_test.go b/exchanges/coinut/coinut_test.go index efd4136d..7a5038fe 100644 --- a/exchanges/coinut/coinut_test.go +++ b/exchanges/coinut/coinut_test.go @@ -210,7 +210,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USD, } - response, err := c.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 10, "1234234") + response, err := c.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 10, "1234234") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/coinut/coinut_wrapper.go b/exchanges/coinut/coinut_wrapper.go index f931e5fe..2391710a 100644 --- a/exchanges/coinut/coinut_wrapper.go +++ b/exchanges/coinut/coinut_wrapper.go @@ -50,9 +50,9 @@ func (c *COINUT) Run() { } } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // COINUT exchange -func (c *COINUT) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (c *COINUT) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo /* response.ExchangeName = e.GetName() @@ -128,22 +128,23 @@ func (c *COINUT) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbo return orderbook.GetOrderbook(c.Name, p, assetType) } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (c *COINUT) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (c *COINUT) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (c *COINUT) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (c *COINUT) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (c *COINUT) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var err error var APIresponse interface{} @@ -191,49 +192,49 @@ func (c *COINUT) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (c *COINUT) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (c *COINUT) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (c *COINUT) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (c *COINUT) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (c *COINUT) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (c *COINUT) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (c *COINUT) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (c *COINUT) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (c *COINUT) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (c *COINUT) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (c *COINUT) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (c *COINUT) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (c *COINUT) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (c *COINUT) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (c *COINUT) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (c *COINUT) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/exchange.go b/exchanges/exchange.go index be026d91..4765350b 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -23,8 +23,8 @@ const ( warningBase64DecryptSecretKeyFailed = "WARNING -- Exchange %s unable to base64 decode secret key.. Disabling Authenticated API support." // WarningAuthenticatedRequestWithoutCredentialsSet error message for authenticated request without credentials set WarningAuthenticatedRequestWithoutCredentialsSet = "WARNING -- Exchange %s authenticated HTTP request called but not supported due to unset/default API keys." - // ErrExchangeNotFound is a constant for an error message - ErrExchangeNotFound = "Exchange not found in dataset." + // ErrExchangeNotFound is a stand for an error message + ErrExchangeNotFound = "Exchange not found in dataset" // DefaultHTTPTimeout is the default HTTP/HTTPS Timeout for exchange requests DefaultHTTPTimeout = time.Second * 15 ) @@ -70,7 +70,7 @@ const ( // SubmitOrderResponse is what is returned after submitting an order to an exchange type SubmitOrderResponse struct { IsOrderPlaced bool - OrderID string + OrderID string } // FeeBuilder is the type which holds all parameters required to calculate a fee for an exchange @@ -239,7 +239,7 @@ type IBotExchange interface { GetEnabledCurrencies() []pair.CurrencyPair GetAvailableCurrencies() []pair.CurrencyPair GetAssetTypes() []string - GetExchangeAccountInfo() (AccountInfo, error) + GetAccountInfo() (AccountInfo, error) GetAuthenticatedAPISupport() bool SetCurrencies(pairs []pair.CurrencyPair, enabledPairs bool) error GetExchangeHistory(pair.CurrencyPair, string) ([]TradeHistory, error) @@ -251,16 +251,16 @@ type IBotExchange interface { FormatWithdrawPermissions() string SupportsWithdrawPermissions(permissions uint32) bool - GetExchangeFundTransferHistory() ([]FundHistory, error) - SubmitExchangeOrder(p pair.CurrencyPair, side OrderSide, orderType OrderType, amount, price float64, clientID string) (SubmitOrderResponse, error) - ModifyExchangeOrder(orderID int64, modify ModifyOrder) (int64, error) - CancelExchangeOrder(orderID int64) error - CancelAllExchangeOrders() error - GetExchangeOrderInfo(orderID int64) (OrderDetail, error) - GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) + GetFundingHistory() ([]FundHistory, error) + SubmitOrder(p pair.CurrencyPair, side OrderSide, orderType OrderType, amount, price float64, clientID string) (SubmitOrderResponse, error) + ModifyOrder(orderID int64, modify ModifyOrder) (int64, error) + CancelOrder(orderID int64) error + CancelAllOrders() error + GetOrderInfo(orderID int64) (OrderDetail, error) + GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) - WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) - WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) + WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) + WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) GetWebsocket() (*Websocket, error) } diff --git a/exchanges/exmo/README.md b/exchanges/exmo/README.md index 1393fddb..c8fcff02 100644 --- a/exchanges/exmo/README.md +++ b/exchanges/exmo/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := e.GetExchangeAccountInfo() +accountInfo, err := e.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/exmo/exmo.go b/exchanges/exmo/exmo.go index e1f830ac..a93562e3 100644 --- a/exchanges/exmo/exmo.go +++ b/exchanges/exmo/exmo.go @@ -185,8 +185,8 @@ func (e *EXMO) CreateOrder(pair, orderType string, price, amount float64) (int64 return result.OrderID, err } -// CancelOrder cancels an order by the orderID -func (e *EXMO) CancelOrder(orderID int64) error { +// CancelExistingOrder cancels an order by the orderID +func (e *EXMO) CancelExistingOrder(orderID int64) error { v := url.Values{} v.Set("order_id", strconv.FormatInt(orderID, 10)) var result interface{} @@ -256,8 +256,8 @@ func (e *EXMO) GetRequiredAmount(pair string, amount float64) (RequiredAmount, e return result, err } -// GetDepositAddress returns a list of addresses for cryptocurrency deposits -func (e *EXMO) GetDepositAddress() (map[string]string, error) { +// GetCryptoDepositAddress returns a list of addresses for cryptocurrency deposits +func (e *EXMO) GetCryptoDepositAddress() (map[string]string, error) { result := make(map[string]string) err := e.SendAuthenticatedHTTPRequest("POST", exmoDepositAddress, url.Values{}, &result) log.Println(reflect.TypeOf(result).String()) diff --git a/exchanges/exmo/exmo_test.go b/exchanges/exmo/exmo_test.go index cca7dd5a..7383f2d7 100644 --- a/exchanges/exmo/exmo_test.go +++ b/exchanges/exmo/exmo_test.go @@ -93,13 +93,13 @@ func TestGetRequiredAmount(t *testing.T) { } } -func TestGetDepositAddress(t *testing.T) { +func TestGetCryptoDepositAddress(t *testing.T) { t.Parallel() if APIKey == "" || APISecret == "" { t.Skip() } TestSetup(t) - _, err := e.GetDepositAddress() + _, err := e.GetCryptoDepositAddress() if err == nil { t.Errorf("Test failed. Err: %s", err) } @@ -266,7 +266,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USD, } - response, err := e.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") + response, err := e.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/exmo/exmo_wrapper.go b/exchanges/exmo/exmo_wrapper.go index 3c078976..550aec1f 100644 --- a/exchanges/exmo/exmo_wrapper.go +++ b/exchanges/exmo/exmo_wrapper.go @@ -136,9 +136,9 @@ func (e *EXMO) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook return orderbook.GetOrderbook(e.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Exmo exchange -func (e *EXMO) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (e *EXMO) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = e.GetName() result, err := e.GetUserInfo() @@ -162,22 +162,22 @@ func (e *EXMO) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (e *EXMO) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (e *EXMO) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (e *EXMO) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (e *EXMO) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (e *EXMO) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var oT string if orderType == exchange.Limit { @@ -205,54 +205,54 @@ func (e *EXMO) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (e *EXMO) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (e *EXMO) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (e *EXMO) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (e *EXMO) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (e *EXMO) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (e *EXMO) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (e *EXMO) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (e *EXMO) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (e *EXMO) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (e *EXMO) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (e *EXMO) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (e *EXMO) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (e *EXMO) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (e *EXMO) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (e *EXMO) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (e *EXMO) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (e *EXMO) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/gateio/README.md b/exchanges/gateio/README.md index 9133e3aa..48e56af8 100644 --- a/exchanges/gateio/README.md +++ b/exchanges/gateio/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := g.GetExchangeAccountInfo() +accountInfo, err := g.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 97acbb2d..be12d531 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -354,10 +354,10 @@ func (g *Gateio) SpotNewOrder(arg SpotNewOrderRequestParams) (SpotNewOrderRespon return result, nil } -// CancelOrder cancels an order given the supplied orderID and symbol +// CancelExistingOrder cancels an order given the supplied orderID and symbol // orderID order ID number // symbol trade pair (ltc_btc) -func (g *Gateio) CancelOrder(orderID int64, symbol string) (bool, error) { +func (g *Gateio) CancelExistingOrder(orderID int64, symbol string) (bool, error) { type response struct { Result bool `json:"result"` Code int `json:"code"` diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index fff3e94a..357eb523 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -73,16 +73,16 @@ func TestSpotNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() if apiKey == "" || apiSecret == "" { t.Skip() } - _, err := g.CancelOrder(917591554, "btc_usdt") + _, err := g.CancelExistingOrder(917591554, "btc_usdt") if err != nil { - t.Errorf("Test failed - Gateio CancelOrder: %s", err) + t.Errorf("Test failed - Gateio CancelExistingOrder: %s", err) } } @@ -268,7 +268,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.LTC, SecondCurrency: symbol.BTC, } - response, err := g.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") + response, err := g.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index cdb88ed0..a30f72c8 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -106,29 +106,29 @@ func (g *Gateio) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbo return orderbook.GetOrderbook(g.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // ZB exchange -func (g *Gateio) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (g *Gateio) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo return response, errors.New("not implemented") } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (g *Gateio) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (g *Gateio) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (g *Gateio) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (g *Gateio) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (g *Gateio) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var orderTypeFormat SpotNewOrderRequestParamsType @@ -158,54 +158,54 @@ func (g *Gateio) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (g *Gateio) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (g *Gateio) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (g *Gateio) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (g *Gateio) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (g *Gateio) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (g *Gateio) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (g *Gateio) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (g *Gateio) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (g *Gateio) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (g *Gateio) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (g *Gateio) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (g *Gateio) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (g *Gateio) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (g *Gateio) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (g *Gateio) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (g *Gateio) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (g *Gateio) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/gemini/README.md b/exchanges/gemini/README.md index dad27ba5..675e46fa 100644 --- a/exchanges/gemini/README.md +++ b/exchanges/gemini/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := g.GetExchangeAccountInfo() +accountInfo, err := g.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index dd7b26ed..99d98695 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -300,9 +300,9 @@ func (g *Gemini) NewOrder(symbol string, amount, price float64, side, orderType return response.OrderID, nil } -// CancelOrder will cancel an order. If the order is already canceled, the +// CancelExistingOrder will cancel an order. If the order is already canceled, the // message will succeed but have no effect. -func (g *Gemini) CancelOrder(OrderID int64) (Order, error) { +func (g *Gemini) CancelExistingOrder(OrderID int64) (Order, error) { request := make(map[string]interface{}) request["order_id"] = OrderID @@ -318,11 +318,11 @@ func (g *Gemini) CancelOrder(OrderID int64) (Order, error) { return response, nil } -// CancelOrders will cancel all outstanding orders created by all sessions owned -// by this account, including interactive orders placed through the UI. If -// sessions = true will only cancel the order that is called on this session -// asssociated with the APIKEY -func (g *Gemini) CancelOrders(CancelBySession bool) (OrderResult, error) { +// CancelExistingOrders will cancel all outstanding orders created by all +// sessions owned by this account, including interactive orders placed through +// the UI. If sessions = true will only cancel the order that is called on this +// session asssociated with the APIKEY +func (g *Gemini) CancelExistingOrders(CancelBySession bool) (OrderResult, error) { response := OrderResult{} path := geminiOrderCancelAll if CancelBySession { @@ -415,8 +415,8 @@ func (g *Gemini) GetBalances() ([]Balance, error) { g.SendAuthenticatedHTTPRequest("POST", geminiBalances, nil, &response) } -// GetDepositAddress returns a deposit address -func (g *Gemini) GetDepositAddress(depositAddlabel, currency string) (DepositAddress, error) { +// GetCryptoDepositAddress returns a deposit address +func (g *Gemini) GetCryptoDepositAddress(depositAddlabel, currency string) (DepositAddress, error) { response := DepositAddress{} err := g.SendAuthenticatedHTTPRequest("POST", geminiDeposit+"/"+currency+"/"+geminiNewAddress, nil, &response) diff --git a/exchanges/gemini/gemini_test.go b/exchanges/gemini/gemini_test.go index fab53488..a0f60dfa 100644 --- a/exchanges/gemini/gemini_test.go +++ b/exchanges/gemini/gemini_test.go @@ -138,23 +138,23 @@ func TestNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - _, err := Session[1].CancelOrder(1337) + _, err := Session[1].CancelExistingOrder(1337) if err == nil { - t.Error("Test Failed - CancelOrder() error", err) + t.Error("Test Failed - CancelExistingOrder() error", err) } } -func TestCancelOrders(t *testing.T) { +func TestCancelExistingOrders(t *testing.T) { t.Parallel() - _, err := Session[1].CancelOrders(false) + _, err := Session[1].CancelExistingOrders(false) if err == nil { - t.Error("Test Failed - CancelOrders() error", err) + t.Error("Test Failed - CancelExistingOrders() error", err) } - _, err = Session[2].CancelOrders(true) + _, err = Session[2].CancelExistingOrders(true) if err == nil { - t.Error("Test Failed - CancelOrders() error", err) + t.Error("Test Failed - CancelExistingOrders() error", err) } } @@ -198,11 +198,11 @@ func TestGetBalances(t *testing.T) { } } -func TestGetDepositAddress(t *testing.T) { +func TestGetCryptoDepositAddress(t *testing.T) { t.Parallel() - _, err := Session[1].GetDepositAddress("LOL123", "btc") + _, err := Session[1].GetCryptoDepositAddress("LOL123", "btc") if err == nil { - t.Error("Test Failed - GetDepositAddress() error", err) + t.Error("Test Failed - GetCryptoDepositAddress() error", err) } } @@ -342,7 +342,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.LTC, SecondCurrency: symbol.BTC, } - response, err := Session[1].SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") + response, err := Session[1].SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/gemini/gemini_wrapper.go b/exchanges/gemini/gemini_wrapper.go index 47f3ac7a..adef578e 100644 --- a/exchanges/gemini/gemini_wrapper.go +++ b/exchanges/gemini/gemini_wrapper.go @@ -1,12 +1,12 @@ package gemini import ( - "errors" "fmt" "log" "net/url" "sync" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" @@ -40,9 +40,9 @@ func (g *Gemini) Run() { } } -// GetExchangeAccountInfo Retrieves balances for all enabled currencies for the +// GetAccountInfo Retrieves balances for all enabled currencies for the // Gemini exchange -func (g *Gemini) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (g *Gemini) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = g.GetName() accountBalance, err := g.GetBalances() @@ -113,22 +113,22 @@ func (g *Gemini) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbo return orderbook.GetOrderbook(g.Name, p, assetType) } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (g *Gemini) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (g *Gemini) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (g *Gemini) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (g *Gemini) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (g *Gemini) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := g.NewOrder(p.Pair().String(), amount, price, side.ToString(), orderType.ToString()) @@ -143,54 +143,54 @@ func (g *Gemini) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (g *Gemini) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (g *Gemini) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (g *Gemini) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (g *Gemini) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (g *Gemini) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (g *Gemini) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (g *Gemini) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (g *Gemini) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (g *Gemini) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (g *Gemini) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (g *Gemini) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (g *Gemini) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (g *Gemini) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (g *Gemini) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (g *Gemini) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (g *Gemini) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (g *Gemini) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/hitbtc/README.md b/exchanges/hitbtc/README.md index a57f6b73..4f13c320 100644 --- a/exchanges/hitbtc/README.md +++ b/exchanges/hitbtc/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := h.GetExchangeAccountInfo() +accountInfo, err := h.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/hitbtc/hitbtc.go b/exchanges/hitbtc/hitbtc.go index 9f3f496d..e8bfae4d 100644 --- a/exchanges/hitbtc/hitbtc.go +++ b/exchanges/hitbtc/hitbtc.go @@ -432,8 +432,8 @@ func (h *HitBTC) PlaceOrder(currency string, rate, amount float64, orderType, si return result, nil } -// CancelOrder cancels a specific order by OrderID -func (h *HitBTC) CancelOrder(orderID int64) (bool, error) { +// CancelExistingOrder cancels a specific order by OrderID +func (h *HitBTC) CancelExistingOrder(orderID int64) (bool, error) { result := GenericResponse{} values := url.Values{} values.Set("orderNumber", strconv.FormatInt(orderID, 10)) diff --git a/exchanges/hitbtc/hitbtc_test.go b/exchanges/hitbtc/hitbtc_test.go index 31d35a4c..3f470181 100644 --- a/exchanges/hitbtc/hitbtc_test.go +++ b/exchanges/hitbtc/hitbtc_test.go @@ -193,7 +193,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.DGD, SecondCurrency: symbol.BTC, } - response, err := h.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") + response, err := h.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "1234234") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/hitbtc/hitbtc_wrapper.go b/exchanges/hitbtc/hitbtc_wrapper.go index 79ccbb4e..0a2272d1 100644 --- a/exchanges/hitbtc/hitbtc_wrapper.go +++ b/exchanges/hitbtc/hitbtc_wrapper.go @@ -1,7 +1,6 @@ package hitbtc import ( - "errors" "fmt" "log" "sync" @@ -121,9 +120,9 @@ func (h *HitBTC) UpdateOrderbook(currencyPair pair.CurrencyPair, assetType strin return orderbook.GetOrderbook(h.Name, currencyPair, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // HitBTC exchange -func (h *HitBTC) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (h *HitBTC) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = h.GetName() accountBalance, err := h.GetBalances() @@ -141,22 +140,22 @@ func (h *HitBTC) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (h *HitBTC) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (h *HitBTC) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (h *HitBTC) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (h *HitBTC) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (h *HitBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := h.PlaceOrder(p.Pair().String(), price, amount, common.StringToLower(orderType.ToString()), common.StringToLower(side.ToString())) @@ -171,49 +170,49 @@ func (h *HitBTC) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (h *HitBTC) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (h *HitBTC) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (h *HitBTC) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (h *HitBTC) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (h *HitBTC) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (h *HitBTC) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (h *HitBTC) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (h *HitBTC) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (h *HitBTC) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (h *HitBTC) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (h *HitBTC) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HitBTC) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (h *HitBTC) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HitBTC) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (h *HitBTC) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HitBTC) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/huobi/README.md b/exchanges/huobi/README.md index 4b969340..3b474ef0 100644 --- a/exchanges/huobi/README.md +++ b/exchanges/huobi/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := h.GetExchangeAccountInfo() +accountInfo, err := h.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index 699ea6e7..feb2ab5f 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -414,8 +414,8 @@ func (h *HUOBI) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) { return result.OrderID, err } -// CancelOrder cancels an order on Huobi -func (h *HUOBI) CancelOrder(orderID int64) (int64, error) { +// CancelExistingOrder cancels an order on Huobi +func (h *HUOBI) CancelExistingOrder(orderID int64) (int64, error) { type response struct { Response OrderID int64 `json:"data,string"` diff --git a/exchanges/huobi/huobi_test.go b/exchanges/huobi/huobi_test.go index 18219937..e2ac2ed2 100644 --- a/exchanges/huobi/huobi_test.go +++ b/exchanges/huobi/huobi_test.go @@ -216,12 +216,12 @@ func TestSpotNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - _, err := h.CancelOrder(1337) + _, err := h.CancelExistingOrder(1337) if err == nil { - t.Error("Test failed - Huobi TestCancelOrder: Invalid orderID returned true") + t.Error("Test failed - Huobi TestCancelExistingOrder: Invalid orderID returned true") } } @@ -416,7 +416,7 @@ func TestSubmitOrder(t *testing.T) { } accounts, err := h.GetAccounts() - response, err := h.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 10, strconv.FormatInt(accounts[0].ID, 10)) + response, err := h.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 10, strconv.FormatInt(accounts[0].ID, 10)) if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/huobi/huobi_wrapper.go b/exchanges/huobi/huobi_wrapper.go index 0935faf4..5c80fb83 100644 --- a/exchanges/huobi/huobi_wrapper.go +++ b/exchanges/huobi/huobi_wrapper.go @@ -149,30 +149,30 @@ func (h *HUOBI) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo return orderbook.GetOrderbook(h.Name, p, assetType) } -//GetExchangeAccountInfo retrieves balances for all enabled currencies for the +//GetAccountInfo retrieves balances for all enabled currencies for the // HUOBI exchange - to-do -func (h *HUOBI) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (h *HUOBI) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = h.GetName() return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (h *HUOBI) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (h *HUOBI) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (h *HUOBI) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (h *HUOBI) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (h *HUOBI) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse accountID, err := strconv.ParseInt(clientID, 10, 64) var formattedType SpotNewOrderRequestParamsType @@ -212,49 +212,49 @@ func (h *HUOBI) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (h *HUOBI) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (h *HUOBI) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (h *HUOBI) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (h *HUOBI) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (h *HUOBI) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (h *HUOBI) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (h *HUOBI) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (h *HUOBI) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (h *HUOBI) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (h *HUOBI) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (h *HUOBI) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HUOBI) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBI) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HUOBI) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBI) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HUOBI) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/huobihadax/README.md b/exchanges/huobihadax/README.md index dd791bcf..40c5389f 100644 --- a/exchanges/huobihadax/README.md +++ b/exchanges/huobihadax/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := h.GetExchangeAccountInfo() +accountInfo, err := h.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/huobihadax/huobihadax.go b/exchanges/huobihadax/huobihadax.go index 7ff535af..ab4d788f 100644 --- a/exchanges/huobihadax/huobihadax.go +++ b/exchanges/huobihadax/huobihadax.go @@ -399,8 +399,8 @@ func (h *HUOBIHADAX) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) return result.OrderID, err } -// CancelOrder cancels an order on Huobi -func (h *HUOBIHADAX) CancelOrder(orderID int64) (int64, error) { +// CancelExistingOrder cancels an order on Huobi +func (h *HUOBIHADAX) CancelExistingOrder(orderID int64) (int64, error) { type response struct { Response OrderID int64 `json:"data,string"` diff --git a/exchanges/huobihadax/huobihadax_test.go b/exchanges/huobihadax/huobihadax_test.go index 07b4e593..e60afc8e 100644 --- a/exchanges/huobihadax/huobihadax_test.go +++ b/exchanges/huobihadax/huobihadax_test.go @@ -208,16 +208,16 @@ func TestSpotNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() if h.APIKey == "" || h.APISecret == "" || h.APIAuthPEMKey == "" { t.Skip() } - _, err := h.CancelOrder(1337) + _, err := h.CancelExistingOrder(1337) if err == nil { - t.Error("Test failed - Huobi TestCancelOrder: Invalid orderID returned true") + t.Error("Test failed - Huobi TestCancelExistingOrder: Invalid orderID returned true") } } @@ -394,7 +394,7 @@ func TestSubmitOrder(t *testing.T) { } accounts, err := h.GetAccounts() - response, err := h.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 10, strconv.FormatInt(accounts[0].ID, 10)) + response, err := h.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 10, strconv.FormatInt(accounts[0].ID, 10)) if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/huobihadax/huobihadax_wrapper.go b/exchanges/huobihadax/huobihadax_wrapper.go index 76626880..c7b95b58 100644 --- a/exchanges/huobihadax/huobihadax_wrapper.go +++ b/exchanges/huobihadax/huobihadax_wrapper.go @@ -114,30 +114,30 @@ func (h *HUOBIHADAX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (ord return orderbook.GetOrderbook(h.Name, p, assetType) } -//GetExchangeAccountInfo retrieves balances for all enabled currencies for the +//GetAccountInfo retrieves balances for all enabled currencies for the // HUOBIHADAX exchange - to-do -func (h *HUOBIHADAX) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (h *HUOBIHADAX) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = h.GetName() return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (h *HUOBIHADAX) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (h *HUOBIHADAX) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (h *HUOBIHADAX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (h *HUOBIHADAX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (h *HUOBIHADAX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse accountID, err := strconv.ParseInt(clientID, 0, 64) var formattedType SpotNewOrderRequestParamsType @@ -177,54 +177,54 @@ func (h *HUOBIHADAX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.Orde return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (h *HUOBIHADAX) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (h *HUOBIHADAX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (h *HUOBIHADAX) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (h *HUOBIHADAX) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (h *HUOBIHADAX) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (h *HUOBIHADAX) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (h *HUOBIHADAX) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (h *HUOBIHADAX) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (h *HUOBIHADAX) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (h *HUOBIHADAX) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (h *HUOBIHADAX) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HUOBIHADAX) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBIHADAX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HUOBIHADAX) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (h *HUOBIHADAX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (h *HUOBIHADAX) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (h *HUOBIHADAX) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/itbit/README.md b/exchanges/itbit/README.md index ae36c796..e8831734 100644 --- a/exchanges/itbit/README.md +++ b/exchanges/itbit/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := i.GetExchangeAccountInfo() +accountInfo, err := i.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/itbit/itbit.go b/exchanges/itbit/itbit.go index f71bbf6e..16b69653 100644 --- a/exchanges/itbit/itbit.go +++ b/exchanges/itbit/itbit.go @@ -210,8 +210,8 @@ func (i *ItBit) GetWalletTrades(walletID string, params url.Values) (Records, er return resp, nil } -// GetFundingHistory returns all funding history for a specified wallet. -func (i *ItBit) GetFundingHistory(walletID string, params url.Values) (FundingRecords, error) { +// GetFundingHistoryForWallet returns all funding history for a specified wallet. +func (i *ItBit) GetFundingHistoryForWallet(walletID string, params url.Values) (FundingRecords, error) { resp := FundingRecords{} url := fmt.Sprintf("/%s/%s/%s", itbitWallets, walletID, itbitFundingHistory) path := common.EncodeURLValues(url, params) @@ -269,16 +269,16 @@ func (i *ItBit) GetOrder(walletID string, params url.Values) (Order, error) { return resp, nil } -// CancelOrder cancels and open order. *This is not a guarantee that the order -// has been cancelled!* -func (i *ItBit) CancelOrder(walletID, orderID string) error { +// CancelExistingOrder cancels and open order. *This is not a guarantee that the +// order has been cancelled!* +func (i *ItBit) CancelExistingOrder(walletID, orderID string) error { path := fmt.Sprintf("/%s/%s/%s/%s", itbitWallets, walletID, itbitOrders, orderID) return i.SendAuthenticatedHTTPRequest("DELETE", path, nil, nil) } -// GetDepositAddress returns a deposit address to send cryptocurrency to. -func (i *ItBit) GetDepositAddress(walletID, currency string) (CryptoCurrencyDeposit, error) { +// GetCryptoDepositAddress returns a deposit address to send cryptocurrency to. +func (i *ItBit) GetCryptoDepositAddress(walletID, currency string) (CryptoCurrencyDeposit, error) { resp := CryptoCurrencyDeposit{} path := fmt.Sprintf("/%s/%s/%s", itbitWallets, walletID, itbitCryptoDeposits) params := make(map[string]interface{}) diff --git a/exchanges/itbit/itbit_test.go b/exchanges/itbit/itbit_test.go index 31039aba..954468ba 100644 --- a/exchanges/itbit/itbit_test.go +++ b/exchanges/itbit/itbit_test.go @@ -101,7 +101,7 @@ func TestGetWalletTrades(t *testing.T) { } func TestGetFundingHistory(t *testing.T) { - _, err := i.GetFundingHistory("1337", url.Values{}) + _, err := i.GetFundingHistoryForWallet("1337", url.Values{}) if err == nil { t.Error("Test Failed - GetFundingHistory() error", err) } @@ -121,18 +121,18 @@ func TestGetOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Skip() - err := i.CancelOrder("1337", "1337order") + err := i.CancelExistingOrder("1337", "1337order") if err == nil { t.Error("Test Failed - CancelOrder() error", err) } } -func TestGetDepositAddress(t *testing.T) { - _, err := i.GetDepositAddress("1337", "AUD") +func TestGetCryptoDepositAddress(t *testing.T) { + _, err := i.GetCryptoDepositAddress("1337", "AUD") if err == nil { - t.Error("Test Failed - GetDepositAddress() error", err) + t.Error("Test Failed - GetCryptoDepositAddress() error", err) } } @@ -262,7 +262,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USDT, } - response, err := i.SubmitExchangeOrder(p, exchange.Buy, exchange.Limit, 1, 10, "hi") + response, err := i.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/itbit/itbit_wrapper.go b/exchanges/itbit/itbit_wrapper.go index ab06e7a1..2a52a3e2 100644 --- a/exchanges/itbit/itbit_wrapper.go +++ b/exchanges/itbit/itbit_wrapper.go @@ -1,12 +1,12 @@ package itbit import ( - "errors" "fmt" "log" "strconv" "sync" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" @@ -107,30 +107,30 @@ func (i *ItBit) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo return orderbook.GetOrderbook(i.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the //ItBit exchange - to-do -func (i *ItBit) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (i *ItBit) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = i.GetName() return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (i *ItBit) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (i *ItBit) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (i *ItBit) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (i *ItBit) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (i *ItBit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var wallet string @@ -165,54 +165,54 @@ func (i *ItBit) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (i *ItBit) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (i *ItBit) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (i *ItBit) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (i *ItBit) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (i *ItBit) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (i *ItBit) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (i *ItBit) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (i *ItBit) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (i *ItBit) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (i *ItBit) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (i *ItBit) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (i *ItBit) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (i *ItBit) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (i *ItBit) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (i *ItBit) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (i *ItBit) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (i *ItBit) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/kraken/README.md b/exchanges/kraken/README.md index f80a33a4..fc9b0984 100644 --- a/exchanges/kraken/README.md +++ b/exchanges/kraken/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := k.GetExchangeAccountInfo() +accountInfo, err := k.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index f220a5bf..4a8389f2 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -845,8 +845,8 @@ func (k *Kraken) AddOrder(symbol, side, orderType string, volume, price, price2, return response.Result, GetError(response.Error) } -// CancelOrder cancels order by orderID -func (k *Kraken) CancelOrder(txid string) (CancelOrderResponse, error) { +// CancelExistingOrder cancels order by orderID +func (k *Kraken) CancelExistingOrder(txid string) (CancelOrderResponse, error) { values := url.Values{ "txid": {txid}, } diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index 18736fad..4ce9c061 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -215,11 +215,11 @@ func TestAddOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - _, err := k.CancelOrder("OAVY7T-MV5VK-KHDF5X") + _, err := k.CancelExistingOrder("OAVY7T-MV5VK-KHDF5X") if err == nil { - t.Error("Test Failed - CancelOrder() error", err) + t.Error("Test Failed - CancelExistingOrder() error", err) } } @@ -348,7 +348,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.XBT, SecondCurrency: symbol.CAD, } - response, err := k.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := k.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/kraken/kraken_wrapper.go b/exchanges/kraken/kraken_wrapper.go index e97b13a3..d9de3e60 100644 --- a/exchanges/kraken/kraken_wrapper.go +++ b/exchanges/kraken/kraken_wrapper.go @@ -1,7 +1,6 @@ package kraken import ( - "errors" "log" "strings" "sync" @@ -139,30 +138,30 @@ func (k *Kraken) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbo return orderbook.GetOrderbook(k.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Kraken exchange - to-do -func (k *Kraken) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (k *Kraken) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = k.GetName() return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (k *Kraken) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (k *Kraken) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (k *Kraken) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (k *Kraken) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (k *Kraken) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var args = AddOrderOptions{} @@ -179,54 +178,54 @@ func (k *Kraken) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (k *Kraken) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (k *Kraken) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (k *Kraken) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (k *Kraken) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (k *Kraken) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (k *Kraken) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (k *Kraken) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (k *Kraken) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (k *Kraken) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (k *Kraken) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (k *Kraken) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (k *Kraken) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (k *Kraken) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (k *Kraken) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (k *Kraken) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (k *Kraken) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (k *Kraken) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/lakebtc/README.md b/exchanges/lakebtc/README.md index 70b1bae7..9f30dc0e 100644 --- a/exchanges/lakebtc/README.md +++ b/exchanges/lakebtc/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := l.GetExchangeAccountInfo() +accountInfo, err := l.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/lakebtc/lakebtc.go b/exchanges/lakebtc/lakebtc.go index 3088a02d..5771502f 100644 --- a/exchanges/lakebtc/lakebtc.go +++ b/exchanges/lakebtc/lakebtc.go @@ -210,8 +210,8 @@ func (l *LakeBTC) GetTradeHistory(currency string) ([]TradeHistory, error) { return resp, l.SendHTTPRequest(path, &resp) } -// GetAccountInfo returns your current account information -func (l *LakeBTC) GetAccountInfo() (AccountInfo, error) { +// GetAccountInformation returns your current account information +func (l *LakeBTC) GetAccountInformation() (AccountInfo, error) { resp := AccountInfo{} return resp, l.SendAuthenticatedHTTPRequest(lakeBTCGetAccountInfo, "", &resp) @@ -259,8 +259,8 @@ func (l *LakeBTC) GetOrders(orders []int64) ([]Orders, error) { l.SendAuthenticatedHTTPRequest(lakeBTCGetOrders, common.JoinStrings(ordersStr, ","), &resp) } -// CancelOrder cancels an order by ID number and returns an error -func (l *LakeBTC) CancelOrder(orderID int64) error { +// CancelExistingOrder cancels an order by ID number and returns an error +func (l *LakeBTC) CancelExistingOrder(orderID int64) error { type Response struct { Result bool `json:"Result"` } diff --git a/exchanges/lakebtc/lakebtc_test.go b/exchanges/lakebtc/lakebtc_test.go index 4b069d51..2b8a3504 100644 --- a/exchanges/lakebtc/lakebtc_test.go +++ b/exchanges/lakebtc/lakebtc_test.go @@ -266,7 +266,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.EUR, } - response, err := l.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := l.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/lakebtc/lakebtc_wrapper.go b/exchanges/lakebtc/lakebtc_wrapper.go index e64176f0..ff62d498 100644 --- a/exchanges/lakebtc/lakebtc_wrapper.go +++ b/exchanges/lakebtc/lakebtc_wrapper.go @@ -1,7 +1,6 @@ package lakebtc import ( - "errors" "fmt" "log" "strconv" @@ -101,12 +100,12 @@ func (l *LakeBTC) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderb return orderbook.GetOrderbook(l.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // LakeBTC exchange -func (l *LakeBTC) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (l *LakeBTC) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = l.GetName() - accountInfo, err := l.GetAccountInfo() + accountInfo, err := l.GetAccountInformation() if err != nil { return response, err } @@ -125,22 +124,22 @@ func (l *LakeBTC) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (l *LakeBTC) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (l *LakeBTC) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (l *LakeBTC) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (l *LakeBTC) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (l *LakeBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse isBuyOrder := side == exchange.Buy response, err := l.Trade(isBuyOrder, amount, price, common.StringToLower(p.Pair().String())) @@ -156,54 +155,54 @@ func (l *LakeBTC) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSi return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (l *LakeBTC) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (l *LakeBTC) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (l *LakeBTC) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (l *LakeBTC) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (l *LakeBTC) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (l *LakeBTC) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (l *LakeBTC) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (l *LakeBTC) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (l *LakeBTC) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (l *LakeBTC) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (l *LakeBTC) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *LakeBTC) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (l *LakeBTC) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *LakeBTC) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (l *LakeBTC) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *LakeBTC) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (l *LakeBTC) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/liqui/README.md b/exchanges/liqui/README.md index c381bfa6..263c29e7 100644 --- a/exchanges/liqui/README.md +++ b/exchanges/liqui/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := l.GetExchangeAccountInfo() +accountInfo, err := l.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/liqui/liqui.go b/exchanges/liqui/liqui.go index 2400fb52..9e967379 100644 --- a/exchanges/liqui/liqui.go +++ b/exchanges/liqui/liqui.go @@ -183,10 +183,10 @@ func (l *Liqui) GetTrades(currencyPair string) ([]Trades, error) { return response.Data[currencyPair], l.SendHTTPRequest(req, &response.Data) } -// GetAccountInfo returns information about the user’s current balance, API-key +// GetAccountInformation returns information about the user’s current balance, API-key // privileges, the number of open orders and Server Time. To use this method you // need a privilege of the key info. -func (l *Liqui) GetAccountInfo() (AccountInfo, error) { +func (l *Liqui) GetAccountInformation() (AccountInfo, error) { var result AccountInfo return result, @@ -217,8 +217,8 @@ func (l *Liqui) GetActiveOrders(pair string) (map[string]ActiveOrders, error) { return result, l.SendAuthenticatedHTTPRequest(liquiActiveOrders, req, &result) } -// GetOrderInfo returns the information on particular order. -func (l *Liqui) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) { +// GetOrderInfoByID returns the information on particular order. +func (l *Liqui) GetOrderInfoByID(OrderID int64) (map[string]OrderInfo, error) { result := make(map[string]OrderInfo) req := url.Values{} @@ -227,8 +227,8 @@ func (l *Liqui) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) { return result, l.SendAuthenticatedHTTPRequest(liquiOrderInfo, req, &result) } -// CancelOrder method is used for order cancelation. -func (l *Liqui) CancelOrder(OrderID int64) (bool, error) { +// CancelExistingOrder method is used for order cancelation. +func (l *Liqui) CancelExistingOrder(OrderID int64) (bool, error) { req := url.Values{} req.Add("order_id", strconv.FormatInt(OrderID, 10)) diff --git a/exchanges/liqui/liqui_test.go b/exchanges/liqui/liqui_test.go index 6819150c..9b92a25a 100644 --- a/exchanges/liqui/liqui_test.go +++ b/exchanges/liqui/liqui_test.go @@ -100,9 +100,9 @@ func TestAuthRequests(t *testing.T) { t.Error("Test Failed - liqui GetOrderInfo() error", err) } - _, err = l.CancelOrder(1337) + _, err = l.CancelExistingOrder(1337) if err == nil { - t.Error("Test Failed - liqui CancelOrder() error", err) + t.Error("Test Failed - liqui CancelExistingOrder() error", err) } _, err = l.GetTradeHistory(url.Values{}, "") @@ -251,7 +251,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.EUR, } - response, err := l.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := l.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/liqui/liqui_wrapper.go b/exchanges/liqui/liqui_wrapper.go index 9c4447d7..5d4b94b6 100644 --- a/exchanges/liqui/liqui_wrapper.go +++ b/exchanges/liqui/liqui_wrapper.go @@ -1,7 +1,6 @@ package liqui import ( - "errors" "fmt" "log" "sync" @@ -113,12 +112,12 @@ func (l *Liqui) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo return orderbook.GetOrderbook(l.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Liqui exchange -func (l *Liqui) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (l *Liqui) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = l.GetName() - accountBalance, err := l.GetAccountInfo() + accountBalance, err := l.GetAccountInformation() if err != nil { return response, err } @@ -134,22 +133,22 @@ func (l *Liqui) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (l *Liqui) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (l *Liqui) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (l *Liqui) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (l *Liqui) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (l *Liqui) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := l.Trade(p.Pair().String(), fmt.Sprintf("%s", orderType), amount, price) @@ -164,54 +163,54 @@ func (l *Liqui) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (l *Liqui) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (l *Liqui) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (l *Liqui) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (l *Liqui) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (l *Liqui) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (l *Liqui) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (l *Liqui) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (l *Liqui) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (l *Liqui) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (l *Liqui) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (l *Liqui) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *Liqui) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (l *Liqui) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *Liqui) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (l *Liqui) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *Liqui) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (l *Liqui) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/localbitcoins/README.md b/exchanges/localbitcoins/README.md index fe29c3c4..a295f3e1 100644 --- a/exchanges/localbitcoins/README.md +++ b/exchanges/localbitcoins/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := l.GetExchangeAccountInfo() +accountInfo, err := l.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/localbitcoins/localbitcoins.go b/exchanges/localbitcoins/localbitcoins.go index 3b50026d..de599e80 100644 --- a/exchanges/localbitcoins/localbitcoins.go +++ b/exchanges/localbitcoins/localbitcoins.go @@ -167,10 +167,10 @@ func (l *LocalBitcoins) Setup(exch config.ExchangeConfig) { } } -// GetAccountInfo lets you retrieve the public user information on a +// GetAccountInformation lets you retrieve the public user information on a // LocalBitcoins user. The response contains the same information that is found // on an account's public profile page. -func (l *LocalBitcoins) GetAccountInfo(username string, self bool) (AccountInfo, error) { +func (l *LocalBitcoins) GetAccountInformation(username string, self bool) (AccountInfo, error) { type response struct { Data AccountInfo `json:"data"` } diff --git a/exchanges/localbitcoins/localbitcoins_test.go b/exchanges/localbitcoins/localbitcoins_test.go index 2f05f0d1..76161cf0 100644 --- a/exchanges/localbitcoins/localbitcoins_test.go +++ b/exchanges/localbitcoins/localbitcoins_test.go @@ -41,13 +41,13 @@ func TestGetAccountInfo(t *testing.T) { if l.APIKey == "" || l.APISecret == "" { t.Skip() } - _, err := l.GetAccountInfo("", true) + _, err := l.GetAccountInformation("", true) if err == nil { - t.Error("Test Failed - GetAccountInfo() error", err) + t.Error("Test Failed - GetAccountInformation() error", err) } - _, err = l.GetAccountInfo("bitcoinbaron", false) + _, err = l.GetAccountInformation("bitcoinbaron", false) if err != nil { - t.Error("Test Failed - GetAccountInfo() error", err) + t.Error("Test Failed - GetAccountInformation() error", err) } } diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index f175b3d5..ba36443e 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -7,6 +7,7 @@ import ( "math" "sync" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" @@ -90,9 +91,9 @@ func (l *LocalBitcoins) UpdateOrderbook(p pair.CurrencyPair, assetType string) ( return orderbook.GetOrderbook(l.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // LocalBitcoins exchange -func (l *LocalBitcoins) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (l *LocalBitcoins) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = l.GetName() accountBalance, err := l.GetWalletBalance() @@ -107,22 +108,22 @@ func (l *LocalBitcoins) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (l *LocalBitcoins) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (l *LocalBitcoins) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (l *LocalBitcoins) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (l *LocalBitcoins) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (l *LocalBitcoins) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse // These are placeholder details // TODO store a user's localbitcoin details to use here @@ -188,54 +189,54 @@ func (l *LocalBitcoins) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.O return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (l *LocalBitcoins) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (l *LocalBitcoins) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (l *LocalBitcoins) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (l *LocalBitcoins) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (l *LocalBitcoins) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (l *LocalBitcoins) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (l *LocalBitcoins) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (l *LocalBitcoins) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (l *LocalBitcoins) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (l *LocalBitcoins) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (l *LocalBitcoins) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *LocalBitcoins) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (l *LocalBitcoins) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *LocalBitcoins) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (l *LocalBitcoins) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (l *LocalBitcoins) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (l *LocalBitcoins) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/okcoin/README.md b/exchanges/okcoin/README.md index b9b57cf5..e1451169 100644 --- a/exchanges/okcoin/README.md +++ b/exchanges/okcoin/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := o.GetExchangeAccountInfo() +accountInfo, err := o.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/okcoin/okcoin.go b/exchanges/okcoin/okcoin.go index 2a3c8d34..a6504941 100644 --- a/exchanges/okcoin/okcoin.go +++ b/exchanges/okcoin/okcoin.go @@ -437,8 +437,8 @@ func (o *OKCoin) BatchTrade(orderData string, symbol, orderType string) (BatchTr return result, nil } -// CancelOrder cancels a specific order or list of orders by orderID -func (o *OKCoin) CancelOrder(orderID []int64, symbol string) (CancelOrderResponse, error) { +// CancelExistingOrder cancels a specific order or list of orders by orderID +func (o *OKCoin) CancelExistingOrder(orderID []int64, symbol string) (CancelOrderResponse, error) { v := url.Values{} orders := []string{} result := CancelOrderResponse{} @@ -458,8 +458,8 @@ func (o *OKCoin) CancelOrder(orderID []int64, symbol string) (CancelOrderRespons return result, o.SendAuthenticatedHTTPRequest(okcoinOrderCancel, v, &result) } -// GetOrderInfo returns order information by orderID -func (o *OKCoin) GetOrderInfo(orderID int64, symbol string) ([]OrderInfo, error) { +// GetOrderInformation returns order information by orderID +func (o *OKCoin) GetOrderInformation(orderID int64, symbol string) ([]OrderInfo, error) { type Response struct { Result bool `json:"result"` Orders []OrderInfo `json:"orders"` diff --git a/exchanges/okcoin/okcoin_test.go b/exchanges/okcoin/okcoin_test.go index af23284c..5873e586 100644 --- a/exchanges/okcoin/okcoin_test.go +++ b/exchanges/okcoin/okcoin_test.go @@ -158,7 +158,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.EUR, } - response, err := o.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := o.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/okcoin/okcoin_wrapper.go b/exchanges/okcoin/okcoin_wrapper.go index 75778c96..2060168b 100644 --- a/exchanges/okcoin/okcoin_wrapper.go +++ b/exchanges/okcoin/okcoin_wrapper.go @@ -135,9 +135,9 @@ func (o *OKCoin) UpdateOrderbook(currency pair.CurrencyPair, assetType string) ( return orderbook.GetOrderbook(o.Name, currency, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // OKCoin exchange -func (o *OKCoin) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (o *OKCoin) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = o.GetName() assets, err := o.GetUserInfo() @@ -172,22 +172,22 @@ func (o *OKCoin) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (o *OKCoin) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (o *OKCoin) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (o *OKCoin) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (o *OKCoin) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (o *OKCoin) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var oT string if orderType == exchange.Limit { @@ -219,49 +219,49 @@ func (o *OKCoin) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSid return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (o *OKCoin) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (o *OKCoin) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (o *OKCoin) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (o *OKCoin) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (o *OKCoin) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (o *OKCoin) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (o *OKCoin) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (o *OKCoin) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (o *OKCoin) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (o *OKCoin) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (o *OKCoin) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (o *OKCoin) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (o *OKCoin) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (o *OKCoin) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (o *OKCoin) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (o *OKCoin) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/okex/README.md b/exchanges/okex/README.md index e6a2b00a..aa5451cb 100644 --- a/exchanges/okex/README.md +++ b/exchanges/okex/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := o.GetExchangeAccountInfo() +accountInfo, err := o.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/okex/okex_test.go b/exchanges/okex/okex_test.go index 9e3147aa..27b34ae6 100644 --- a/exchanges/okex/okex_test.go +++ b/exchanges/okex/okex_test.go @@ -407,7 +407,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.EUR, } - response, err := o.SubmitExchangeOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := o.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/okex/okex_wrapper.go b/exchanges/okex/okex_wrapper.go index 63a243b2..69196e8d 100644 --- a/exchanges/okex/okex_wrapper.go +++ b/exchanges/okex/okex_wrapper.go @@ -131,29 +131,29 @@ func (o *OKEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook return orderbook.GetOrderbook(o.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // OKEX exchange -func (o *OKEX) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (o *OKEX) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo return response, errors.New("not implemented") } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (o *OKEX) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (o *OKEX) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (o *OKEX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (o *OKEX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (o *OKEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var oT SpotNewOrderRequestType @@ -193,49 +193,49 @@ func (o *OKEX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (o *OKEX) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (o *OKEX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (o *OKEX) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (o *OKEX) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (o *OKEX) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (o *OKEX) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (o *OKEX) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (o *OKEX) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (o *OKEX) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (o *OKEX) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (o *OKEX) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (o *OKEX) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (o *OKEX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (o *OKEX) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (o *OKEX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (o *OKEX) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/poloniex/README.md b/exchanges/poloniex/README.md index 8ea7cce5..d86e7e20 100644 --- a/exchanges/poloniex/README.md +++ b/exchanges/poloniex/README.md @@ -72,7 +72,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := p.GetExchangeAccountInfo() +accountInfo, err := p.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index 212c2afb..e8526480 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -521,8 +521,8 @@ func (p *Poloniex) PlaceOrder(currency string, rate, amount float64, immediate, return result, nil } -// CancelOrder cancels and order by orderID -func (p *Poloniex) CancelOrder(orderID int64) (bool, error) { +// CancelExistingOrder cancels and order by orderID +func (p *Poloniex) CancelExistingOrder(orderID int64) (bool, error) { result := GenericResponse{} values := url.Values{} values.Set("orderNumber", strconv.FormatInt(orderID, 10)) diff --git a/exchanges/poloniex/poloniex_test.go b/exchanges/poloniex/poloniex_test.go index 7ba754fa..35b7d7be 100644 --- a/exchanges/poloniex/poloniex_test.go +++ b/exchanges/poloniex/poloniex_test.go @@ -211,7 +211,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.LTC, } - response, err := p.SubmitExchangeOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := p.SubmitOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/poloniex/poloniex_wrapper.go b/exchanges/poloniex/poloniex_wrapper.go index c88ce245..76d41e1b 100644 --- a/exchanges/poloniex/poloniex_wrapper.go +++ b/exchanges/poloniex/poloniex_wrapper.go @@ -1,7 +1,6 @@ package poloniex import ( - "errors" "fmt" "log" "sync" @@ -122,9 +121,9 @@ func (p *Poloniex) UpdateOrderbook(currencyPair pair.CurrencyPair, assetType str return orderbook.GetOrderbook(p.Name, currencyPair, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Poloniex exchange -func (p *Poloniex) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (p *Poloniex) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = p.GetName() accountBalance, err := p.GetBalances() @@ -141,22 +140,22 @@ func (p *Poloniex) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (p *Poloniex) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (p *Poloniex) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (p *Poloniex) GetExchangeHistory(currencyPair pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (p *Poloniex) SubmitExchangeOrder(currencyPair pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (p *Poloniex) SubmitOrder(currencyPair pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse fillOrKill := orderType == exchange.Market isBuyOrder := side == exchange.Buy @@ -173,49 +172,49 @@ func (p *Poloniex) SubmitExchangeOrder(currencyPair pair.CurrencyPair, side exch return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (p *Poloniex) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (p *Poloniex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (p *Poloniex) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (p *Poloniex) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (p *Poloniex) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (p *Poloniex) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (p *Poloniex) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (p *Poloniex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (p *Poloniex) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (p *Poloniex) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (p *Poloniex) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (p *Poloniex) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (p *Poloniex) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (p *Poloniex) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (p *Poloniex) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (p *Poloniex) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/wex/README.md b/exchanges/wex/README.md index 36a8af82..edf89f2a 100644 --- a/exchanges/wex/README.md +++ b/exchanges/wex/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := w.GetExchangeAccountInfo() +accountInfo, err := w.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/wex/wex.go b/exchanges/wex/wex.go index ff946598..451ec14b 100644 --- a/exchanges/wex/wex.go +++ b/exchanges/wex/wex.go @@ -173,8 +173,8 @@ func (w *WEX) GetTrades(symbol string) ([]Trades, error) { return response.Data[symbol], w.SendHTTPRequest(req, &response.Data) } -// GetAccountInfo returns a users account info -func (w *WEX) GetAccountInfo() (AccountInfo, error) { +// GetAccountInformation returns a users account info +func (w *WEX) GetAccountInformation() (AccountInfo, error) { var result AccountInfo err := w.SendAuthenticatedHTTPRequest(wexAccountInfo, url.Values{}, &result) @@ -198,8 +198,8 @@ func (w *WEX) GetActiveOrders(pair string) (map[string]ActiveOrders, error) { return result, w.SendAuthenticatedHTTPRequest(wexActiveOrders, req, &result) } -// GetOrderInfo returns the order info for a specific order ID -func (w *WEX) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) { +// GetOrderInformation returns the order info for a specific order ID +func (w *WEX) GetOrderInformation(OrderID int64) (map[string]OrderInfo, error) { req := url.Values{} req.Add("order_id", strconv.FormatInt(OrderID, 10)) @@ -208,8 +208,8 @@ func (w *WEX) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) { return result, w.SendAuthenticatedHTTPRequest(wexOrderInfo, req, &result) } -// CancelOrder cancels an order for a specific order ID -func (w *WEX) CancelOrder(OrderID int64) (bool, error) { +// CancelExistingOrder cancels an order for a specific order ID +func (w *WEX) CancelExistingOrder(OrderID int64) (bool, error) { req := url.Values{} req.Add("order_id", strconv.FormatInt(OrderID, 10)) diff --git a/exchanges/wex/wex_test.go b/exchanges/wex/wex_test.go index 61aeb0c5..ccf3d075 100644 --- a/exchanges/wex/wex_test.go +++ b/exchanges/wex/wex_test.go @@ -101,11 +101,11 @@ func TestGetOrderInfo(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() - _, err := w.CancelOrder(1337) + _, err := w.CancelExistingOrder(1337) if err == nil { - t.Error("Test Failed - CancelOrder() error", err) + t.Error("Test Failed - CancelExistingOrder() error", err) } } @@ -286,7 +286,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USD, } - response, err := w.SubmitExchangeOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := w.SubmitOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/wex/wex_wrapper.go b/exchanges/wex/wex_wrapper.go index 0b365414..df8cf470 100644 --- a/exchanges/wex/wex_wrapper.go +++ b/exchanges/wex/wex_wrapper.go @@ -1,7 +1,6 @@ package wex import ( - "errors" "fmt" "log" "sync" @@ -123,12 +122,12 @@ func (w *WEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook. return orderbook.GetOrderbook(w.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // WEX exchange -func (w *WEX) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (w *WEX) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = w.GetName() - accountBalance, err := w.GetAccountInfo() + accountBalance, err := w.GetAccountInformation() if err != nil { return response, err } @@ -144,22 +143,22 @@ func (w *WEX) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (w *WEX) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (w *WEX) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (w *WEX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (w *WEX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (w *WEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := w.Trade(common.StringToLower(p.Pair().String()), common.StringToLower(side.ToString()), amount, price) @@ -174,54 +173,54 @@ func (w *WEX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (w *WEX) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (w *WEX) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (w *WEX) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (w *WEX) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (w *WEX) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (w *WEX) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (w *WEX) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (w *WEX) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (w *WEX) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (w *WEX) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (w *WEX) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (w *WEX) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (w *WEX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (w *WEX) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (w *WEX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (w *WEX) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (w *WEX) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/yobit/README.md b/exchanges/yobit/README.md index 2c4717cd..2018f42a 100644 --- a/exchanges/yobit/README.md +++ b/exchanges/yobit/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := y.GetExchangeAccountInfo() +accountInfo, err := y.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/yobit/yobit.go b/exchanges/yobit/yobit.go index 0c38d3f4..762b497c 100644 --- a/exchanges/yobit/yobit.go +++ b/exchanges/yobit/yobit.go @@ -159,8 +159,8 @@ func (y *Yobit) GetTrades(symbol string) ([]Trades, error) { return response.Data[symbol], y.SendHTTPRequest(path, &response.Data) } -// GetAccountInfo returns a users account info -func (y *Yobit) GetAccountInfo() (AccountInfo, error) { +// GetAccountInformation returns a users account info +func (y *Yobit) GetAccountInformation() (AccountInfo, error) { result := AccountInfo{} err := y.SendAuthenticatedHTTPRequest(privateAccountInfo, url.Values{}, &result) @@ -203,8 +203,8 @@ func (y *Yobit) GetActiveOrders(pair string) (map[string]ActiveOrders, error) { return result, y.SendAuthenticatedHTTPRequest(privateActiveOrders, req, &result) } -// GetOrderInfo returns the order info for a specific order ID -func (y *Yobit) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) { +// GetOrderInformation returns the order info for a specific order ID +func (y *Yobit) GetOrderInformation(OrderID int64) (map[string]OrderInfo, error) { req := url.Values{} req.Add("order_id", strconv.FormatInt(OrderID, 10)) @@ -213,8 +213,8 @@ func (y *Yobit) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error) { return result, y.SendAuthenticatedHTTPRequest(privateOrderInfo, req, &result) } -// CancelOrder cancels an order for a specific order ID -func (y *Yobit) CancelOrder(OrderID int64) (bool, error) { +// CancelExistingOrder cancels an order for a specific order ID +func (y *Yobit) CancelExistingOrder(OrderID int64) (bool, error) { req := url.Values{} req.Add("order_id", strconv.FormatInt(OrderID, 10)) @@ -247,8 +247,8 @@ func (y *Yobit) GetTradeHistory(TIDFrom, Count, TIDEnd int64, order, since, end, return result, y.SendAuthenticatedHTTPRequest(privateTradeHistory, req, &result) } -// GetDepositAddress returns the deposit address for a specific currency -func (y *Yobit) GetDepositAddress(coin string) (DepositAddress, error) { +// GetCryptoDepositAddress returns the deposit address for a specific currency +func (y *Yobit) GetCryptoDepositAddress(coin string) (DepositAddress, error) { req := url.Values{} req.Add("coinName", coin) diff --git a/exchanges/yobit/yobit_test.go b/exchanges/yobit/yobit_test.go index 8ecf21d3..c064847f 100644 --- a/exchanges/yobit/yobit_test.go +++ b/exchanges/yobit/yobit_test.go @@ -95,7 +95,7 @@ func TestGetOrderInfo(t *testing.T) { func TestCancelOrder(t *testing.T) { t.Parallel() - _, err := y.CancelOrder(1337) + _, err := y.CancelExistingOrder(1337) if err == nil { t.Error("Test Failed - CancelOrder() error", err) } @@ -330,7 +330,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.BTC, SecondCurrency: symbol.USD, } - response, err := y.SubmitExchangeOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := y.SubmitOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/yobit/yobit_wrapper.go b/exchanges/yobit/yobit_wrapper.go index 46e14bbe..2a5768b7 100644 --- a/exchanges/yobit/yobit_wrapper.go +++ b/exchanges/yobit/yobit_wrapper.go @@ -1,7 +1,6 @@ package yobit import ( - "errors" "fmt" "log" "sync" @@ -99,12 +98,12 @@ func (y *Yobit) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo return orderbook.GetOrderbook(y.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // Yobit exchange -func (y *Yobit) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (y *Yobit) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo response.ExchangeName = y.GetName() - accountBalance, err := y.GetAccountInfo() + accountBalance, err := y.GetAccountInformation() if err != nil { return response, err } @@ -126,22 +125,22 @@ func (y *Yobit) GetExchangeAccountInfo() (exchange.AccountInfo, error) { return response, nil } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (y *Yobit) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (y *Yobit) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (y *Yobit) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (y *Yobit) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (y *Yobit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse response, err := y.Trade(p.Pair().String(), orderType.ToString(), amount, price) @@ -156,54 +155,54 @@ func (y *Yobit) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (y *Yobit) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (y *Yobit) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (y *Yobit) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (y *Yobit) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (y *Yobit) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (y *Yobit) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (y *Yobit) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (y *Yobit) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (y *Yobit) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (y *Yobit) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (y *Yobit) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (y *Yobit) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (y *Yobit) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (y *Yobit) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (y *Yobit) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (y *Yobit) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (y *Yobit) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/exchanges/zb/README.md b/exchanges/zb/README.md index 4e452ad6..3d988210 100644 --- a/exchanges/zb/README.md +++ b/exchanges/zb/README.md @@ -71,7 +71,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := z.GetExchangeAccountInfo() +accountInfo, err := z.GetAccountInfo() if err != nil { // Handle error } diff --git a/exchanges/zb/zb.go b/exchanges/zb/zb.go index 2470d648..f0fc7308 100644 --- a/exchanges/zb/zb.go +++ b/exchanges/zb/zb.go @@ -134,8 +134,8 @@ func (z *ZB) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) { return newOrderID, nil } -// CancelOrder cancels an order on Huobi -func (z *ZB) CancelOrder(orderID int64, symbol string) error { +// CancelExistingOrder cancels an order +func (z *ZB) CancelExistingOrder(orderID int64, symbol string) error { type response struct { Code int `json:"code"` // Result code Message string `json:"message"` // Result Message @@ -159,9 +159,9 @@ func (z *ZB) CancelOrder(orderID int64, symbol string) error { return nil } -// GetAccountInfo returns account information including coin information +// GetAccountInformation returns account information including coin information // and pricing -func (z *ZB) GetAccountInfo() (AccountsResponse, error) { +func (z *ZB) GetAccountInformation() (AccountsResponse, error) { var result AccountsResponse vals := url.Values{} diff --git a/exchanges/zb/zb_test.go b/exchanges/zb/zb_test.go index 7d2e8eb6..25fae4a4 100644 --- a/exchanges/zb/zb_test.go +++ b/exchanges/zb/zb_test.go @@ -59,16 +59,16 @@ func TestSpotNewOrder(t *testing.T) { } } -func TestCancelOrder(t *testing.T) { +func TestCancelExistingOrder(t *testing.T) { t.Parallel() if z.APIKey == "" || z.APISecret == "" { t.Skip() } - err := z.CancelOrder(20180629145864850, "btc_usdt") + err := z.CancelExistingOrder(20180629145864850, "btc_usdt") if err != nil { - t.Errorf("Test failed - ZB CancelOrder: %s", err) + t.Errorf("Test failed - ZB CancelExistingOrder: %s", err) } } @@ -260,7 +260,7 @@ func TestSubmitOrder(t *testing.T) { FirstCurrency: symbol.QTUM, SecondCurrency: symbol.USDT, } - response, err := z.SubmitExchangeOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") + response, err := z.SubmitOrder(pair, exchange.Buy, exchange.Market, 1, 10, "hi") if err != nil || !response.IsOrderPlaced { t.Errorf("Order failed to be placed: %v", err) } diff --git a/exchanges/zb/zb_wrapper.go b/exchanges/zb/zb_wrapper.go index d3fc2007..d6c23356 100644 --- a/exchanges/zb/zb_wrapper.go +++ b/exchanges/zb/zb_wrapper.go @@ -115,29 +115,29 @@ func (z *ZB) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.B return orderbook.GetOrderbook(z.Name, p, assetType) } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // ZB exchange -func (z *ZB) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func (z *ZB) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo return response, errors.New("not implemented") } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func (z *ZB) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func (z *ZB) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func (z *ZB) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func (z *ZB) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { +// SubmitOrder submits a new order +func (z *ZB) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { var submitOrderResponse exchange.SubmitOrderResponse var oT SpotNewOrderRequestParamsType @@ -166,54 +166,54 @@ func (z *ZB) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, o return submitOrderResponse, err } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func (z *ZB) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func (z *ZB) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func (z *ZB) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func (z *ZB) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func (z *ZB) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func (z *ZB) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func (z *ZB) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func (z *ZB) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func (z *ZB) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func (z *ZB) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func (z *ZB) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (z *ZB) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a +// WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted -func (z *ZB) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (z *ZB) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted -func (z *ZB) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func (z *ZB) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func (z *ZB) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } // GetFeeByType returns an estimate of fee based on type of transaction diff --git a/restful_server.go b/restful_server.go index 75e9872a..2539c133 100644 --- a/restful_server.go +++ b/restful_server.go @@ -270,7 +270,7 @@ func GetAllEnabledExchangeAccountInfo() AllEnabledExchangeAccounts { log.Printf("GetAllEnabledExchangeAccountInfo: Skippping %s due to disabled authenticated API support.", individualBot.GetName()) continue } - individualExchange, err := individualBot.GetExchangeAccountInfo() + individualExchange, err := individualBot.GetAccountInfo() if err != nil { log.Printf("Error encountered retrieving exchange account info for %s. Error %s", individualBot.GetName(), err) diff --git a/tools/documentation/exchanges_templates/anx.tmpl b/tools/documentation/exchanges_templates/anx.tmpl index e2a4e4f9..e94a37e2 100644 --- a/tools/documentation/exchanges_templates/anx.tmpl +++ b/tools/documentation/exchanges_templates/anx.tmpl @@ -57,7 +57,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := a.GetExchangeAccountInfo() +accountInfo, err := a.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/binance.tmpl b/tools/documentation/exchanges_templates/binance.tmpl index 492c33cc..a836b302 100644 --- a/tools/documentation/exchanges_templates/binance.tmpl +++ b/tools/documentation/exchanges_templates/binance.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/bitfinex.tmpl b/tools/documentation/exchanges_templates/bitfinex.tmpl index bad641ca..bdf756aa 100644 --- a/tools/documentation/exchanges_templates/bitfinex.tmpl +++ b/tools/documentation/exchanges_templates/bitfinex.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/bitflyer.tmpl b/tools/documentation/exchanges_templates/bitflyer.tmpl index e7b32d08..11525706 100644 --- a/tools/documentation/exchanges_templates/bitflyer.tmpl +++ b/tools/documentation/exchanges_templates/bitflyer.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/bithumb.tmpl b/tools/documentation/exchanges_templates/bithumb.tmpl index 2e12de48..4e630f83 100644 --- a/tools/documentation/exchanges_templates/bithumb.tmpl +++ b/tools/documentation/exchanges_templates/bithumb.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/bitmex.tmpl b/tools/documentation/exchanges_templates/bitmex.tmpl index 0aba53ac..fb65ba93 100644 --- a/tools/documentation/exchanges_templates/bitmex.tmpl +++ b/tools/documentation/exchanges_templates/bitmex.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/bitstamp.tmpl b/tools/documentation/exchanges_templates/bitstamp.tmpl index 9affe03e..1d288aa4 100644 --- a/tools/documentation/exchanges_templates/bitstamp.tmpl +++ b/tools/documentation/exchanges_templates/bitstamp.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/bittrex.tmpl b/tools/documentation/exchanges_templates/bittrex.tmpl index a9313b5c..e5e4f011 100644 --- a/tools/documentation/exchanges_templates/bittrex.tmpl +++ b/tools/documentation/exchanges_templates/bittrex.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/btcc.tmpl b/tools/documentation/exchanges_templates/btcc.tmpl index 43fd48bf..095a9fea 100644 --- a/tools/documentation/exchanges_templates/btcc.tmpl +++ b/tools/documentation/exchanges_templates/btcc.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/btcmarkets.tmpl b/tools/documentation/exchanges_templates/btcmarkets.tmpl index 940e02e1..6ca25f3d 100644 --- a/tools/documentation/exchanges_templates/btcmarkets.tmpl +++ b/tools/documentation/exchanges_templates/btcmarkets.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := b.GetExchangeAccountInfo() +accountInfo, err := b.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/coinbasepro.tmpl b/tools/documentation/exchanges_templates/coinbasepro.tmpl index e2939ab3..6843d0e8 100644 --- a/tools/documentation/exchanges_templates/coinbasepro.tmpl +++ b/tools/documentation/exchanges_templates/coinbasepro.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := c.GetExchangeAccountInfo() +accountInfo, err := c.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/coinut.tmpl b/tools/documentation/exchanges_templates/coinut.tmpl index c6916450..1a7960ec 100644 --- a/tools/documentation/exchanges_templates/coinut.tmpl +++ b/tools/documentation/exchanges_templates/coinut.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := c.GetExchangeAccountInfo() +accountInfo, err := c.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/exmo.tmpl b/tools/documentation/exchanges_templates/exmo.tmpl index d4095426..d65ec2b7 100644 --- a/tools/documentation/exchanges_templates/exmo.tmpl +++ b/tools/documentation/exchanges_templates/exmo.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := e.GetExchangeAccountInfo() +accountInfo, err := e.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/gateio.tmpl b/tools/documentation/exchanges_templates/gateio.tmpl index d075b1a4..ef80257b 100644 --- a/tools/documentation/exchanges_templates/gateio.tmpl +++ b/tools/documentation/exchanges_templates/gateio.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := g.GetExchangeAccountInfo() +accountInfo, err := g.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/gemini.tmpl b/tools/documentation/exchanges_templates/gemini.tmpl index 621066c1..18e2170d 100644 --- a/tools/documentation/exchanges_templates/gemini.tmpl +++ b/tools/documentation/exchanges_templates/gemini.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := g.GetExchangeAccountInfo() +accountInfo, err := g.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/hitbtc.tmpl b/tools/documentation/exchanges_templates/hitbtc.tmpl index e4f18ce9..bc484858 100644 --- a/tools/documentation/exchanges_templates/hitbtc.tmpl +++ b/tools/documentation/exchanges_templates/hitbtc.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := h.GetExchangeAccountInfo() +accountInfo, err := h.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/huobi.tmpl b/tools/documentation/exchanges_templates/huobi.tmpl index 9688119b..0917fb77 100644 --- a/tools/documentation/exchanges_templates/huobi.tmpl +++ b/tools/documentation/exchanges_templates/huobi.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := h.GetExchangeAccountInfo() +accountInfo, err := h.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/huobihadax.tmpl b/tools/documentation/exchanges_templates/huobihadax.tmpl index d09535cf..6534d838 100644 --- a/tools/documentation/exchanges_templates/huobihadax.tmpl +++ b/tools/documentation/exchanges_templates/huobihadax.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := h.GetExchangeAccountInfo() +accountInfo, err := h.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/itbit.tmpl b/tools/documentation/exchanges_templates/itbit.tmpl index 897ebae9..2112c376 100644 --- a/tools/documentation/exchanges_templates/itbit.tmpl +++ b/tools/documentation/exchanges_templates/itbit.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := i.GetExchangeAccountInfo() +accountInfo, err := i.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/kraken.tmpl b/tools/documentation/exchanges_templates/kraken.tmpl index c1987823..c433b000 100644 --- a/tools/documentation/exchanges_templates/kraken.tmpl +++ b/tools/documentation/exchanges_templates/kraken.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := k.GetExchangeAccountInfo() +accountInfo, err := k.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/lakebtc.tmpl b/tools/documentation/exchanges_templates/lakebtc.tmpl index cfebdc20..0b28111a 100644 --- a/tools/documentation/exchanges_templates/lakebtc.tmpl +++ b/tools/documentation/exchanges_templates/lakebtc.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := l.GetExchangeAccountInfo() +accountInfo, err := l.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/liqui.tmpl b/tools/documentation/exchanges_templates/liqui.tmpl index f830658a..a0b4bd92 100644 --- a/tools/documentation/exchanges_templates/liqui.tmpl +++ b/tools/documentation/exchanges_templates/liqui.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := l.GetExchangeAccountInfo() +accountInfo, err := l.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/localbitcoins.tmpl b/tools/documentation/exchanges_templates/localbitcoins.tmpl index 500023c6..b3654258 100644 --- a/tools/documentation/exchanges_templates/localbitcoins.tmpl +++ b/tools/documentation/exchanges_templates/localbitcoins.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := l.GetExchangeAccountInfo() +accountInfo, err := l.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/okcoin.tmpl b/tools/documentation/exchanges_templates/okcoin.tmpl index 25305645..9657a62a 100644 --- a/tools/documentation/exchanges_templates/okcoin.tmpl +++ b/tools/documentation/exchanges_templates/okcoin.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := o.GetExchangeAccountInfo() +accountInfo, err := o.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/okex.tmpl b/tools/documentation/exchanges_templates/okex.tmpl index 3ffa1118..1b5d091e 100644 --- a/tools/documentation/exchanges_templates/okex.tmpl +++ b/tools/documentation/exchanges_templates/okex.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := o.GetExchangeAccountInfo() +accountInfo, err := o.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/poloniex.tmpl b/tools/documentation/exchanges_templates/poloniex.tmpl index e1a9ca3c..512f010e 100644 --- a/tools/documentation/exchanges_templates/poloniex.tmpl +++ b/tools/documentation/exchanges_templates/poloniex.tmpl @@ -54,7 +54,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := p.GetExchangeAccountInfo() +accountInfo, err := p.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/wex.tmpl b/tools/documentation/exchanges_templates/wex.tmpl index f81d7fdd..d7f80aa1 100644 --- a/tools/documentation/exchanges_templates/wex.tmpl +++ b/tools/documentation/exchanges_templates/wex.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := w.GetExchangeAccountInfo() +accountInfo, err := w.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/yobit.tmpl b/tools/documentation/exchanges_templates/yobit.tmpl index 16a2ecc4..3e51bc05 100644 --- a/tools/documentation/exchanges_templates/yobit.tmpl +++ b/tools/documentation/exchanges_templates/yobit.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := y.GetExchangeAccountInfo() +accountInfo, err := y.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/documentation/exchanges_templates/zb.tmpl b/tools/documentation/exchanges_templates/zb.tmpl index 5a2537af..f3ed9124 100644 --- a/tools/documentation/exchanges_templates/zb.tmpl +++ b/tools/documentation/exchanges_templates/zb.tmpl @@ -53,7 +53,7 @@ if err != nil { // set and AuthenticatedAPISupport is set to true // Fetches current account information -accountInfo, err := z.GetExchangeAccountInfo() +accountInfo, err := z.GetAccountInfo() if err != nil { // Handle error } diff --git a/tools/exchange_template/wrapper_file.tmpl b/tools/exchange_template/wrapper_file.tmpl index 07b2620e..2fdc965e 100644 --- a/tools/exchange_template/wrapper_file.tmpl +++ b/tools/exchange_template/wrapper_file.tmpl @@ -99,80 +99,80 @@ func ({{.Variable}} *{{.CapitalName}}) UpdateOrderbook(p pair.CurrencyPair, asse return orderBook, nil // NOTE DO NOT USE AS RETURN } -// GetExchangeAccountInfo retrieves balances for all enabled currencies for the +// GetAccountInfo retrieves balances for all enabled currencies for the // {{.CapitalName}} exchange -func ({{.Variable}} *{{.CapitalName}}) GetExchangeAccountInfo() (exchange.AccountInfo, error) { +func ({{.Variable}} *{{.CapitalName}}) GetAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo return response, errors.New("not implemented") } -// GetExchangeFundTransferHistory returns funding history, deposits and +// GetFundingHistory returns funding history, deposits and // withdrawals -func ({{.Variable}} *{{.CapitalName}}) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { +func ({{.Variable}} *{{.CapitalName}}) GetFundingHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory - return fundHistory, errors.New("not supported on exchange") + return fundHistory, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. func ({{.Variable}} *{{.CapitalName}}) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory - return resp, errors.New("trade history not yet implemented") + return resp, common.ErrNotYetImplemented } -// SubmitExchangeOrder submits a new order -func ({{.Variable}} *{{.CapitalName}}) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { - return "", errors.New("not yet implemented") +// SubmitOrder submits a new order +func ({{.Variable}} *{{.CapitalName}}) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) { + return "", common.ErrNotYetImplemented } -// ModifyExchangeOrder will allow of changing orderbook placement and limit to +// ModifyOrder will allow of changing orderbook placement and limit to // market conversion -func ({{.Variable}} *{{.CapitalName}}) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { - return 0, errors.New("not yet implemented") +func ({{.Variable}} *{{.CapitalName}}) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { + return 0, common.ErrNotYetImplemented } -// CancelExchangeOrder cancels an order by its corresponding ID number -func ({{.Variable}} *{{.CapitalName}}) CancelExchangeOrder(orderID int64) error { - return errors.New("not yet implemented") +// CancelOrder cancels an order by its corresponding ID number +func ({{.Variable}} *{{.CapitalName}}) CancelOrder(orderID int64) error { + return common.ErrNotYetImplemented } -// CancelAllExchangeOrders cancels all orders associated with a currency pair -func ({{.Variable}} *{{.CapitalName}}) CancelAllExchangeOrders() error { - return errors.New("not yet implemented") +// CancelAllOrders cancels all orders associated with a currency pair +func ({{.Variable}} *{{.CapitalName}}) CancelAllOrders() error { + return common.ErrNotYetImplemented } -// GetExchangeOrderInfo returns information on a current open order -func ({{.Variable}} *{{.CapitalName}}) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { +// GetOrderInfo returns information on a current open order +func ({{.Variable}} *{{.CapitalName}}) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail - return orderDetail, errors.New("not yet implemented") + return orderDetail, common.ErrNotYetImplemented } -// GetExchangeDepositAddress returns a deposit address for a specified currency -func ({{.Variable}} *{{.CapitalName}}) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { - return "", errors.New("not yet implemented") +// GetDepositAddress returns a deposit address for a specified currency +func ({{.Variable}} *{{.CapitalName}}) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted -func ({{.Variable}} *{{.CapitalName}}) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func ({{.Variable}} *{{.CapitalName}}) WithdrawCryptocurrencyFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is +// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted -func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatFunds(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } -// WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted -func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { - return "", errors.New("not yet implemented") +func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { + return "", common.ErrNotYetImplemented } // GetWebsocket returns a pointer to the exchange websocket func ({{.Variable}} *{{.CapitalName}}) GetWebsocket() (*exchange.Websocket, error) { - return nil, errors.New("not yet implemented") + return nil, common.ErrNotYetImplemented } {{end}}