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

View File

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

View File

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

View File

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