Makefile: add new recipes and linter features (#244)

* Makefile: add new recipes and linter features

* expand linter coverage and fix issues

* Update makefile

* address PR nitterinos
This commit is contained in:
Adrian Gallagher
2019-01-31 14:53:24 +11:00
committed by GitHub
parent e182248387
commit 291e404a4a
85 changed files with 306 additions and 393 deletions

View File

@@ -21,6 +21,6 @@ matrix:
install: true
script:
- go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- make check
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@@ -1,8 +1,50 @@
LDFLAGS = -ldflags "-w -s"
GCTPKG = github.com/thrasher-/gocryptotrader
LINTPKG = gopkg.in/alecthomas/gometalinter.v2
LINTBIN = $(GOPATH)/bin/gometalinter.v2
ENABLELLL = false
LINTOPTS = \
--disable-all \
--enable=gofmt \
--enable=vet \
--enable=vetshadow \
--enable=misspell \
--enable=golint \
--enable=ineffassign \
--enable=goconst \
--enable=structcheck \
--enable=unparam \
--enable=gosimple \
--enable=unconvert
ifeq ($(ENABLELLL), true)
LINTOPTS += \
--enable=lll \
--line-length=80
endif
LINTOPTS += \
--deadline=5m ./... | \
grep -v 'ALL_CAPS\|OP_' 2>&1 | \
tee /dev/stderr
get:
dep ensure
GO111MODULE=on go get $(GCTPKG)
linter:
GO111MODULE=on go get $(GCTPKG)
GO111MODULE=off go get -u $(LINTPKG)
$(LINTBIN) --install
test -z "$$($(LINTBIN) $(LINTOPTS))"
check: linter test
test:
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
build:
go build .
GO111MODULE=on go build $(LDFLAGS)
install:
go install
GO111MODULE=on go install $(LDFLAGS)
fmt:
gofmt -l -w -s $(shell find . -type f -name '*.go')

View File

@@ -60,7 +60,7 @@ const (
func initialiseHTTPClient() {
// If the HTTPClient isn't set, start a new client with a default timeout of 15 seconds
if HTTPClient == nil {
HTTPClient = NewHTTPClientWithTimeout(time.Duration(time.Second * 15))
HTTPClient = NewHTTPClientWithTimeout(time.Second * 15)
}
}
@@ -138,7 +138,7 @@ func GetHMAC(hashType int, input, key []byte) []byte {
}
}
hmac := hmac.New(hash, []byte(key))
hmac := hmac.New(hash, key)
hmac.Write(input)
return hmac.Sum(nil)
}

View File

