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

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

View File

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

View File

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