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

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

View File

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

View File

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

View File

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