@@ -217,7 +217,7 @@ func (s *Slack) WebsocketReader() {
}
case "hello":
s.handleHelloResponse(data)
s.handleHelloResponse()
case "reconnect_url":
err = s.handleReconnectResponse(resp)
@@ -301,7 +301,7 @@ func (s *Slack) handleErrorResponse(data WebsocketResponse) error {
return fmt.Errorf("Unknown error '%s'", data.Error.Msg)
}
func (s *Slack) handleHelloResponse(data WebsocketResponse) {
func (s *Slack) handleHelloResponse() {
if s.Verbose {
log.Debugln("Websocket connected successfully.")
}

View File

@@ -311,8 +311,7 @@ func TestHandleErrorResponse(t *testing.T) {
}
func TestHandleHelloResponse(t *testing.T) {
var data WebsocketResponse
s.handleHelloResponse(data)
s.handleHelloResponse()
}
func TestHandleReconnectResponse(t *testing.T) {

View File

@@ -31,7 +31,7 @@ const (
configFileEncryptionEnabled = 1
configFileEncryptionDisabled = -1
configPairsLastUpdatedWarningThreshold = 30 // 30 days
configDefaultHTTPTimeout = time.Duration(time.Second * 15)
configDefaultHTTPTimeout = time.Second * 15
configMaxAuthFailres = 3
)
@@ -326,7 +326,7 @@ func (c *Config) CheckClientBankAccounts() error {
}
for i := range c.BankAccounts {
if c.BankAccounts[i].Enabled == true {
if c.BankAccounts[i].Enabled {
if c.BankAccounts[i].BankName == "" || c.BankAccounts[i].BankAddress == "" {
return fmt.Errorf("banking details for %s is enabled but variables not set correctly",
c.BankAccounts[i].BankName)
@@ -764,7 +764,7 @@ func (c *Config) CheckExchangeConfigValues() error {
c.Exchanges[i].BankAccounts = append(c.Exchanges[i].BankAccounts, BankAccount{})
} else {
for _, bankAccount := range exch.BankAccounts {
if bankAccount.Enabled == true {
if bankAccount.Enabled {
if bankAccount.BankName == "" || bankAccount.BankAddress == "" {
return fmt.Errorf("banking details for %s is enabled but variables not set",
exch.Name)
@@ -855,7 +855,7 @@ func (c *Config) CheckCurrencyConfigValues() error {
count := 0
for i := range c.Currency.ForexProviders {
if c.Currency.ForexProviders[i].Enabled == true {
if c.Currency.ForexProviders[i].Enabled {
if c.Currency.ForexProviders[i].APIKey == "Key" {
log.Warnf("%s forex provider API key not set. Please set this in your config.json file", c.Currency.ForexProviders[i].Name)
c.Currency.ForexProviders[i].Enabled = false

View File

@@ -169,7 +169,8 @@ func ConvertCurrency(amount float64, from, to string) (float64, error) {
// check to see if we're converting from the base currency
if to == baseCurr {
resultFrom, ok := FXRates[baseCurr+from]
var ok bool
resultFrom, ok = FXRates[baseCurr+from]
if !ok {
return 0, fmt.Errorf("Currency conversion failed. Unable to find %s in currency map [%s -> %s]", from, from, to)
}
@@ -178,7 +179,8 @@ func ConvertCurrency(amount float64, from, to string) (float64, error) {
// Check to see if we're converting from the base currency
if from == baseCurr {
resultTo, ok := FXRates[baseCurr+to]
var ok bool
resultTo, ok = FXRates[baseCurr+to]
if !ok {
return 0, fmt.Errorf("Currency conversion failed. Unable to find %s in currency map [%s -> %s]", to, from, to)
}

View File

@@ -34,7 +34,10 @@ func TestSeedCurrencyData(t *testing.T) {
}
func TestGetExchangeRates(t *testing.T) {
result := GetExchangeRates()
result := make(map[string]float64)
for k, v := range GetExchangeRates() {
result[k] = v
}
backup := FXRates
FXRates = nil

View File

@@ -20,6 +20,8 @@ const (
APIEndpointCurrencies = "currencies"
APIEndpointCountries = "countries"
APIEndpointUsage = "usage"
defaultAPIKey = "Key"
)
// CurrencyConverter stores the struct for the CurrencyConverter API
@@ -93,7 +95,7 @@ func (c *CurrencyConverter) GetRates(baseCurrency, symbols string) (map[string]f
// ConvertMany takes 2 or more currencies depending on if using the free
// or paid API
func (c *CurrencyConverter) ConvertMany(currencies []string) (map[string]float64, error) {
if len(currencies) > 2 && (c.APIKey == "" || c.APIKey == "Key") {
if len(currencies) > 2 && (c.APIKey == "" || c.APIKey == defaultAPIKey) {
return nil, errors.New("currency fetching is limited to two currencies per request")
}
@@ -156,7 +158,7 @@ func (c *CurrencyConverter) GetCountries() (map[string]CountryItem, error) {
func (c *CurrencyConverter) SendHTTPRequest(endPoint string, values url.Values, result interface{}) error {
var path string
if c.APIKey == "" || c.APIKey == "Key" {
if c.APIKey == "" || c.APIKey == defaultAPIKey {
path = fmt.Sprintf("%s%s/%s?", APIEndpointFreeURL, APIEndpointVersion, endPoint)
} else {
path = fmt.Sprintf("%s%s%s?", APIEndpointURL, APIEndpointVersion, endPoint)

View File

@@ -52,7 +52,7 @@ const (
BAT = "BAT"
ETP = "ETP"
HOT = "HOT"
STRAT = "STRAT"
STRAT = "STRAT" // nolint: misspell
GNT = "GNT"
REP = "REP"
SNT = "SNT"

View File

@@ -30,8 +30,5 @@ func GetTranslation(currency pair.CurrencyItem) (pair.CurrencyItem, error) {
// HasTranslation returns whether or not a particular currency has a translation
func HasTranslation(currency pair.CurrencyItem) bool {
_, err := GetTranslation(currency)
if err != nil {
return false
}
return true
return (err == nil)
}

View File

@@ -613,7 +613,7 @@ func TestWithdraw(t *testing.T) {
_, err := a.WithdrawCryptocurrencyFunds(withdrawCryptoRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not implemented', recieved %v", err)
t.Errorf("Expected 'Not implemented', received %v", err)
}
}
@@ -629,7 +629,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := a.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
}
@@ -645,6 +645,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := a.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
}

View File

@@ -420,10 +420,8 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
request["nonce"] = a.Nonce.String()[0:13]
path = fmt.Sprintf("api/%s/%s", anxAPIVersion, path)
if params != nil {
for key, value := range params {
request[key] = value
}
for key, value := range params {
request[key] = value
}
PayloadJSON, err := common.JSONEncode(request)
@@ -438,7 +436,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
hmac := common.GetHMAC(common.HashSHA512, []byte(path+string("\x00")+string(PayloadJSON)), []byte(a.APISecret))
headers := make(map[string]string)
headers["Rest-Key"] = a.APIKey
headers["Rest-Sign"] = common.Base64Encode([]byte(hmac))
headers["Rest-Sign"] = common.Base64Encode(hmac)
headers["Content-Type"] = "application/json"
return a.SendPayload("POST", a.APIUrl+path, headers, bytes.NewBuffer(PayloadJSON), result, true, a.Verbose)

View File

@@ -376,7 +376,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := a.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -392,7 +392,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := a.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -208,7 +208,6 @@ func (b *Binance) GetOrderBook(obd OrderBookDataRequestParams) (OrderBook, error
case 1:
ASK.Quantity, _ = strconv.ParseFloat(ask.(string), 64)
orderbook.Asks = append(orderbook.Asks, ASK)
break
}
}
}
@@ -225,7 +224,6 @@ func (b *Binance) GetOrderBook(obd OrderBookDataRequestParams) (OrderBook, error
case 1:
BID.Quantity, _ = strconv.ParseFloat(bid.(string), 64)
orderbook.Bids = append(orderbook.Bids, BID)
break
}
}
}
@@ -706,7 +704,7 @@ func (b *Binance) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
}
fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount, multiplier)
case exchange.CryptocurrencyWithdrawalFee:
fee = getCryptocurrencyWithdrawalFee(feeBuilder.FirstCurrency, feeBuilder.PurchasePrice, feeBuilder.Amount)
fee = getCryptocurrencyWithdrawalFee(feeBuilder.FirstCurrency)
}
if fee < 0 {
fee = 0
@@ -735,7 +733,7 @@ func calculateTradingFee(purchasePrice, amount, multiplier float64) float64 {
}
// getCryptocurrencyWithdrawalFee returns the fee for withdrawing from the exchange
func getCryptocurrencyWithdrawalFee(currency string, purchasePrice, amount float64) float64 {
func getCryptocurrencyWithdrawalFee(currency string) float64 {
return WithdrawalFees[currency]
}
@@ -746,13 +744,13 @@ func (b *Binance) WithdrawCrypto(asset, address, addressTag, name, amount string
params := url.Values{}
params.Set("asset", asset)
params.Set("address", string(address))
params.Set("amount", string(amount))
params.Set("address", address)
params.Set("amount", amount)
if len(name) > 0 {
params.Set("name", string(name))
params.Set("name", name)
}
if len(addressTag) > 0 {
params.Set("addressTag", string(addressTag))
params.Set("addressTag", addressTag)
}
if err := b.SendAuthHTTPRequest("POST", path, params, &resp); err != nil {

View File

@@ -471,7 +471,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := b.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -487,7 +487,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -15,6 +15,7 @@ import (
"github.com/thrasher-/gocryptotrader/currency/pair"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
const (
@@ -60,7 +61,7 @@ func (b *Binance) SeedLocalCache(p pair.CurrencyPair) error {
newOrderBook.Pair = pair.NewCurrencyPairFromString(formattedPair.String())
newOrderBook.CurrencyPair = formattedPair.String()
newOrderBook.LastUpdated = time.Now()
newOrderBook.AssetType = "SPOT"
newOrderBook.AssetType = ticker.Spot
return b.Websocket.Orderbook.LoadSnapshot(newOrderBook, b.GetName(), false)
}
@@ -155,17 +156,18 @@ func (b *Binance) WSConnect() error {
depth
if b.Websocket.GetProxyAddress() != "" {
url, err := url.Parse(b.Websocket.GetProxyAddress())
var u *url.URL
u, err = url.Parse(b.Websocket.GetProxyAddress())
if err != nil {
return fmt.Errorf("binance_websocket.go - Unable to connect to parse proxy address. Error: %s",
err)
}
Dialer.Proxy = http.ProxyURL(url)
Dialer.Proxy = http.ProxyURL(u)
}
for _, ePair := range b.GetEnabledCurrencies() {
err := b.SeedLocalCache(ePair)
err = b.SeedLocalCache(ePair)
if err != nil {
return err
}
@@ -264,9 +266,9 @@ func (b *Binance) WsHandleData() {
continue
} else if strings.Contains(multiStreamData.Stream, "ticker") {
ticker := TickerStream{}
t := TickerStream{}
err := common.JSONDecode(multiStreamData.Data, &ticker)
err := common.JSONDecode(multiStreamData.Data, &t)
if err != nil {
b.Websocket.DataHandler <- fmt.Errorf("binance_websocket.go - Could not convert to a TickerStream structure %s",
err.Error())
@@ -275,15 +277,15 @@ func (b *Binance) WsHandleData() {
var wsTicker exchange.TickerData
wsTicker.Timestamp = time.Unix(0, ticker.EventTime)
wsTicker.Pair = pair.NewCurrencyPairFromString(ticker.Symbol)
wsTicker.AssetType = "SPOT"
wsTicker.Timestamp = time.Unix(0, t.EventTime)
wsTicker.Pair = pair.NewCurrencyPairFromString(t.Symbol)
wsTicker.AssetType = ticker.Spot
wsTicker.Exchange = b.GetName()
wsTicker.ClosePrice, _ = strconv.ParseFloat(ticker.CurrDayClose, 64)
wsTicker.Quantity, _ = strconv.ParseFloat(ticker.TotalTradedVolume, 64)
wsTicker.OpenPrice, _ = strconv.ParseFloat(ticker.OpenPrice, 64)
wsTicker.HighPrice, _ = strconv.ParseFloat(ticker.HighPrice, 64)
wsTicker.LowPrice, _ = strconv.ParseFloat(ticker.LowPrice, 64)
wsTicker.ClosePrice, _ = strconv.ParseFloat(t.CurrDayClose, 64)
wsTicker.Quantity, _ = strconv.ParseFloat(t.TotalTradedVolume, 64)
wsTicker.OpenPrice, _ = strconv.ParseFloat(t.OpenPrice, 64)
wsTicker.HighPrice, _ = strconv.ParseFloat(t.HighPrice, 64)
wsTicker.LowPrice, _ = strconv.ParseFloat(t.LowPrice, 64)
b.Websocket.DataHandler <- wsTicker
continue
@@ -302,7 +304,7 @@ func (b *Binance) WsHandleData() {
wsKline.Timestamp = time.Unix(0, kline.EventTime)
wsKline.Pair = pair.NewCurrencyPairFromString(kline.Symbol)
wsKline.AssetType = "SPOT"
wsKline.AssetType = ticker.Spot
wsKline.Exchange = b.GetName()
wsKline.StartTime = time.Unix(0, kline.Kline.StartTime)
wsKline.CloseTime = time.Unix(0, kline.Kline.CloseTime)

View File

@@ -934,10 +934,8 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[
request["request"] = fmt.Sprintf("%s%s", bitfinexAPIVersion, path)
request["nonce"] = b.Nonce.String()
if params != nil {
for key, value := range params {
request[key] = value
}
for key, value := range params {
request[key] = value
}
PayloadJSON, err := common.JSONEncode(request)

View File

@@ -135,7 +135,8 @@ func (b *Bitfinex) WsConnect() error {
var err error
if b.Websocket.GetProxyAddress() != "" {
proxy, err := url.Parse(b.Websocket.GetProxyAddress())
var proxy *url.URL
proxy, err = url.Parse(b.Websocket.GetProxyAddress())
if err != nil {
return err
}
@@ -171,7 +172,7 @@ func (b *Bitfinex) WsConnect() error {
params["prec"] = "P0"
}
params["pair"] = y
err := b.WsSubscribe(x, params)
err = b.WsSubscribe(x, params)
if err != nil {
return err
}

View File

@@ -271,12 +271,12 @@ func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (
var withdrawalSuccesses string
var withdrawalErrors string
for _, withdrawl := range resp {
if withdrawl.Status == "error" {
withdrawalErrors += fmt.Sprintf("%v ", withdrawl.Message)
for _, withdrawal := range resp {
if withdrawal.Status == "error" {
withdrawalErrors += fmt.Sprintf("%v ", withdrawal.Message)
}
if withdrawl.Status == "success" {
withdrawalSuccesses += fmt.Sprintf("%v,", withdrawl.WithdrawalID)
if withdrawal.Status == "success" {
withdrawalSuccesses += fmt.Sprintf("%v,", withdrawal.WithdrawalID)
}
}
if len(withdrawalErrors) > 0 {

View File

@@ -386,7 +386,7 @@ func (b *Bitflyer) SendHTTPRequest(path string, result interface{}) error {
func (b *Bitflyer) SendAuthHTTPRequest(path string, params url.Values, result interface{}) {
headers := make(map[string]string)
headers["ACCESS-KEY"] = b.APIKey
headers["ACCESS-TIMESTAMP"] = strconv.FormatInt(int64(time.Now().UnixNano()), 10)
headers["ACCESS-TIMESTAMP"] = strconv.FormatInt(time.Now().UnixNano(), 10)
}
// GetFee returns an estimate of fee based on type of transaction
@@ -398,7 +398,7 @@ func (b *Bitflyer) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
case exchange.CryptocurrencyTradeFee:
fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount)
case exchange.InternationalBankDepositFee:
fee = getDepositFee(feeBuilder.BankTransactionType, feeBuilder.CurrencyItem, feeBuilder.Amount)
fee = getDepositFee(feeBuilder.BankTransactionType, feeBuilder.CurrencyItem)
case exchange.InternationalBankWithdrawalFee:
fee = getWithdrawalFee(feeBuilder.BankTransactionType, feeBuilder.CurrencyItem, feeBuilder.Amount)
}
@@ -415,7 +415,7 @@ func calculateTradingFee(purchasePrice float64, amount float64) float64 {
return fee * amount * purchasePrice
}
func getDepositFee(bankTransactionType exchange.InternationalBankTransactionType, currency string, amount float64) (fee float64) {
func getDepositFee(bankTransactionType exchange.InternationalBankTransactionType, currency string) (fee float64) {
switch bankTransactionType {
case exchange.WireTransfer:
switch currency {

View File

@@ -274,7 +274,7 @@ func TestSubmitOrder(t *testing.T) {
}
_, err := b.SubmitOrder(p, exchange.Buy, exchange.Market, 1, 1, "clientId")
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -299,7 +299,7 @@ func TestCancelExchangeOrder(t *testing.T) {
err := b.CancelOrder(orderCancellation)
// Assert
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -324,7 +324,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
_, err := b.CancelAllOrders(orderCancellation)
// Assert
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -344,7 +344,7 @@ func TestWithdraw(t *testing.T) {
_, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -367,7 +367,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := b.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
}
@@ -383,6 +383,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
}

View File

@@ -479,7 +479,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -228,10 +228,7 @@ func (b *Bithumb) CancelAllOrders(orderCancellation exchange.OrderCancellation)
if err != nil {
return cancelAllOrdersResponse, err
}
for _, order := range orders.Data {
allOrders = append(allOrders, order)
}
allOrders = append(allOrders, orders.Data...)
}
for _, order := range allOrders {

View File

@@ -110,10 +110,7 @@ func (p APIKeyParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p APIKeyParams) IsNil() bool {
if p == (APIKeyParams{}) {
return true
}
return false
return p == (APIKeyParams{})
}
// ChatGetParams contains all the parameters to send to the API endpoint
@@ -148,10 +145,7 @@ func (p ChatGetParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p ChatGetParams) IsNil() bool {
if p == (ChatGetParams{}) {
return true
}
return false
return p == (ChatGetParams{})
}
// ChatSendParams contains all the parameters to send to the API endpoint
@@ -179,10 +173,7 @@ func (p ChatSendParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p ChatSendParams) IsNil() bool {
if p == (ChatSendParams{}) {
return true
}
return false
return p == (ChatSendParams{})
}
// GenericRequestParams contains all the parameters for some general functions
@@ -239,10 +230,7 @@ func (p GenericRequestParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p GenericRequestParams) IsNil() bool {
if p == (GenericRequestParams{}) {
return true
}
return false
return p == (GenericRequestParams{})
}
// LeaderboardGetParams contains all the parameters to send to the API endpoint
@@ -264,10 +252,7 @@ func (p LeaderboardGetParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p LeaderboardGetParams) IsNil() bool {
if p == (LeaderboardGetParams{}) {
return true
}
return false
return p == (LeaderboardGetParams{})
}
// OrderNewParams contains all the parameters to send to the API endpoint
@@ -359,10 +344,7 @@ func (p OrderNewParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderNewParams) IsNil() bool {
if p == (OrderNewParams{}) {
return true
}
return false
return p == (OrderNewParams{})
}
// OrderAmendParams contains all the parameters to send to the API endpoint
@@ -427,10 +409,7 @@ func (p OrderAmendParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderAmendParams) IsNil() bool {
if p == (OrderAmendParams{}) {
return true
}
return false
return p == (OrderAmendParams{})
}
// OrderCancelParams contains all the parameters to send to the API endpoint
@@ -458,10 +437,7 @@ func (p OrderCancelParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderCancelParams) IsNil() bool {
if p == (OrderCancelParams{}) {
return true
}
return false
return p == (OrderCancelParams{})
}
// OrderCancelAllParams contains all the parameters to send to the API endpoint
@@ -492,10 +468,7 @@ func (p OrderCancelAllParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderCancelAllParams) IsNil() bool {
if p == (OrderCancelAllParams{}) {
return true
}
return false
return p == (OrderCancelAllParams{})
}
// OrderAmendBulkParams contains all the parameters to send to the API endpoint
@@ -517,10 +490,7 @@ func (p OrderAmendBulkParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderAmendBulkParams) IsNil() bool {
if len(p.Orders) == 0 {
return true
}
return false
return len(p.Orders) == 0
}
// OrderNewBulkParams contains all the parameters to send to the API endpoint
@@ -542,10 +512,7 @@ func (p OrderNewBulkParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderNewBulkParams) IsNil() bool {
if len(p.Orders) == 0 {
return true
}
return false
return len(p.Orders) == 0
}
// OrderCancelAllAfterParams contains all the parameters to send to the API
@@ -568,10 +535,7 @@ func (p OrderCancelAllAfterParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderCancelAllAfterParams) IsNil() bool {
if p == (OrderCancelAllAfterParams{}) {
return true
}
return false
return p == (OrderCancelAllAfterParams{})
}
// OrderClosePositionParams contains all the parameters to send to the API
@@ -597,10 +561,7 @@ func (p OrderClosePositionParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderClosePositionParams) IsNil() bool {
if p == (OrderClosePositionParams{}) {
return true
}
return false
return p == (OrderClosePositionParams{})
}
// OrderBookGetL2Params contains all the parameters to send to the API endpoint
@@ -630,10 +591,7 @@ func (p OrderBookGetL2Params) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p OrderBookGetL2Params) IsNil() bool {
if p == (OrderBookGetL2Params{}) {
return true
}
return false
return p == (OrderBookGetL2Params{})
}
// PositionGetParams contains all the parameters to send to the API endpoint
@@ -662,10 +620,7 @@ func (p PositionGetParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p PositionGetParams) IsNil() bool {
if p == (PositionGetParams{}) {
return true
}
return false
return p == (PositionGetParams{})
}
// PositionIsolateMarginParams contains all the parameters to send to the API
@@ -691,10 +646,7 @@ func (p PositionIsolateMarginParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p PositionIsolateMarginParams) IsNil() bool {
if p == (PositionIsolateMarginParams{}) {
return true
}
return false
return p == (PositionIsolateMarginParams{})
}
// PositionUpdateLeverageParams contains all the parameters to send to the API
@@ -721,10 +673,7 @@ func (p PositionUpdateLeverageParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p PositionUpdateLeverageParams) IsNil() bool {
if p == (PositionUpdateLeverageParams{}) {
return true
}
return false
return p == (PositionUpdateLeverageParams{})
}
// PositionUpdateRiskLimitParams contains all the parameters to send to the API
@@ -750,10 +699,7 @@ func (p PositionUpdateRiskLimitParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p PositionUpdateRiskLimitParams) IsNil() bool {
if p == (PositionUpdateRiskLimitParams{}) {
return true
}
return false
return p == (PositionUpdateRiskLimitParams{})
}
// PositionTransferIsolatedMarginParams contains all the parameters to send to
@@ -779,10 +725,7 @@ func (p PositionTransferIsolatedMarginParams) ToURLVals(path string) (string, er
// IsNil checks to see if any values has been set for the paramater
func (p PositionTransferIsolatedMarginParams) IsNil() bool {
if p == (PositionTransferIsolatedMarginParams{}) {
return true
}
return false
return p == (PositionTransferIsolatedMarginParams{})
}
// QuoteGetBucketedParams contains all the parameters to send to the API
@@ -842,10 +785,7 @@ func (p QuoteGetBucketedParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p QuoteGetBucketedParams) IsNil() bool {
if p == (QuoteGetBucketedParams{}) {
return true
}
return false
return p == (QuoteGetBucketedParams{})
}
// TradeGetBucketedParams contains all the parameters to send to the API
@@ -906,10 +846,7 @@ func (p TradeGetBucketedParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p TradeGetBucketedParams) IsNil() bool {
if p == (TradeGetBucketedParams{}) {
return true
}
return false
return p == (TradeGetBucketedParams{})
}
// UserUpdateParams contains all the parameters to send to the API endpoint
@@ -946,10 +883,7 @@ func (p UserUpdateParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserUpdateParams) IsNil() bool {
if p == (UserUpdateParams{}) {
return true
}
return false
return p == (UserUpdateParams{})
}
// UserTokenParams contains all the parameters to send to the API endpoint
@@ -970,10 +904,7 @@ func (p UserTokenParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserTokenParams) IsNil() bool {
if p == (UserTokenParams{}) {
return true
}
return false
return p == (UserTokenParams{})
}
// UserCheckReferralCodeParams contains all the parameters to send to the API
@@ -995,10 +926,7 @@ func (p UserCheckReferralCodeParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserCheckReferralCodeParams) IsNil() bool {
if p == (UserCheckReferralCodeParams{}) {
return true
}
return false
return p == (UserCheckReferralCodeParams{})
}
// UserConfirmTFAParams contains all the parameters to send to the API endpoint
@@ -1024,10 +952,7 @@ func (p UserConfirmTFAParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserConfirmTFAParams) IsNil() bool {
if p == (UserConfirmTFAParams{}) {
return true
}
return false
return p == (UserConfirmTFAParams{})
}
// UserCurrencyParams contains all the parameters to send to the API endpoint
@@ -1048,10 +973,7 @@ func (p UserCurrencyParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserCurrencyParams) IsNil() bool {
if p == (UserCurrencyParams{}) {
return true
}
return false
return p == (UserCurrencyParams{})
}
// UserPreferencesParams contains all the parameters to send to the API
@@ -1076,10 +998,7 @@ func (p UserPreferencesParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserPreferencesParams) IsNil() bool {
if p == (UserPreferencesParams{}) {
return true
}
return false
return p == (UserPreferencesParams{})
}
// UserRequestWithdrawalParams contains all the parameters to send to the API
@@ -1116,8 +1035,5 @@ func (p UserRequestWithdrawalParams) ToURLVals(path string) (string, error) {
// IsNil checks to see if any values has been set for the paramater
func (p UserRequestWithdrawalParams) IsNil() bool {
if p == (UserRequestWithdrawalParams{}) {
return true
}
return false
return p == (UserRequestWithdrawalParams{})
}

View File

@@ -618,7 +618,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := b.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -634,7 +634,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -72,7 +72,8 @@ func (b *Bitmex) WsConnector() error {
var err error
if b.Websocket.GetProxyAddress() != "" {
proxy, err := url.Parse(b.Websocket.GetProxyAddress())
var proxy *url.URL
proxy, err = url.Parse(b.Websocket.GetProxyAddress())
if err != nil {
return err
}
@@ -169,7 +170,7 @@ func (b *Bitmex) wsHandleIncomingData() {
}
if common.StringContains(message, "ping") {
err := b.WebsocketConn.WriteJSON("pong")
err = b.WebsocketConn.WriteJSON("pong")
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -254,7 +255,8 @@ func (b *Bitmex) wsHandleIncomingData() {
}
for _, trade := range trades.Data {
timestamp, err := time.Parse(time.RFC3339, trade.Timestamp)
var timestamp time.Time
timestamp, err = time.Parse(time.RFC3339, trade.Timestamp)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -320,7 +322,7 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai
var bids, asks []orderbook.Item
for _, orderbookItem := range data {
if orderbookItem.Side == "Sell" {
if orderbookItem.Side == exchange.Sell.ToString() {
asks = append(asks, orderbook.Item{
Price: orderbookItem.Price,
Amount: float64(orderbookItem.Size),

View File

@@ -107,12 +107,12 @@ func (b *Bitmex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbo
}
for _, ob := range orderbookNew {
if ob.Side == "Sell" {
if ob.Side == exchange.Sell.ToString() {
orderBook.Asks = append(orderBook.Asks,
orderbook.Item{Amount: float64(ob.Size), Price: ob.Price})
continue
}
if ob.Side == "Buy" {
if ob.Side == exchange.Buy.ToString() {
orderBook.Bids = append(orderBook.Bids,
orderbook.Item{Amount: float64(ob.Size), Price: ob.Price})
continue

View File

@@ -453,7 +453,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := b.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -469,7 +469,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -115,8 +115,5 @@ func getCryptocurrencyWithdrawalFee(currency string) float64 {
}
func getInternationalBankWithdrawalFee(currency string, amount float64) float64 {
var fee float64
fee = WithdrawalFees[currency] * amount
return fee
return WithdrawalFees[currency] * amount
}

View File

@@ -197,7 +197,7 @@ func TestSubmitOrder(t *testing.T) {
}
_, err := b.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 1, "clientId")
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -224,7 +224,7 @@ func TestCancelExchangeOrder(t *testing.T) {
// Assert
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -251,7 +251,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
// Assert
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', recieved %v", err)
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
}
@@ -271,7 +271,7 @@ func TestWithdraw(t *testing.T) {
_, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -294,7 +294,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := b.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -310,6 +310,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -51,11 +51,12 @@ func (b *BTCC) WsConnect() error {
var err error
if b.Websocket.GetProxyAddress() != "" {
prxy, err := url.Parse(b.Websocket.GetProxyAddress())
var proxy *url.URL
proxy, err = url.Parse(b.Websocket.GetProxyAddress())
if err != nil {
return err
}
dialer.Proxy = http.ProxyURL(prxy)
dialer.Proxy = http.ProxyURL(proxy)
}
b.Conn, _, err = dialer.Dial(b.Websocket.GetWebsocketURL(), http.Header{})
@@ -170,7 +171,7 @@ func (b *BTCC) WsHandleData() {
case msgTypeGetTrades:
var trades WsTrades
err := common.JSONDecode(resp.Raw, &trades)
err = common.JSONDecode(resp.Raw, &trades)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -182,7 +183,7 @@ func (b *BTCC) WsHandleData() {
// orderbook feeds
var orderbook WsOrderbookSnapshot
err := common.JSONDecode(resp.Raw, &orderbook)
err = common.JSONDecode(resp.Raw, &orderbook)
if err != nil {
b.Websocket.DataHandler <- err
continue
@@ -477,8 +478,8 @@ func (b *BTCC) WsProcessOrderbookUpdate(ob WsOrderbookSnapshot) error {
func (b *BTCC) WsProcessOldOrderbookSnapshot(ob WsOrderbookSnapshotOld, symbol string) error {
var asks, bids []orderbook.Item
askData, _ := ob.Data["Asks"]
bidData, _ := ob.Data["Bids"]
askData := ob.Data["Asks"]
bidData := ob.Data["Bids"]
for _, ask := range askData {
data := ask.([]interface{})

View File

@@ -467,11 +467,11 @@ func (b *BTCMarkets) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
if err != nil {
return 0, err
}
fee = calculateTradingFee(feeBuilder.FirstCurrency+feeBuilder.Delimiter+feeBuilder.SecondCurrency, tradingFee, feeBuilder.PurchasePrice, feeBuilder.Amount)
fee = calculateTradingFee(tradingFee, feeBuilder.PurchasePrice, feeBuilder.Amount)
case exchange.CryptocurrencyWithdrawalFee:
fee = getCryptocurrencyWithdrawalFee(feeBuilder.FirstCurrency)
case exchange.InternationalBankWithdrawalFee:
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem, feeBuilder.Amount)
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem)
}
if fee < 0 {
fee = 0
@@ -479,9 +479,8 @@ func (b *BTCMarkets) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
return fee, nil
}
func calculateTradingFee(curr string, tradingFee TradingFee, purchasePrice, amount float64) (fee float64) {
func calculateTradingFee(tradingFee TradingFee, purchasePrice, amount float64) (fee float64) {
fee = tradingFee.TradingFeeRate / 100000000
return fee * amount * purchasePrice
}
@@ -489,7 +488,7 @@ func getCryptocurrencyWithdrawalFee(currency string) float64 {
return WithdrawalFees[currency]
}
func getInternationalBankWithdrawalFee(currency string, amount float64) float64 {
func getInternationalBankWithdrawalFee(currency string) float64 {
var fee float64
if currency == symbol.AUD {

View File

@@ -447,7 +447,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -818,7 +818,7 @@ func (c *CoinbasePro) SendAuthenticatedHTTPRequest(method, path string, params m
message := nonce + method + "/" + path + string(payload)
hmac := common.GetHMAC(common.HashSHA256, []byte(message), []byte(c.APISecret))
headers := make(map[string]string)
headers["CB-ACCESS-SIGN"] = common.Base64Encode([]byte(hmac))
headers["CB-ACCESS-SIGN"] = common.Base64Encode(hmac)
headers["CB-ACCESS-TIMESTAMP"] = nonce
headers["CB-ACCESS-KEY"] = c.APIKey
headers["CB-ACCESS-PASSPHRASE"] = c.ClientID
@@ -838,9 +838,9 @@ func (c *CoinbasePro) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
}
fee = c.calculateTradingFee(trailingVolume, feeBuilder.FirstCurrency, feeBuilder.Delimiter, feeBuilder.SecondCurrency, feeBuilder.PurchasePrice, feeBuilder.Amount, feeBuilder.IsMaker)
case exchange.InternationalBankWithdrawalFee:
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem, feeBuilder.Amount)
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem)
case exchange.InternationalBankDepositFee:
fee = getInternationalBankDepositFee(feeBuilder.CurrencyItem, feeBuilder.Amount)
fee = getInternationalBankDepositFee(feeBuilder.CurrencyItem)
}
if fee < 0 {
@@ -870,7 +870,7 @@ func (c *CoinbasePro) calculateTradingFee(trailingVolume []Volume, firstCurrency
return fee * amount * purchasePrice
}
func getInternationalBankWithdrawalFee(currency string, amount float64) float64 {
func getInternationalBankWithdrawalFee(currency string) float64 {
var fee float64
if currency == symbol.USD {
@@ -882,7 +882,7 @@ func getInternationalBankWithdrawalFee(currency string, amount float64) float64
return fee
}
func getInternationalBankDepositFee(currency string, amount float64) float64 {
func getInternationalBankDepositFee(currency string) float64 {
var fee float64
if currency == symbol.USD {

View File

@@ -253,10 +253,7 @@ func (c *COINUT) CancelOrders(orders []CancelOrders) (CancelOrdersResponse, erro
}
entries := []CancelOrders{}
for _, order := range orders {
entries = append(entries, order)
}
entries = append(entries, orders...)
params["entries"] = entries
return result, c.SendHTTPRequest(coinutOrdersCancel, params, true, &result)
@@ -365,7 +362,7 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{
headers := make(map[string]string)
if authenticated {
headers["X-USER"] = c.ClientID
hmac := common.GetHMAC(common.HashSHA256, []byte(payload), []byte(c.APISecret))
hmac := common.GetHMAC(common.HashSHA256, payload, []byte(c.APISecret))
headers["X-SIGNATURE"] = common.HexEncodeToString(hmac)
}
headers["Content-Type"] = "application/json"

View File

@@ -325,7 +325,7 @@ func TestWithdraw(t *testing.T) {
_, err := c.WithdrawCryptocurrencyFunds(withdrawCryptoRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected 'Not supported', recieved %v", err)
t.Errorf("Expected 'Not supported', received %v", err)
}
}
@@ -341,7 +341,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := c.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -357,7 +357,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := c.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -239,15 +239,15 @@ func (c *COINUT) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, order
return submitOrderResponse, errors.New("unsupported order type")
}
switch APIresponse.(type) {
switch apiResp := APIresponse.(type) {
case OrdersBase:
orderResult := APIresponse.(OrdersBase)
orderResult := apiResp
submitOrderResponse.OrderID = fmt.Sprintf("%v", orderResult.OrderID)
case OrderFilledResponse:
orderResult := APIresponse.(OrderFilledResponse)
orderResult := apiResp
submitOrderResponse.OrderID = fmt.Sprintf("%v", orderResult.Order.OrderID)
case OrderRejectResponse:
orderResult := APIresponse.(OrderRejectResponse)
orderResult := apiResp
submitOrderResponse.OrderID = fmt.Sprintf("%v", orderResult.OrderID)
err = fmt.Errorf("OrderID: %v was rejected: %v", orderResult.OrderID, orderResult.Reasons)
}
@@ -310,9 +310,7 @@ func (c *COINUT) CancelAllOrders(orderCancellation exchange.OrderCancellation) (
return cancelAllOrdersResponse, err
}
for _, openOrder := range openOrders.Orders {
allTheOrders = append(allTheOrders, openOrder)
}
allTheOrders = append(allTheOrders, openOrders.Orders...)
}
}

View File

@@ -883,10 +883,7 @@ func (e *Base) GetWithdrawPermissions() uint32 {
// SupportsWithdrawPermissions compares the supplied permissions with the exchange's to verify they're supported
func (e *Base) SupportsWithdrawPermissions(permissions uint32) bool {
exchangePermissions := e.GetWithdrawPermissions()
if permissions&exchangePermissions == permissions {
return true
}
return false
return permissions&exchangePermissions == permissions
}
// FormatWithdrawPermissions will return each of the exchange's compatible withdrawal methods in readable form

View File

@@ -25,7 +25,7 @@ func TestSupportsRESTTickerBatchUpdates(t *testing.T) {
func TestHTTPClient(t *testing.T) {
r := Base{Name: "asdf"}
r.SetHTTPClientTimeout(time.Duration(time.Second * 5))
r.SetHTTPClientTimeout(time.Second * 5)
if r.GetHTTPClient().Timeout != time.Second*5 {
t.Fatalf("Test failed. TestHTTPClient unexpected value")
@@ -33,7 +33,7 @@ func TestHTTPClient(t *testing.T) {
r.Requester = nil
newClient := new(http.Client)
newClient.Timeout = time.Duration(time.Second * 10)
newClient.Timeout = time.Second * 10
r.SetHTTPClient(newClient)
if r.GetHTTPClient().Timeout != time.Second*10 {
@@ -57,7 +57,7 @@ func TestHTTPClient(t *testing.T) {
}
newClient = new(http.Client)
newClient.Timeout = time.Duration(time.Second * 10)
newClient.Timeout = time.Second * 10
b.SetHTTPClient(newClient)
if b.GetHTTPClient().Timeout != time.Second*10 {

View File

@@ -561,17 +561,11 @@ func (w *WebsocketOrderbookLocal) UpdateUsingID(bidTargets, askTargets []orderbo
}
case "insert":
for _, target := range bidTargets {
orderbookAddress.Bids = append(orderbookAddress.Bids, target)
}
for _, target := range askTargets {
orderbookAddress.Asks = append(orderbookAddress.Asks, target)
}
orderbookAddress.Bids = append(orderbookAddress.Bids, bidTargets...)
orderbookAddress.Asks = append(orderbookAddress.Asks, askTargets...)
}
orderbook.ProcessOrderbook(exchName, p, *orderbookAddress, assetType)
return nil
}
@@ -655,10 +649,7 @@ func (w *Websocket) GetFunctionality() uint32 {
// SupportsFunctionality returns if the functionality is supported as a boolean
func (w *Websocket) SupportsFunctionality(f uint32) bool {
if w.GetFunctionality()&f == f {
return true
}
return false
return w.GetFunctionality()&f == f
}
// FormatFunctionality will return each of the websocket connection compatible

View File

@@ -314,7 +314,7 @@ func TestFunctionality(t *testing.T) {
var w Websocket
if w.FormatFunctionality() != NoWebsocketSupportText {
t.Fatalf("Test Failed - FormatFunctionality error expected %s but recieved %s",
t.Fatalf("Test Failed - FormatFunctionality error expected %s but received %s",
NoWebsocketSupportText, w.FormatFunctionality())
}

View File

@@ -277,11 +277,11 @@ func (e *EXMO) GetCryptoDepositAddress() (map[string]string, error) {
return nil, err
}
switch result.(type) {
switch r := result.(type) {
case map[string]interface{}:
mapString := make(map[string]string)
for key, value := range result.(map[string]interface{}) {
for key, value := range r {
strValue := fmt.Sprintf("%v", value)
mapString[key] = strValue
}

View File

@@ -369,7 +369,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := e.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -385,7 +385,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := e.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -402,7 +402,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := g.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -418,7 +418,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := g.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -156,7 +156,7 @@ func (g *Gateio) WsHandleData() {
case common.StringContains(result.Method, "ticker"):
var ticker WebsocketTicker
var c string
err := common.JSONDecode(result.Params[1], &ticker)
err = common.JSONDecode(result.Params[1], &ticker)
if err != nil {
g.Websocket.DataHandler <- err
continue
@@ -183,7 +183,7 @@ func (g *Gateio) WsHandleData() {
case common.StringContains(result.Method, "trades"):
var trades []WebsocketTrade
var c string
err := common.JSONDecode(result.Params[1], &trades)
err = common.JSONDecode(result.Params[1], &trades)
if err != nil {
g.Websocket.DataHandler <- err
continue

View File

@@ -496,10 +496,8 @@ func (g *Gemini) SendAuthenticatedHTTPRequest(method, path string, params map[st
request["request"] = fmt.Sprintf("/v%s/%s", geminiAPIVersion, path)
request["nonce"] = g.Nonce.GetValue(g.Name, false)
if params != nil {
for key, value := range params {
request[key] = value
}
for key, value := range params {
request[key] = value
}
PayloadJSON, err := common.JSONEncode(request)

View File

@@ -482,7 +482,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := Session[1].WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -499,7 +499,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := Session[1].WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -314,13 +314,8 @@ func (h *HitBTC) GetOrderbook(currencyPair string, limit int) (Orderbook, error)
}
ob := Orderbook{}
for _, x := range resp.Asks {
ob.Asks = append(ob.Asks, x)
}
for _, x := range resp.Bids {
ob.Bids = append(ob.Bids, x)
}
ob.Asks = append(ob.Asks, resp.Asks...)
ob.Bids = append(ob.Bids, resp.Bids...)
return ob, nil
}

View File

@@ -312,7 +312,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := h.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -328,7 +328,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -863,7 +863,7 @@ func (h *HUOBI) SendAuthenticatedHTTPRequest(method, endpoint string, values url
signature := common.Base64Encode(hmac)
values.Set("Signature", signature)
if h.APIAuthPEMKeySupport == true {
if h.APIAuthPEMKeySupport {
pemKey := strings.NewReader(h.APIAuthPEMKey)
pemBytes, err := ioutil.ReadAll(pemKey)
if err != nil {

View File

@@ -555,7 +555,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := h.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -571,7 +571,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -539,7 +539,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := h.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -555,7 +555,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -363,17 +363,14 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params
request := make(map[string]interface{})
url := i.APIUrl + path
if params != nil {
for key, value := range params {
request[key] = value
}
for key, value := range params {
request[key] = value
}
PayloadJSON := []byte("")
var err error
if params != nil {
PayloadJSON, err = common.JSONEncode(request)
if err != nil {
return err
@@ -410,7 +407,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params
RequestID string `json:"requestId"`
}{}
err = i.SendPayload(method, url, headers, bytes.NewBuffer([]byte(PayloadJSON)), &intermediary, true, i.Verbose)
err = i.SendPayload(method, url, headers, bytes.NewBuffer(PayloadJSON), &intermediary, true, i.Verbose)
if err != nil {
return err
}
@@ -434,7 +431,7 @@ func (i *ItBit) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
case exchange.CryptocurrencyTradeFee:
fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount, feeBuilder.IsMaker)
case exchange.InternationalBankWithdrawalFee:
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem, feeBuilder.Amount, feeBuilder.BankTransactionType)
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem, feeBuilder.BankTransactionType)
}
if fee < 0 {
@@ -454,7 +451,7 @@ func calculateTradingFee(purchasePrice, amount float64, isMaker bool) float64 {
return feePercent * purchasePrice * amount
}
func getInternationalBankWithdrawalFee(currency string, amount float64, bankTransactionType exchange.InternationalBankTransactionType) float64 {
func getInternationalBankWithdrawalFee(currency string, bankTransactionType exchange.InternationalBankTransactionType) float64 {
var fee float64
if (bankTransactionType == exchange.Swift || bankTransactionType == exchange.WireTransfer) && currency == symbol.USD {
fee = 40

View File

@@ -371,7 +371,7 @@ func TestWithdraw(t *testing.T) {
_, err := i.WithdrawCryptocurrencyFunds(withdrawCryptoRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected 'Not supported', recieved %v", err)
t.Errorf("Expected 'Not supported', received %v", err)
}
}
@@ -387,7 +387,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := i.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -403,7 +403,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := i.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -559,6 +559,6 @@ func TestWithdrawCancel(t *testing.T) {
if areTestAPIKeysSet() && err == nil {
t.Error("Test Failed - WithdrawCancel() error cannot be nil")
} else if !areTestAPIKeysSet() && err == nil {
t.Errorf("Test Failed - WithdrawCancel() error - expecting an error when no keys are set but recieved nil")
t.Errorf("Test Failed - WithdrawCancel() error - expecting an error when no keys are set but received nil")
}
}

View File

@@ -273,7 +273,7 @@ func (l *LakeBTC) CancelExistingOrder(orderID int64) error {
return err
}
if resp.Result != true {
if !resp.Result {
return errors.New("unable to cancel order")
}
return nil
@@ -292,7 +292,7 @@ func (l *LakeBTC) CancelExistingOrders(orderIDs []string) error {
return err
}
if resp.Result != true {
if !resp.Result {
return fmt.Errorf("unable to cancel order(s): %v", orderIDs)
}
return nil

View File

@@ -375,7 +375,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := l.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -391,7 +391,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -48,7 +48,7 @@ type AccountInfo struct {
Profile struct {
Email string `json:"email"`
UID string `json:"uid"`
BTCDepositAddress string `json:"btc_deposit_addres"`
BTCDepositAddress string `json:"btc_deposit_addres"` // nolint: misspell
} `json:"profile"`
}

View File

@@ -366,7 +366,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := l.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -382,6 +382,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -156,7 +156,7 @@ func (l *Liqui) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exc
// SubmitOrder submits a new order
func (l *Liqui) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := l.Trade(p.Pair().String(), fmt.Sprintf("%s", orderType), amount, price)
response, err := l.Trade(p.Pair().String(), orderType.ToString(), amount, price)
if response > 0 {
submitOrderResponse.OrderID = fmt.Sprintf("%v", response)

View File

@@ -336,7 +336,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := l.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -352,7 +352,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -160,7 +160,7 @@ func (l *LocalBitcoins) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide
Currency: p.SecondCurrency.String(),
AccountInfo: "-",
BankName: "Bank",
MSG: fmt.Sprintf("%s", side.ToString()),
MSG: side.ToString(),
SMSVerficationRequired: true,
TrackMaxAmount: true,
RequireTrustedByAdvertiser: true,

View File

@@ -496,7 +496,7 @@ func (o *OKCoin) GetOrderInformation(orderID int64, symbol string) ([]OrderInfo,
return nil, err
}
if result.Result != true {
if !result.Result {
return nil, errors.New("unable to retrieve order info")
}
@@ -526,7 +526,7 @@ func (o *OKCoin) GetOrderInfoBatch(orderID []int64, symbol string) ([]OrderInfo,
return nil, err
}
if result.Result != true {
if !result.Result {
return nil, errors.New("unable to retrieve order info")
}

View File

@@ -286,7 +286,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := o.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -302,6 +302,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := o.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -865,7 +865,7 @@ func (o *OKEX) GetSpotKline(arg KlinesRequestParams) ([]CandleStickData, error)
values.Set("size", strconv.FormatInt(int64(arg.Size), 10))
}
if arg.Since != 0 {
values.Set("since", strconv.FormatInt(int64(arg.Since), 10))
values.Set("since", strconv.FormatInt(arg.Since, 10))
}
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, spotKline, values.Encode())

View File

@@ -551,7 +551,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := o.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -567,6 +567,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := o.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -264,9 +264,7 @@ func (o *OKEX) CancelAllOrders(orderCancellation exchange.OrderCancellation) (ex
return cancelAllOrdersResponse, fmt.Errorf("Something went wrong for currency %s", formattedCurrency)
}
for _, openOrder := range openOrders.Orders {
allOpenOrders = append(allOpenOrders, openOrder)
}
allOpenOrders = append(allOpenOrders, openOrders.Orders...)
}
for _, openOrder := range allOpenOrders {

View File

@@ -331,7 +331,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := p.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -347,7 +347,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := p.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -121,10 +121,7 @@ func getWSDataType(data interface{}) string {
}
func checkSubscriptionSuccess(data []interface{}) bool {
if data[1].(float64) != 1 {
return false
}
return true
return data[1].(float64) == 1
}
// WsHandleData handles data from the websocket connection
@@ -406,7 +403,7 @@ var CurrencyPairID = map[int]string{
174: "BTC_REP",
177: "BTC_ARDR",
178: "BTC_ZEC",
182: "BTC_STRAT",
182: "BTC_STRAT", // nolint: misspell
184: "BTC_PASC",
185: "BTC_GNT",
187: "BTC_GNO",

View File

@@ -470,7 +470,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := w.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -486,6 +486,6 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := w.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -366,7 +366,7 @@ func (y *Yobit) GetFee(feeBuilder exchange.FeeBuilder) (float64, error) {
case exchange.CryptocurrencyWithdrawalFee:
fee = getWithdrawalFee(feeBuilder.FirstCurrency)
case exchange.InternationalBankDepositFee:
fee = getInternationalBankDepositFee(feeBuilder.CurrencyItem, feeBuilder.Amount, feeBuilder.BankTransactionType)
fee = getInternationalBankDepositFee(feeBuilder.CurrencyItem, feeBuilder.BankTransactionType)
case exchange.InternationalBankWithdrawalFee:
fee = getInternationalBankWithdrawalFee(feeBuilder.CurrencyItem, feeBuilder.Amount, feeBuilder.BankTransactionType)
}
@@ -425,7 +425,7 @@ func getInternationalBankWithdrawalFee(currency string, amount float64, bankTran
}
// getInternationalBankDepositFee; No real fees for yobit deposits, but want to be explicit on what each payment type supports
func getInternationalBankDepositFee(currency string, amount float64, bankTransactionType exchange.InternationalBankTransactionType) float64 {
func getInternationalBankDepositFee(currency string, bankTransactionType exchange.InternationalBankTransactionType) float64 {
var fee float64
switch bankTransactionType {
case exchange.PerfectMoney:

View File

@@ -442,7 +442,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := y.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -458,7 +458,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := y.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -382,7 +382,7 @@ func TestWithdrawFiat(t *testing.T) {
_, err := z.WithdrawFiatFunds(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}
@@ -398,7 +398,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
_, err := z.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err)
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
}

View File

@@ -2,7 +2,7 @@ package zb
import "encoding/json"
// Subscription defines an intial subscription type to be sent
// Subscription defines an initial subscription type to be sent
type Subscription struct {
Event string `json:"event"`
Channel string `json:"channel"`

View File

@@ -224,9 +224,7 @@ func (z *ZB) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exch
return cancelAllOrdersResponse, err
}
for _, openOrder := range openOrders {
allOpenOrders = append(allOpenOrders, openOrder)
}
allOpenOrders = append(allOpenOrders, openOrders...)
}
for _, openOrder := range allOpenOrders {

View File

@@ -75,9 +75,7 @@ func IsRelatablePairs(p1, p2 pair.CurrencyPair, includeUSDT bool) bool {
return true
}
var relatablePairs []pair.CurrencyPair
relatablePairs = GetRelatableCurrencies(p1, true, includeUSDT)
var relatablePairs = GetRelatableCurrencies(p1, true, includeUSDT)
if currency.IsCryptoFiatPair(p1) {
for x := range relatablePairs {
relatablePairs = append(relatablePairs, GetRelatableFiatCurrencies(relatablePairs[x])...)
@@ -197,7 +195,8 @@ func GetRelatableCurrencies(p pair.CurrencyPair, incOrig, incUSDT bool) []pair.C
addPair(pair.NewCurrencyPair(first.String(),
p.SecondCurrency.String()))
second, err := translation.GetTranslation(p.SecondCurrency)
var second pair.CurrencyItem
second, err = translation.GetTranslation(p.SecondCurrency)
if err == nil {
addPair(pair.NewCurrencyPair(first.String(),
second.String()))

View File

@@ -143,7 +143,7 @@ func main() {
common.ExtractHost(listenAddr), common.ExtractPort(listenAddr),
)
router := NewRouter(bot.exchanges)
router := NewRouter()
go func() {
err = http.ListenAndServe(listenAddr, router)
if err != nil {

View File

@@ -198,10 +198,7 @@ func (p *Base) UpdatePortfolio(addresses []string, coinType string) bool {
}
p.AddAddress(addresses[x], coinType, PortfolioAddressPersonal, result.ETH.Balance)
}
if errors > 0 {
return false
}
return true
return errors == 0
}
for x := range addresses {
result, err := GetCryptoIDAddress(addresses[x], coinType)
@@ -261,8 +258,8 @@ func (p *Base) GetPersonalPortfolio() map[string]float64 {
// getPercentage returns the percentage of the target coin amount against the
// total coin amount.
func getPercentage(input map[string]float64, target string, totals map[string]float64) float64 {
subtotal, _ := input[target]
total, _ := totals[target]
subtotal := input[target]
total := totals[target]
percentage := (subtotal / total) * 100 / 1
return percentage
}
@@ -270,7 +267,7 @@ func getPercentage(input map[string]float64, target string, totals map[string]fl
// getPercentageSpecific returns the percentage a specific value of a target coin amount
// against the total coin amount.
func getPercentageSpecific(input float64, target string, totals map[string]float64) float64 {
total, _ := totals[target]
total := totals[target]
percentage := (input / total) * 100 / 1
return percentage
}

View File

@@ -6,7 +6,6 @@ import (
"time"
"github.com/gorilla/mux"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
log "github.com/thrasher-/gocryptotrader/logger"
)
@@ -42,7 +41,7 @@ var routes = Routes{}
// NewRouter takes in the exchange interfaces and returns a new multiplexor
// router
func NewRouter(exchanges []exchange.IBotExchange) *mux.Router {
func NewRouter() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
routes = Routes{
@@ -109,15 +108,11 @@ func NewRouter(exchanges []exchange.IBotExchange) *mux.Router {
}
for _, route := range routes {
var handler http.Handler
handler = route.HandlerFunc
handler = RESTLogger(handler, route.Name)
router.
Methods(route.Method).
Path(route.Pattern).
Name(route.Name).
Handler(handler)
Handler(RESTLogger(route.HandlerFunc, route.Name))
}
return router
}

View File

@@ -42,7 +42,7 @@ type AllEnabledExchangeAccounts struct {
}
// RESTfulJSONResponse outputs a JSON response of the response interface
func RESTfulJSONResponse(w http.ResponseWriter, r *http.Request, response interface{}) error {
func RESTfulJSONResponse(w http.ResponseWriter, response interface{}) error {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
return json.NewEncoder(w).Encode(response)
@@ -57,7 +57,7 @@ func RESTfulError(method string, err error) {
// RESTGetAllSettings replies to a request with an encoded JSON response about the
// trading bots configuration.
func RESTGetAllSettings(w http.ResponseWriter, r *http.Request) {
err := RESTfulJSONResponse(w, r, bot.config)
err := RESTfulJSONResponse(w, bot.config)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -79,7 +79,7 @@ func RESTSaveAllSettings(w http.ResponseWriter, r *http.Request) {
RESTfulError(r.Method, err)
}
err = RESTfulJSONResponse(w, r, bot.config)
err = RESTfulJSONResponse(w, bot.config)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -106,7 +106,7 @@ func RESTGetOrderbook(w http.ResponseWriter, r *http.Request) {
return
}
err = RESTfulJSONResponse(w, r, response)
err = RESTfulJSONResponse(w, response)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -165,7 +165,7 @@ func RESTGetAllActiveOrderbooks(w http.ResponseWriter, r *http.Request) {
var response AllEnabledExchangeOrderbooks
response.Data = GetAllActiveOrderbooks()
err := RESTfulJSONResponse(w, r, response)
err := RESTfulJSONResponse(w, response)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -174,7 +174,7 @@ func RESTGetAllActiveOrderbooks(w http.ResponseWriter, r *http.Request) {
// RESTGetPortfolio returns the bot portfolio
func RESTGetPortfolio(w http.ResponseWriter, r *http.Request) {
result := bot.portfolio.GetPortfolioSummary()
err := RESTfulJSONResponse(w, r, result)
err := RESTfulJSONResponse(w, result)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -197,7 +197,7 @@ func RESTGetTicker(w http.ResponseWriter, r *http.Request) {
currency)
return
}
err = RESTfulJSONResponse(w, r, response)
err = RESTfulJSONResponse(w, response)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -255,7 +255,7 @@ func RESTGetAllActiveTickers(w http.ResponseWriter, r *http.Request) {
var response AllEnabledExchangeCurrencies
response.Data = GetAllActiveTickers()
err := RESTfulJSONResponse(w, r, response)
err := RESTfulJSONResponse(w, response)
if err != nil {
RESTfulError(r.Method, err)
}
@@ -286,7 +286,7 @@ func GetAllEnabledExchangeAccountInfo() AllEnabledExchangeAccounts {
// info
func RESTGetAllEnabledAccountInfo(w http.ResponseWriter, r *http.Request) {
response := GetAllEnabledExchangeAccountInfo()
err := RESTfulJSONResponse(w, r, response)
err := RESTfulJSONResponse(w, response)
if err != nil {
RESTfulError(r.Method, err)
}

View File

@@ -22,10 +22,9 @@ func loadConfig(t *testing.T) *config.Config {
}
func makeHTTPGetRequest(t *testing.T, url string, response interface{}) *http.Response {
req := httptest.NewRequest("GET", "http://localhost:9050/config/all", nil)
w := httptest.NewRecorder()
err := RESTfulJSONResponse(w, req, response)
err := RESTfulJSONResponse(w, response)
if err != nil {
t.Error("Test failed. Failed to make response.", err)
}

View File

@@ -382,9 +382,9 @@ func WebsocketDataHandler(ws *exchange.Websocket, verbose bool) {
return
case data := <-ws.DataHandler:
switch data.(type) {
switch d := data.(type) {
case string:
switch data.(string) {
switch d {
case exchange.WebsocketNotEnabled:
if verbose {
log.Warnf("routines.go warning - exchange %s weboscket not enabled",
@@ -392,12 +392,12 @@ func WebsocketDataHandler(ws *exchange.Websocket, verbose bool) {
}
default:
log.Infof(data.(string))
log.Infof(d)
}
case error:
switch {
case common.StringContains(data.(error).Error(), "close 1006"):
case common.StringContains(d.Error(), "close 1006"):
go WebsocketReconnect(ws, verbose)
continue
default:
@@ -407,27 +407,27 @@ func WebsocketDataHandler(ws *exchange.Websocket, verbose bool) {
case exchange.TradeData:
// Trade Data
if verbose {
log.Infoln("Websocket trades Updated: ", data.(exchange.TradeData))
log.Infoln("Websocket trades Updated: ", d)
}
case exchange.TickerData:
// Ticker data
if verbose {
log.Infoln("Websocket Ticker Updated: ", data.(exchange.TickerData))
log.Infoln("Websocket Ticker Updated: ", d)
}
case exchange.KlineData:
// Kline data
if verbose {
log.Infoln("Websocket Kline Updated: ", data.(exchange.KlineData))
log.Infoln("Websocket Kline Updated: ", d)
}
case exchange.WebsocketOrderbookUpdate:
// Orderbook data
if verbose {
log.Infoln("Websocket Orderbook Updated:", data.(exchange.WebsocketOrderbookUpdate))
log.Infoln("Websocket Orderbook Updated:", d)
}
default:
if verbose {
log.Warnf("Websocket Unknown type: %s", data)
log.Warnf("Websocket Unknown type: %s", d)
}
}
}

View File

@@ -43,7 +43,7 @@ func encodePEM(privKey *ecdsa.PrivateKey, pubKey bool) ([]byte, error) {
}
func decodePEM(PEMPrivKey, PEMPubKey []byte) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error) {
block, _ := pem.Decode([]byte(PEMPrivKey))
block, _ := pem.Decode(PEMPrivKey)
if block == nil {
return nil, nil, errors.New("priv block data is nil")
}
@@ -54,7 +54,7 @@ func decodePEM(PEMPrivKey, PEMPubKey []byte) (*ecdsa.PrivateKey, *ecdsa.PublicKe
return nil, nil, err
}
blockPub, _ := pem.Decode([]byte(PEMPubKey))
blockPub, _ := pem.Decode(PEMPubKey)
if block == nil {
return nil, nil, errors.New("pub block data is nil")
}
@@ -97,7 +97,8 @@ func main() {
}
if genKeys {
pKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
var pKey *ecdsa.PrivateKey
pKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
log.Fatal(err)
}
@@ -115,13 +116,15 @@ func main() {
}
} else {
pubKeyData, err := common.ReadFile("publickey.pem")
var pubKeyData []byte
pubKeyData, err = common.ReadFile("publickey.pem")
if err != nil {
log.Fatal(err)
}
log.Println("Successfully read PEM files.")
priv, _, err := decodePEM(privKeyData, pubKeyData)
var priv *ecdsa.PrivateKey
priv, _, err = decodePEM(privKeyData, pubKeyData)
if err != nil {
log.Fatal(err)
}

View File

@@ -194,7 +194,7 @@ func (c *WebsocketClient) write() {
defer func() {
c.Conn.Close()
}()
for {
for { // nolint: gosimple
select {
case message, ok := <-c.Send:
if !ok {