Remove unwanted wrapper name stuttering and standardise common error returns (#213)

This commit is contained in:
Ryan O'Hara-Reid
2018-11-23 12:55:00 +11:00
committed by Adrian Gallagher
parent c41f611d96
commit 92534249bf
154 changed files with 1362 additions and 1367 deletions

View File

@@ -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
}

View File

@@ -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"`

View File

@@ -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)
}

View File

@@ -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