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 := b.GetExchangeAccountInfo()
accountInfo, err := b.GetAccountInfo()
if err != nil {
// Handle error
}

View File

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

View File

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

View File

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