minor improvements and bugfixes

1) reduce request content-type mismatch ambiguity
2) remove duplicate wrapper function for withdraw permissions
3) update exchange_template tool to add missing/incorrect wrapper funcs
This commit is contained in:
Adrian Gallagher
2019-02-27 14:43:23 +11:00
parent 3066f3d027
commit e000a8d6c7
32 changed files with 23 additions and 153 deletions

View File

@@ -213,11 +213,6 @@ func (a *Alphapoint) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, erro
return 0, common.ErrFunctionNotSupported
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (a *Alphapoint) GetWithdrawCapabilities() uint32 {
return a.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
// This function is not concurrency safe due to orderSide/orderType maps
func (a *Alphapoint) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {

View File

@@ -343,11 +343,6 @@ func (a *ANX) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return a.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (a *ANX) GetWithdrawCapabilities() uint32 {
return a.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (a *ANX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := a.GetOrderList(true)

View File

@@ -304,11 +304,6 @@ func (b *Binance) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
return b.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Binance) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Binance) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
if len(getOrdersRequest.Currencies) <= 0 {

View File

@@ -304,11 +304,6 @@ func (b *Bitfinex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
return b.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Bitfinex) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Bitfinex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var orders []exchange.OrderDetail

View File

@@ -211,11 +211,6 @@ func (b *Bitflyer) GetWebsocket() (*exchange.Websocket, error) {
return nil, common.ErrNotYetImplemented
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Bitflyer) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Bitflyer) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
return nil, common.ErrNotYetImplemented

View File

@@ -304,11 +304,6 @@ func (b *Bithumb) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
return b.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Bithumb) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Bithumb) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var orders []exchange.OrderDetail

View File

@@ -300,11 +300,6 @@ func (b *Bitmex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return b.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Bitmex) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
// This function is not concurrency safe due to orderSide/orderType maps
func (b *Bitmex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {

View File

@@ -287,11 +287,6 @@ func (b *Bitstamp) GetWebsocket() (*exchange.Websocket, error) {
return b.Websocket, nil
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Bitstamp) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Bitstamp) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var orders []exchange.OrderDetail

View File

@@ -284,11 +284,6 @@ func (b *Bittrex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *Bittrex) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Bittrex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var currPair string

View File

@@ -212,11 +212,6 @@ func (b *BTCC) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return b.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *BTCC) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *BTCC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
return nil, common.ErrNotYetImplemented

View File

