mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 15:10:40 +00:00
Remove unwanted wrapper name stuttering and standardise common error returns (#213)
This commit is contained in:
committed by
Adrian Gallagher
parent
c41f611d96
commit
92534249bf
@@ -72,7 +72,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
|
||||
}
|
||||
|
||||
@@ -489,8 +489,8 @@ func (b *Bitfinex) GetSymbolsDetails() ([]SymbolDetails, error) {
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
}
|
||||
|
||||
// GetAccountInfo returns information about your account incl. trading fees
|
||||
func (b *Bitfinex) GetAccountInfo() ([]AccountInfo, error) {
|
||||
// GetAccountInformation returns information about your account incl. trading fees
|
||||
func (b *Bitfinex) GetAccountInformation() ([]AccountInfo, error) {
|
||||
|
||||
var responses []AccountInfo
|
||||
err := b.SendAuthenticatedHTTPRequest("POST", bitfinexAccountInfo, nil, &responses)
|
||||
@@ -628,8 +628,8 @@ func (b *Bitfinex) NewOrderMulti(orders []PlaceOrder) (OrderMultiResponse, error
|
||||
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderNewMulti, request, &response)
|
||||
}
|
||||
|
||||
// CancelOrder cancels a single order
|
||||
func (b *Bitfinex) CancelOrder(OrderID int64) (Order, error) {
|
||||
// CancelExistingOrder cancels a single order by OrderID
|
||||
func (b *Bitfinex) CancelExistingOrder(OrderID int64) (Order, error) {
|
||||
response := Order{}
|
||||
request := make(map[string]interface{})
|
||||
request["order_id"] = OrderID
|
||||
@@ -648,8 +648,8 @@ func (b *Bitfinex) CancelMultipleOrders(OrderIDs []int64) (string, error) {
|
||||
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderCancelMulti, request, nil)
|
||||
}
|
||||
|
||||
// CancelAllOrders cancels all active and open orders
|
||||
func (b *Bitfinex) CancelAllOrders() (string, error) {
|
||||
// CancelAllExistingOrders cancels all active and open orders
|
||||
func (b *Bitfinex) CancelAllExistingOrders() (string, error) {
|
||||
response := GenericResponse{}
|
||||
|
||||
return response.Result,
|
||||
@@ -925,7 +925,7 @@ func (b *Bitfinex) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
|
||||
|
||||
switch feeBuilder.FeeType {
|
||||
case exchange.CryptocurrencyTradeFee:
|
||||
accountInfos, err := b.GetAccountInfo()
|
||||
accountInfos, err := b.GetAccountInformation()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -383,15 +383,15 @@ func TestNewOrderMulti(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCancelOrder(t *testing.T) {
|
||||
func TestCancelExistingOrder(t *testing.T) {
|
||||
if b.APIKey == "" || b.APISecret == "" {
|
||||
t.SkipNow()
|
||||
}
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.CancelOrder(1337)
|
||||
_, err := b.CancelExistingOrder(1337)
|
||||
if err == nil {
|
||||
t.Error("Test Failed - CancelOrder() error")
|
||||
t.Error("Test Failed - CancelExistingOrder() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,15 +407,15 @@ func TestCancelMultipleOrders(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCancelAllOrders(t *testing.T) {
|
||||
func TestCancelAllExistingOrders(t *testing.T) {
|
||||
if b.APIKey == "" || b.APISecret == "" {
|
||||
t.SkipNow()
|
||||
}
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.CancelAllOrders()
|
||||
_, err := b.CancelAllExistingOrders()
|
||||
if err == nil {
|
||||
t.Error("Test Failed - CancelAllOrders() error")
|
||||
t.Error("Test Failed - CancelAllExistingOrders() error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,7 +737,7 @@ func TestSubmitOrder(t *testing.T) {
|
||||
FirstCurrency: symbol.LTC,
|
||||
SecondCurrency: symbol.BTC,
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package bitfinex
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
@@ -113,9 +112,9 @@ func (b *Bitfinex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (order
|
||||
return orderbook.GetOrderbook(b.Name, p, assetType)
|
||||
}
|
||||
|
||||
// GetExchangeAccountInfo retrieves balances for all enabled currencies on the
|
||||
// GetAccountInfo retrieves balances for all enabled currencies on the
|
||||
// Bitfinex exchange
|
||||
func (b *Bitfinex) GetExchangeAccountInfo() (exchange.AccountInfo, error) {
|
||||
func (b *Bitfinex) GetAccountInfo() (exchange.AccountInfo, error) {
|
||||
var response exchange.AccountInfo
|
||||
response.ExchangeName = b.GetName()
|
||||
accountBalance, err := b.GetAccountBalance()
|
||||
@@ -160,22 +159,22 @@ func (b *Bitfinex) GetExchangeAccountInfo() (exchange.AccountInfo, error) {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// GetExchangeFundTransferHistory returns funding history, deposits and
|
||||
// GetFundingHistory returns funding history, deposits and
|
||||
// withdrawals
|
||||
func (b *Bitfinex) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) {
|
||||
func (b *Bitfinex) 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 (b *Bitfinex) 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 *Bitfinex) 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 *Bitfinex) 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
|
||||
|
||||
@@ -196,48 +195,48 @@ func (b *Bitfinex) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderS
|
||||
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 *Bitfinex) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, errors.New("not yet implemented")
|
||||
func (b *Bitfinex) ModifyOrder(orderID int64, action exchange.ModifyOrder) (int64, error) {
|
||||
return 0, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelExchangeOrder cancels an order by its corresponding ID number
|
||||
func (b *Bitfinex) CancelExchangeOrder(orderID int64) error {
|
||||
return errors.New("not yet implemented")
|
||||
// CancelOrder cancels an order by its corresponding ID number
|
||||
func (b *Bitfinex) CancelOrder(orderID int64) error {
|
||||
return common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// CancelAllExchangeOrders cancels all orders associated with a currency pair
|
||||
func (b *Bitfinex) CancelAllExchangeOrders() error {
|
||||
return errors.New("not yet implemented")
|
||||
// CancelAllOrders cancels all orders associated with a currency pair
|
||||
func (b *Bitfinex) CancelAllOrders() error {
|
||||
return common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// GetExchangeOrderInfo returns information on a current open order
|
||||
func (b *Bitfinex) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) {
|
||||
// GetOrderInfo returns information on a current open order
|
||||
func (b *Bitfinex) 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 *Bitfinex) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) {
|
||||
return "", errors.New("not yet implemented")
|
||||
// GetDepositAddress returns a deposit address for a specified currency
|
||||
func (b *Bitfinex) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) {
|
||||
return "", common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted
|
||||
func (b *Bitfinex) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) {
|
||||
return "", errors.New("not yet implemented")
|
||||
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted
|
||||
func (b *Bitfinex) 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 (b *Bitfinex) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) {
|
||||
return "", errors.New("not yet implemented")
|
||||
func (b *Bitfinex) 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 (b *Bitfinex) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) {
|
||||
return "", errors.New("not yet implemented")
|
||||
func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) {
|
||||
return "", common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
// GetWebsocket returns a pointer to the exchange websocket
|
||||
|
||||
Reference in New Issue
Block a user