@@ -306,11 +306,6 @@ func (b *BTCMarkets) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, erro
return b.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (b *BTCMarkets) GetWithdrawCapabilities() uint32 {
return b.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (b *BTCMarkets) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := b.GetOpenOrders()

View File

@@ -257,11 +257,6 @@ func (c *CoinbasePro) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, err
return c.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (c *CoinbasePro) GetWithdrawCapabilities() uint32 {
return c.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (c *CoinbasePro) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var respOrders []GeneralizedOrderResponse

View File

@@ -380,11 +380,6 @@ func (c *COINUT) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return c.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (c *COINUT) GetWithdrawCapabilities() uint32 {
return c.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (c *COINUT) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
instruments, err := c.GetInstruments()

View File

@@ -322,12 +322,12 @@ type IBotExchange interface {
GetOrderInfo(orderID int64) (OrderDetail, error)
GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error)
GetOrderHistory(GetOrdersRequest GetOrdersRequest) ([]OrderDetail, error)
GetOrderHistory(getOrdersRequest GetOrdersRequest) ([]OrderDetail, error)
GetActiveOrders(getOrdersRequest GetOrdersRequest) ([]OrderDetail, error)
WithdrawCryptocurrencyFunds(wtihdrawRequest WithdrawRequest) (string, error)
WithdrawFiatFunds(wtihdrawRequest WithdrawRequest) (string, error)
WithdrawFiatFundsToInternationalBank(wtihdrawRequest WithdrawRequest) (string, error)
WithdrawCryptocurrencyFunds(withdrawRequest WithdrawRequest) (string, error)
WithdrawFiatFunds(withdrawRequest WithdrawRequest) (string, error)
WithdrawFiatFundsToInternationalBank(withdrawRequest WithdrawRequest) (string, error)
GetWebsocket() (*Websocket, error)
}

View File

@@ -301,11 +301,6 @@ func (e *EXMO) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return e.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (e *EXMO) GetWithdrawCapabilities() uint32 {
return e.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (e *EXMO) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := e.GetOpenOrders()

View File

@@ -317,11 +317,6 @@ func (g *Gateio) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return g.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (g *Gateio) GetWithdrawCapabilities() uint32 {
return g.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (g *Gateio) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var currPair string

View File

@@ -239,11 +239,6 @@ func (g *Gemini) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return g.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (g *Gemini) GetWithdrawCapabilities() uint32 {
return g.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (g *Gemini) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := g.GetOrders()

View File

@@ -263,11 +263,6 @@ func (h *HitBTC) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return h.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (h *HitBTC) GetWithdrawCapabilities() uint32 {
return h.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (h *HitBTC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
if len(getOrdersRequest.Currencies) <= 0 {

View File

@@ -372,11 +372,6 @@ func (h *HUOBI) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return h.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (h *HUOBI) GetWithdrawCapabilities() uint32 {
return h.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (h *HUOBI) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
if len(getOrdersRequest.Currencies) <= 0 {

View File

@@ -337,11 +337,6 @@ func (h *HUOBIHADAX) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, erro
return h.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (h *HUOBIHADAX) GetWithdrawCapabilities() uint32 {
return h.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (h *HUOBIHADAX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
if len(getOrdersRequest.Currencies) <= 0 {

View File

@@ -278,11 +278,6 @@ func (i *ItBit) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return i.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (i *ItBit) GetWithdrawCapabilities() uint32 {
return i.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (i *ItBit) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
wallets, err := i.GetWallets(url.Values{})

View File

@@ -288,11 +288,6 @@ func (k *Kraken) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return k.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (k *Kraken) GetWithdrawCapabilities() uint32 {
return k.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (k *Kraken) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := k.GetOpenOrders(OrderInfoOptions{})

View File

@@ -261,11 +261,6 @@ func (l *LakeBTC) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
return l.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (l *LakeBTC) GetWithdrawCapabilities() uint32 {
return l.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (l *LakeBTC) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := l.GetOpenOrders()

View File

@@ -290,11 +290,6 @@ func (l *LocalBitcoins) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, e
return l.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (l *LocalBitcoins) GetWithdrawCapabilities() uint32 {
return l.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (l *LocalBitcoins) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := l.GetDashboardInfo()

View File

@@ -42,7 +42,7 @@ func (o *OKCoin) Run() {
prods, err := o.GetSpotInstruments()
if err != nil {
log.Errorf("OKEX failed to obtain available spot instruments. Err: %d", err)
log.Errorf("OKEX failed to obtain available spot instruments. Err: %s", err)
} else {
var pairs []string
for x := range prods {
@@ -327,11 +327,6 @@ func (o *OKCoin) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return o.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (o *OKCoin) GetWithdrawCapabilities() uint32 {
return o.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (o *OKCoin) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var allOrders []OrderInfo

View File

@@ -35,7 +35,7 @@ func (o *OKEX) Run() {
prods, err := o.GetSpotInstruments()
if err != nil {
log.Errorf("OKEX failed to obtain available spot instruments. Err: %d", err)
log.Errorf("OKEX failed to obtain available spot instruments. Err: %s", err)
return
}
@@ -320,11 +320,6 @@ func (o *OKEX) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return o.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (o *OKEX) GetWithdrawCapabilities() uint32 {
return o.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (o *OKEX) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var allOrders []OrderInfo

View File

@@ -287,11 +287,6 @@ func (p *Poloniex) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
return p.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (p *Poloniex) GetWithdrawCapabilities() uint32 {
return p.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (p *Poloniex) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
resp, err := p.GetOpenOrdersForAllCurrencies()

View File

@@ -310,8 +310,8 @@ func (r *Requester) DoRequest(req *http.Request, path string, body io.Reader, re
reader = resp.Body
default:
log.Warnf("encoding is not JSON for request response but receieved %v",
resp.Header.Get("Content-Type"))
log.Warnf("%s request response content type differs from JSON; received %v [path: %s]",
r.Name, resp.Header.Get("Content-Type"), path)
reader = resp.Body
}
}

View File

@@ -271,11 +271,6 @@ func (y *Yobit) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return y.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (y *Yobit) GetWithdrawCapabilities() uint32 {
return y.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
func (y *Yobit) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
var orders []exchange.OrderDetail

View File

@@ -292,11 +292,6 @@ func (z *ZB) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error) {
return z.GetFee(feeBuilder)
}
// GetWithdrawCapabilities returns the types of withdrawal methods permitted by the exchange
func (z *ZB) GetWithdrawCapabilities() uint32 {
return z.GetWithdrawPermissions()
}
// GetActiveOrders retrieves any orders that are active/open
// This function is not concurrency safe due to orderSide/orderType maps
func (z *ZB) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {

View File

@@ -219,7 +219,7 @@ func main() {
fmt.Println("Update the config_test.go file")
fmt.Println("Test config.go")
fmt.Println("Open a pull request")
fmt.Println("If help is needed please post a message on the slack.")
fmt.Println("If help is needed please post a message on Slack.")
}
func newFile(path string) {

View File

@@ -2,10 +2,9 @@
package {{.Name}}
import (
"errors"
"sync"
{{if .WS}} "github.com/thrasher-/gocryptotrader/common" {{end}}
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
@@ -102,13 +101,13 @@ func ({{.Variable}} *{{.CapitalName}}) UpdateOrderbook(p pair.CurrencyPair, asse
// GetAccountInfo retrieves balances for all enabled currencies for the
// {{.CapitalName}} exchange
func ({{.Variable}} *{{.CapitalName}}) GetAccountInfo() (exchange.AccountInfo, error) {
return exchange.AccountInfo{}, errors.New("not implemented")
return exchange.AccountInfo{}, common.ErrNotYetImplemented
}
// GetFundingHistory returns funding history, deposits and
// withdrawals
func ({{.Variable}} *{{.CapitalName}}) GetFundingHistory() ([]exchange.FundHistory, error) {
return nil, common.ErrFunctionNotSupported
return nil, common.ErrNotYetImplemented
}
// GetExchangeHistory returns historic trade data since exchange opening.
@@ -170,4 +169,15 @@ func ({{.Variable}} *{{.CapitalName}}) GetWebsocket() (*exchange.Websocket, erro
return nil, common.ErrNotYetImplemented
}
// GetActiveOrders retrieves any orders that are active/open
func ({{.Variable}} *{{.CapitalName}}) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
return nil, common.ErrNotYetImplemented
}
// GetOrderHistory retrieves account order information
// Can Limit response to specific order status
func ({{.Variable}} *{{.CapitalName}}) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
return nil, common.ErrNotYetImplemented
}
{{end}}