Linter fixes (#246)

Linter fixes
This commit is contained in:
Adrian Gallagher
2019-02-05 16:26:04 +11:00
committed by GitHub
parent d7368c1a8d
commit 5e5ca8a887
85 changed files with 641 additions and 794 deletions

View File

@@ -21,7 +21,7 @@ Block style example:
func SendHTTPRequest(method, path string, headers map[string]string, body io.Reader) (string, error) {
result := strings.ToUpper(method)
if result != "POST" && result != "GET" && result != "DELETE" {
if result != http.MethodPost && result != http.MethodGet && result != http.MethodDelete {
return "", errors.New("Invalid HTTP method specified.")
}

View File

@@ -21,7 +21,7 @@ Block style example:
func SendHTTPRequest(method, path string, headers map[string]string, body io.Reader) (string, error) {
result := strings.ToUpper(method)
if result != "POST" && result != "GET" && result != "DELETE" {
if result != http.MethodPost && result != http.MethodGet && result != http.MethodDelete {
return "", errors.New("Invalid HTTP method specified.")
}

View File

@@ -23,7 +23,6 @@ LINTOPTS += \
endif
LINTOPTS += \
--deadline=5m ./... | \
grep -v 'ALL_CAPS\|OP_' 2>&1 | \
tee /dev/stderr
get:

View File

@@ -356,7 +356,7 @@ func CalculateNetProfit(amount, priceThen, priceNow, costs float64) float64 {
func SendHTTPRequest(method, path string, headers map[string]string, body io.Reader) (string, error) {
result := strings.ToUpper(method)
if result != "POST" && result != "GET" && result != "DELETE" {
if result != http.MethodPost && result != http.MethodGet && result != http.MethodDelete {
return "", errors.New("invalid HTTP method specified")
}
@@ -509,20 +509,12 @@ func UnixTimestampStrToTime(timeStr string) (time.Time, error) {
// ReadFile reads a file and returns read data as byte array.
func ReadFile(path string) ([]byte, error) {
file, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
return file, nil
return ioutil.ReadFile(path)
}
// WriteFile writes selected data to a file and returns an error
func WriteFile(file string, data []byte) error {
err := ioutil.WriteFile(file, data, 0644)
if err != nil {
return err
}
return nil
return ioutil.WriteFile(file, data, 0644)
}
// RemoveFile removes a file

View File

@@ -96,7 +96,7 @@ func TestGetChannelsString(t *testing.T) {
testpassed = true
}
}
if testpassed == false {
if !testpassed {
t.Error("test failed - slack GetChannelsString() error")
}
}

View File

@@ -4,6 +4,7 @@ package smsglobal
import (
"errors"
"flag"
"net/http"
"net/url"
"strings"
@@ -164,7 +165,7 @@ func (s *SMSGlobal) SendMessage(to, message string) error {
headers := make(map[string]string)
headers["Content-Type"] = "application/x-www-form-urlencoded"
resp, err := common.SendHTTPRequest("POST",
resp, err := common.SendHTTPRequest(http.MethodPost,
smsGlobalAPIURL,
headers,
strings.NewReader(values.Encode()))

View File

@@ -7,6 +7,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/communications/base"
@@ -221,7 +222,7 @@ func (t *Telegram) SendHTTPRequest(path string, json []byte, result interface{})
headers := make(map[string]string)
headers["content-type"] = "application/json"
resp, err := common.SendHTTPRequest("POST", path, headers, bytes.NewBuffer(json))
resp, err := common.SendHTTPRequest(http.MethodPost, path, headers, bytes.NewBuffer(json))
if err != nil {
return err
}

View File

@@ -13,8 +13,8 @@ func TestSetup(t *testing.T) {
cfg := config.GetConfig()
cfg.LoadConfig("../../testdata/configtest.json")
T.Setup(cfg.GetCommunicationsConfig())
if T.Name != "Telegram" || T.Enabled != false ||
T.Token != "testest" || T.Verbose != false {
if T.Name != "Telegram" || T.Enabled ||
T.Token != "testest" || T.Verbose {
t.Error("test failed - telegram Setup() error, unexpected setup values",
T.Name, T.Enabled, T.Token, T.Verbose)
}

View File

@@ -1244,12 +1244,7 @@ func (c *Config) SaveConfig(configPath string) error {
return err
}
}
err = common.WriteFile(defaultPath, payload)
if err != nil {
return err
}
return nil
return common.WriteFile(defaultPath, payload)
}
// CheckConfig checks all config settings
@@ -1279,12 +1274,7 @@ func (c *Config) CheckConfig() error {
c.GlobalHTTPTimeout = configDefaultHTTPTimeout
}
err = c.CheckClientBankAccounts()
if err != nil {
return err
}
return nil
return c.CheckClientBankAccounts()
}
// LoadConfig loads your configuration file into your configuration object
@@ -1318,12 +1308,7 @@ func (c *Config) UpdateConfig(configPath string, newCfg Config) error {
return err
}
err = c.LoadConfig(configPath)
if err != nil {
return err
}
return nil
return c.LoadConfig(configPath)
}
// GetConfig returns a pointer to a configuration object

View File

@@ -57,11 +57,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
log.Println("Please enter in your password: ")
pwPrompt := func(i *[]byte) error {
_, err := fmt.Scanln(i)
if err != nil {
return err
}
return nil
return err
}
var p1 []byte

View File

@@ -54,7 +54,7 @@ func TestUpdateExchangeBankAccounts(t *testing.T) {
var count int
for _, exch := range cfg.Exchanges {
if exch.Name == "Bitfinex" {
if exch.BankAccounts[0].Enabled == false {
if !exch.BankAccounts[0].Enabled {
count++
}
}
@@ -109,7 +109,7 @@ func TestUpdateClientBankAccounts(t *testing.T) {
var count int
for _, bank := range cfg.BankAccounts {
if bank.BankName == b.BankName {
if bank.Enabled == false {
if !bank.Enabled {
count++
}
}
@@ -518,7 +518,7 @@ func TestGetRequestCurrencyPairFormat(t *testing.T) {
)
}
exchFmt, err := cfg.GetRequestCurrencyPairFormat("Bitfinex")
exchFmt, err := cfg.GetRequestCurrencyPairFormat("Yobit")
if exchFmt.Uppercase || exchFmt.Delimiter != "_" || exchFmt.Separator != "-" {
t.Errorf(
"Test failed. TestGetRequestCurrencyPairFormat. Invalid values",

View File

@@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"strings"
@@ -117,7 +118,7 @@ func (c *Coinmarketcap) GetCryptocurrencyInfo(currencyID ...int64) (CryptoCurren
val := url.Values{}
val.Set("id", strings.Join(currStr, ","))
err = c.SendHTTPRequest("GET", endpointCryptocurrencyInfo, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyInfo, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -142,7 +143,7 @@ func (c *Coinmarketcap) GetCryptocurrencyIDMap() ([]CryptoCurrencyMap, error) {
return resp.Data, err
}
err = c.SendHTTPRequest("GET", endpointCryptocurrencyMap, nil, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyMap, nil, &resp)
if err != nil {
return resp.Data, err
}
@@ -169,7 +170,7 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH
// return resp.Data, err
// }
// err = c.SendHTTPRequest("GET", endpointCryptocurrencyHistoricalListings, nil, &resp)
// err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyHistoricalListings, nil, &resp)
// if err != nil {
// return resp.Data, err
// }
@@ -206,7 +207,7 @@ func (c *Coinmarketcap) GetCryptocurrencyLatestListing(start, limit int64) ([]Cr
val.Set("limit", strconv.FormatInt(limit, 10))
}
err = c.SendHTTPRequest("GET", endpointCryptocurrencyLatestListings, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyLatestListings, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -246,7 +247,7 @@ func (c *Coinmarketcap) GetCryptocurrencyLatestMarketPairs(currencyID, start, li
val.Set("limit", strconv.FormatInt(limit, 10))
}
err = c.SendHTTPRequest("GET", endpointCryptocurrencyMarketPairs, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyMarketPairs, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -284,7 +285,7 @@ func (c *Coinmarketcap) GetCryptocurrencyOHLCHistorical(currencyID int64, tStart
val.Set("time_end", strconv.FormatInt(tEnd.Unix(), 10))
}
err = c.SendHTTPRequest("GET", endpointOHLCVHistorical, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointOHLCVHistorical, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -318,7 +319,7 @@ func (c *Coinmarketcap) GetCryptocurrencyOHLCLatest(currencyID int64) (Cryptocur
val := url.Values{}
val.Set("id", strconv.FormatInt(currencyID, 10))
err = c.SendHTTPRequest("GET", endpointOHLCVLatest, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointOHLCVLatest, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -353,7 +354,7 @@ func (c *Coinmarketcap) GetCryptocurrencyLatestQuotes(currencyID ...int64) (Cryp
val := url.Values{}
val.Set("id", strings.Join(currStr, ","))
err = c.SendHTTPRequest("GET", endpointGetMarketQuotesLatest, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointGetMarketQuotesLatest, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -390,7 +391,7 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalQuotes(currencyID int64, tSta
val.Set("time_end", strconv.FormatInt(tEnd.Unix(), 10))
}
err = c.SendHTTPRequest("GET", endpointGetMarketQuotesHistorical, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointGetMarketQuotesHistorical, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -425,7 +426,7 @@ func (c *Coinmarketcap) GetExchangeInfo(exchangeID ...int64) (ExchangeInfo, erro
val := url.Values{}
val.Set("id", strings.Join(exchStr, ","))
err = c.SendHTTPRequest("GET", endpointExchangeInfo, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointExchangeInfo, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -465,7 +466,7 @@ func (c *Coinmarketcap) GetExchangeMap(start, limit int64) ([]ExchangeMap, error
val.Set("limit", strconv.FormatInt(start, 10))
}
err = c.SendHTTPRequest("GET", endpointExchangeMap, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointExchangeMap, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -527,7 +528,7 @@ func (c *Coinmarketcap) GetExchangeLatestMarketPairs(exchangeID, start, limit in
val.Set("limit", strconv.FormatInt(start, 10))
}
err = c.SendHTTPRequest("GET", endpointExchangeMarketPairsLatest, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointExchangeMarketPairsLatest, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -562,7 +563,7 @@ func (c *Coinmarketcap) GetExchangeLatestQuotes(exchangeID ...int64) (ExchangeLa
val := url.Values{}
val.Set("id", strings.Join(exchStr, ","))
err = c.SendHTTPRequest("GET", endpointExchangeMarketQuoteLatest, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointExchangeMarketQuoteLatest, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -599,7 +600,7 @@ func (c *Coinmarketcap) GetExchangeHistoricalQuotes(exchangeID int64, tStart, tE
val.Set("time_end", strconv.FormatInt(tEnd.Unix(), 10))
}
err = c.SendHTTPRequest("GET", endpointExchangeMarketQuoteHistorical, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointExchangeMarketQuoteHistorical, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -624,7 +625,7 @@ func (c *Coinmarketcap) GetGlobalMeticLatestQuotes() (GlobalMeticLatestQuotes, e
return resp.Data, err
}
err = c.SendHTTPRequest("GET", endpointGlobalQuoteLatest, nil, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointGlobalQuoteLatest, nil, &resp)
if err != nil {
return resp.Data, err
}
@@ -659,7 +660,7 @@ func (c *Coinmarketcap) GetGlobalMeticHistoricalQuotes(tStart, tEnd time.Time) (
val.Set("time_end", strconv.FormatInt(tEnd.Unix(), 10))
}
err = c.SendHTTPRequest("GET", endpointGlobalQuoteHistorical, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointGlobalQuoteHistorical, val, &resp)
if err != nil {
return resp.Data, err
}
@@ -699,7 +700,7 @@ func (c *Coinmarketcap) GetPriceConversion(amount float64, currencyID int64, atH
val.Set("time", strconv.FormatInt(atHistoricTime.Unix(), 10))
}
err = c.SendHTTPRequest("GET", endpointPriceConversion, val, &resp)
err = c.SendHTTPRequest(http.MethodGet, endpointPriceConversion, val, &resp)
if err != nil {
return resp.Data, err
}

View File

@@ -96,12 +96,18 @@ func (f *Fixer) GetLatestRates(base, symbols string) (map[string]float64, error)
// GetHistoricalRates returns historical exchange rate data for all available or
// a specific set of currencies.
// date - YYYY-MM-DD [required] A date in the past
// base - USD [optional]
// symbols - the desired symbols
func (f *Fixer) GetHistoricalRates(date, base string, symbols []string) (map[string]float64, error) {
var resp Rates
v := url.Values{}
v.Set("symbols", common.JoinStrings(symbols, ","))
if len(base) > 0 {
v.Set("base", base)
}
err := f.SendOpenHTTPRequest(date, v, &resp)
if err != nil {
return resp.Rates, err

View File

@@ -11,6 +11,7 @@ package openexchangerates
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
@@ -222,7 +223,7 @@ func (o *OXR) SendHTTPRequest(endpoint string, values url.Values, result interfa
headers["Authorization"] = "Token " + o.APIKey
path := APIURL + endpoint + "?" + values.Encode()
resp, err := common.SendHTTPRequest("GET", path, headers, nil)
resp, err := common.SendHTTPRequest(http.MethodGet, path, headers, nil)
if err != nil {
return err
}

View File

@@ -1,6 +1,8 @@
package symbol
import "errors"
import (
"errors"
)
// Const declarations for individual currencies/tokens/fiat
// An ever growing list. Cares not for equivalence, just is
@@ -309,9 +311,9 @@ const (
STQ = "STQ"
INK = "INK"
HBZ = "HBZ"
USDT_ETH = "USDT_ETH"
QTUM_ETH = "QTUM_ETH"
BTM_ETH = "BTM_ETH"
USDT_ETH = "USDT_ETH" // nolint: golint
QTUM_ETH = "QTUM_ETH" // nolint: golint
BTM_ETH = "BTM_ETH" // nolint: golint
FIL = "FIL"
STX = "STX"
BOT = "BOT"
@@ -324,7 +326,7 @@ const (
GOD = "GOD"
SMT = "SMT"
BTF = "BTF"
NAS_ETH = "NAS_ETH"
NAS_ETH = "NAS_ETH" // nolint: golint
TSL = "TSL"
BIFI = "BIFI"
BNTY = "BNTY"
@@ -350,7 +352,7 @@ const (
MOBI = "MOBI"
LEDU = "LEDU"
DBC = "DBC"
MKR_OLD = "MKR_OLD"
MKR_OLD = "MKR_OLD" // nolint: golint
DPY = "DPY"
BCDN = "BCDN"
EOSDAC = "EOSDAC"
@@ -359,7 +361,7 @@ const (
PPS = "PPS"
BOE = "BOE"
MEDX = "MEDX"
SMT_ETH = "SMT_ETH"
SMT_ETH = "SMT_ETH" // nolint: golint
CS = "CS"
MAN = "MAN"
REM = "REM"
@@ -379,7 +381,7 @@ const (
SWTH = "SWTH"
NKN = "NKN"
SOUL = "SOUL"
GALA_NEO = "GALA_NEO"
GALA_NEO = "GALA_NEO" // nolint: golint
LRN = "LRN"
GSE = "GSE"
RATING = "RATING"

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"strconv"
"time"
@@ -70,7 +71,7 @@ func (a *Alphapoint) GetTicker(currencyPair string) (Ticker, error) {
request["productPair"] = currencyPair
response := Ticker{}
err := a.SendHTTPRequest("POST", alphapointTicker, request, &response)
err := a.SendHTTPRequest(http.MethodPost, alphapointTicker, request, &response)
if err != nil {
return response, err
}
@@ -93,7 +94,7 @@ func (a *Alphapoint) GetTrades(currencyPair string, startIndex, count int) (Trad
request["Count"] = count
response := Trades{}
err := a.SendHTTPRequest("POST", alphapointTrades, request, &response)
err := a.SendHTTPRequest(http.MethodPost, alphapointTrades, request, &response)
if err != nil {
return response, err
}
@@ -114,7 +115,7 @@ func (a *Alphapoint) GetTradesByDate(currencyPair string, startDate, endDate int
request["endDate"] = endDate
response := Trades{}
err := a.SendHTTPRequest("POST", alphapointTradesByDate, request, &response)
err := a.SendHTTPRequest(http.MethodPost, alphapointTradesByDate, request, &response)
if err != nil {
return response, err
}
@@ -131,7 +132,7 @@ func (a *Alphapoint) GetOrderbook(currencyPair string) (Orderbook, error) {
request["productPair"] = currencyPair
response := Orderbook{}
err := a.SendHTTPRequest("POST", alphapointOrderbook, request, &response)
err := a.SendHTTPRequest(http.MethodPost, alphapointOrderbook, request, &response)
if err != nil {
return response, err
}
@@ -145,7 +146,7 @@ func (a *Alphapoint) GetOrderbook(currencyPair string) (Orderbook, error) {
func (a *Alphapoint) GetProductPairs() (ProductPairs, error) {
response := ProductPairs{}
err := a.SendHTTPRequest("POST", alphapointProductPairs, nil, &response)
err := a.SendHTTPRequest(http.MethodPost, alphapointProductPairs, nil, &response)
if err != nil {
return response, err
}
@@ -159,7 +160,7 @@ func (a *Alphapoint) GetProductPairs() (ProductPairs, error) {
func (a *Alphapoint) GetProducts() (Products, error) {
response := Products{}
err := a.SendHTTPRequest("POST", alphapointProducts, nil, &response)
err := a.SendHTTPRequest(http.MethodPost, alphapointProducts, nil, &response)
if err != nil {
return response, err
}
@@ -190,7 +191,7 @@ func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password s
request["password"] = password
response := Response{}
err := a.SendAuthenticatedHTTPRequest("POST", alphapointCreateAccount, request, &response)
err := a.SendAuthenticatedHTTPRequest(http.MethodPost, alphapointCreateAccount, request, &response)
if err != nil {
return fmt.Errorf("Alphapoint Error - CreateAccount HTTPRequest - reason: %s", err)
}
@@ -204,7 +205,7 @@ func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password s
func (a *Alphapoint) GetUserInfo() (UserInfo, error) {
response := UserInfo{}
err := a.SendAuthenticatedHTTPRequest("POST", alphapointUserInfo, map[string]interface{}{}, &response)
err := a.SendAuthenticatedHTTPRequest(http.MethodPost, alphapointUserInfo, map[string]interface{}{}, &response)
if err != nil {
return UserInfo{}, err
}
@@ -257,7 +258,7 @@ func (a *Alphapoint) SetUserInfo(firstName, lastName, cell2FACountryCode, cell2F
request["userInfoKVP"] = userInfoKVPs
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointUserInfo,
request,
&response,
@@ -276,7 +277,7 @@ func (a *Alphapoint) GetAccountInformation() (AccountInfo, error) {
response := AccountInfo{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointAccountInfo,
map[string]interface{}{},
&response,
@@ -302,7 +303,7 @@ func (a *Alphapoint) GetAccountTrades(currencyPair string, startIndex, count int
response := Trades{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointAccountTrades,
request,
&response,
@@ -320,7 +321,7 @@ func (a *Alphapoint) GetAccountTrades(currencyPair string, startIndex, count int
func (a *Alphapoint) GetDepositAddresses() ([]DepositAddresses, error) {
response := Response{}
err := a.SendAuthenticatedHTTPRequest("POST", alphapointDepositAddresses,
err := a.SendAuthenticatedHTTPRequest(http.MethodPost, alphapointDepositAddresses,
map[string]interface{}{}, &response,
)
if err != nil {
@@ -346,7 +347,7 @@ func (a *Alphapoint) WithdrawCoins(symbol, product, address string, amount float
response := Response{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointWithdraw,
request,
&response,
@@ -385,7 +386,7 @@ func (a *Alphapoint) CreateOrder(symbol, side, orderType string, quantity, price
response := Response{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointCreateOrder,
request,
&response,
@@ -415,7 +416,7 @@ func (a *Alphapoint) ModifyExistingOrder(symbol string, OrderID, action int64) (
response := Response{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointModifyOrder,
request,
&response,
@@ -439,7 +440,7 @@ func (a *Alphapoint) CancelExistingOrder(OrderID int64, OMSID string) (int64, er
response := Response{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointCancelOrder,
request,
&response,
@@ -461,7 +462,7 @@ func (a *Alphapoint) CancelAllExistingOrders(OMSID string) error {
response := Response{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointCancelAllOrders,
request,
&response,
@@ -480,7 +481,7 @@ func (a *Alphapoint) GetOrders() ([]OpenOrders, error) {
response := OrderInfo{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointOpenOrders,
map[string]interface{}{},
&response,
@@ -508,7 +509,7 @@ func (a *Alphapoint) GetOrderFee(symbol, side string, quantity, price float64) (
response := Response{}
err := a.SendAuthenticatedHTTPRequest(
"POST",
http.MethodPost,
alphapointOrderFee,
request,
&response,

View File

@@ -155,7 +155,7 @@ func TestGetTradesByDate(t *testing.T) {
if trades.Instrument != "BTCUSD" {
t.Error("Test Failed - Alphapoint trades.Instrument value is incorrect")
}
if trades.IsAccepted != true {
if !trades.IsAccepted {
t.Error("Test Failed - Alphapoint trades.IsAccepted value is true")
}
if len(trades.RejectReason) > 0 {

View File

@@ -116,7 +116,7 @@ func (a *Alphapoint) GetExchangeHistory(p pair.CurrencyPair, assetType string) (
// SubmitOrder submits a new order and returns a true value when
// successfully submitted
func (a *Alphapoint) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (a *Alphapoint) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := a.CreateOrder(p.Pair().String(), side.ToString(), orderType.ToString(), amount, price)
@@ -164,7 +164,7 @@ func (a *Alphapoint) GetOrderInfo(orderID int64) (float64, error) {
for x := range orders {
for y := range orders[x].OpenOrders {
if int64(orders[x].OpenOrders[y].ServerOrderID) == orderID {
return float64(orders[x].OpenOrders[y].QtyRemaining), nil
return orders[x].OpenOrders[y].QtyRemaining, nil
}
}
}
@@ -172,7 +172,7 @@ func (a *Alphapoint) GetOrderInfo(orderID int64) (float64, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (a *Alphapoint) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (a *Alphapoint) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
addreses, err := a.GetDepositAddresses()
if err != nil {
return "", err
@@ -234,12 +234,12 @@ func (a *Alphapoint) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest)
}
orderDetail := exchange.OrderDetail{
Amount: float64(order.QtyTotal),
Amount: order.QtyTotal,
Exchange: a.Name,
AccountID: fmt.Sprintf("%v", order.AccountID),
ID: fmt.Sprintf("%v", order.ServerOrderID),
Price: float64(order.Price),
RemainingAmount: float64(order.QtyRemaining),
Price: order.Price,
RemainingAmount: order.QtyRemaining,
}
orderDetail.OrderSide = orderSideMap[order.Side]
@@ -277,12 +277,12 @@ func (a *Alphapoint) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest)
}
orderDetail := exchange.OrderDetail{
Amount: float64(order.QtyTotal),
Amount: order.QtyTotal,
AccountID: fmt.Sprintf("%v", order.AccountID),
Exchange: a.Name,
ID: fmt.Sprintf("%v", order.ServerOrderID),
Price: float64(order.Price),
RemainingAmount: float64(order.QtyRemaining),
Price: order.Price,
RemainingAmount: order.QtyRemaining,
}
orderDetail.OrderSide = orderSideMap[order.Side]

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"strconv"
"time"
@@ -401,7 +402,7 @@ func (a *ANX) GetDepositAddressByCurrency(currency, name string, new bool) (stri
// SendHTTPRequest sends an unauthenticated HTTP request
func (a *ANX) SendHTTPRequest(path string, result interface{}) error {
return a.SendPayload("GET", path, nil, nil, result, false, a.Verbose)
return a.SendPayload(http.MethodGet, path, nil, nil, result, false, a.Verbose)
}
// SendAuthenticatedHTTPRequest sends a authenticated HTTP request
@@ -439,7 +440,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
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)
return a.SendPayload(http.MethodPost, a.APIUrl+path, headers, bytes.NewBuffer(PayloadJSON), result, true, a.Verbose)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -25,7 +25,7 @@ func TestSetDefaults(t *testing.T) {
if a.Name != "ANX" {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if a.Enabled != false {
if a.Enabled {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if a.TakerFee != 0.02 {
@@ -34,10 +34,10 @@ func TestSetDefaults(t *testing.T) {
if a.MakerFee != 0.01 {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if a.Verbose != false {
if a.Verbose {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if a.Websocket.IsEnabled() != false {
if a.Websocket.IsEnabled() {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if a.RESTPollingDelay != 10 {
@@ -59,16 +59,16 @@ func TestSetup(t *testing.T) {
a.APISecret = testAPISecret
a.AuthenticatedAPISupport = true
if a.Enabled != true {
if !a.Enabled {
t.Error("Test Failed - ANX Setup() incorrect values set")
}
if a.RESTPollingDelay != 10 {
t.Error("Test Failed - ANX Setup() incorrect values set")
}
if a.Verbose != false {
if a.Verbose {
t.Error("Test Failed - ANX Setup() incorrect values set")
}
if a.Websocket.IsEnabled() != false {
if a.Websocket.IsEnabled() {
t.Error("Test Failed - ANX Setup() incorrect values set")
}
if len(a.BaseCurrencies) <= 0 {

View File

@@ -224,7 +224,7 @@ func (a *ANX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]excha
}
// SubmitOrder submits a new order
func (a *ANX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (a *ANX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var isBuying bool
@@ -274,7 +274,7 @@ func (a *ANX) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (a *ANX) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (a *ANX) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -309,7 +309,7 @@ func (a *ANX) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (a *ANX) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (a *ANX) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
return a.GetDepositAddressByCurrency(cryptocurrency.String(), "", false)
}

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -468,7 +469,7 @@ func (b *Binance) NewOrder(o NewOrderRequest) (NewOrderResponse, error) {
params.Set("newOrderRespType", o.NewOrderRespType)
}
if err := b.SendAuthHTTPRequest("POST", path, params, &resp); err != nil {
if err := b.SendAuthHTTPRequest(http.MethodPost, path, params, &resp); err != nil {
return resp, err
}
@@ -495,7 +496,7 @@ func (b *Binance) CancelExistingOrder(symbol string, orderID int64, origClientOr
params.Set("origClientOrderId", origClientOrderID)
}
return resp, b.SendAuthHTTPRequest("DELETE", path, params, &resp)
return resp, b.SendAuthHTTPRequest(http.MethodDelete, path, params, &resp)
}
// OpenOrders Current open orders. Get all open orders on a symbol.
@@ -510,7 +511,7 @@ func (b *Binance) OpenOrders(symbol string) ([]QueryOrderData, error) {
params.Set("symbol", common.StringToUpper(symbol))
}
if err := b.SendAuthHTTPRequest("GET", path, params, &resp); err != nil {
if err := b.SendAuthHTTPRequest(http.MethodGet, path, params, &resp); err != nil {
return resp, err
}
@@ -533,7 +534,7 @@ func (b *Binance) AllOrders(symbol, orderID, limit string) ([]QueryOrderData, er
if limit != "" {
params.Set("limit", limit)
}
if err := b.SendAuthHTTPRequest("GET", path, params, &resp); err != nil {
if err := b.SendAuthHTTPRequest(http.MethodGet, path, params, &resp); err != nil {
return resp, err
}
@@ -555,7 +556,7 @@ func (b *Binance) QueryOrder(symbol, origClientOrderID string, orderID int64) (Q
params.Set("orderId", strconv.FormatInt(orderID, 10))
}
if err := b.SendAuthHTTPRequest("GET", path, params, &resp); err != nil {
if err := b.SendAuthHTTPRequest(http.MethodGet, path, params, &resp); err != nil {
return resp, err
}
@@ -577,7 +578,7 @@ func (b *Binance) GetAccount() (*Account, error) {
path := fmt.Sprintf("%s%s", b.APIUrl, accountInfo)
params := url.Values{}
if err := b.SendAuthHTTPRequest("GET", path, params, &resp); err != nil {
if err := b.SendAuthHTTPRequest(http.MethodGet, path, params, &resp); err != nil {
return &resp.Account, err
}
@@ -590,7 +591,7 @@ func (b *Binance) GetAccount() (*Account, error) {
// SendHTTPRequest sends an unauthenticated request
func (b *Binance) SendHTTPRequest(path string, result interface{}) error {
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, b.Verbose)
}
// SendAuthHTTPRequest sends an authenticated HTTP request
@@ -754,7 +755,7 @@ func (b *Binance) WithdrawCrypto(asset, address, addressTag, name, amount string
params.Set("addressTag", addressTag)
}
if err := b.SendAuthHTTPRequest("POST", path, params, &resp); err != nil {
if err := b.SendAuthHTTPRequest(http.MethodPost, path, params, &resp); err != nil {
return -1, err
}
@@ -780,5 +781,5 @@ func (b *Binance) GetDepositAddressForCurrency(currency string) (string, error)
params.Set("status", "true")
return resp.Address,
b.SendAuthHTTPRequest("GET", path, params, &resp)
b.SendAuthHTTPRequest(http.MethodGet, path, params, &resp)
}

View File

@@ -181,7 +181,7 @@ func (b *Binance) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]e
}
// SubmitOrder submits a new order
func (b *Binance) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (b *Binance) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var sideType RequestParamsSideType
@@ -243,7 +243,7 @@ func (b *Binance) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Binance) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *Binance) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -269,7 +269,7 @@ func (b *Binance) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Binance) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (b *Binance) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
return b.GetDepositAddressForCurrency(cryptocurrency.String())
}

View File

@@ -3,6 +3,7 @@ package bitfinex
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -497,26 +498,14 @@ func (b *Bitfinex) GetSymbolsDetails() ([]SymbolDetails, error) {
// GetAccountInformation returns information about your account incl. trading fees
func (b *Bitfinex) GetAccountInformation() ([]AccountInfo, error) {
var responses []AccountInfo
err := b.SendAuthenticatedHTTPRequest("POST", bitfinexAccountInfo, nil, &responses)
if err != nil {
return responses, err
}
return responses, nil
return responses, b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexAccountInfo, nil, &responses)
}
// GetAccountFees - Gets all fee rates for all currencies
func (b *Bitfinex) GetAccountFees() (AccountFees, error) {
response := AccountFees{}
err := b.SendAuthenticatedHTTPRequest("POST", bitfinexAccountFees, nil, &response)
if err != nil {
return response, err
}
return response, nil
return response, b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexAccountFees, nil, &response)
}
// GetAccountSummary returns a 30-day summary of your trading volume and return
@@ -526,7 +515,7 @@ func (b *Bitfinex) GetAccountSummary() (AccountSummary, error) {
return response,
b.SendAuthenticatedHTTPRequest(
"POST", bitfinexAccountSummary, nil, &response,
http.MethodPost, bitfinexAccountSummary, nil, &response,
)
}
@@ -543,7 +532,7 @@ func (b *Bitfinex) NewDeposit(method, walletName string, renew int) (DepositResp
request["renew"] = renew
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexDeposit, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexDeposit, request, &response)
}
// GetKeyPermissions checks the permissions of the key being used to generate
@@ -552,7 +541,7 @@ func (b *Bitfinex) GetKeyPermissions() (KeyPermissions, error) {
response := KeyPermissions{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexKeyPermissions, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexKeyPermissions, nil, &response)
}
// GetMarginInfo shows your trading wallet information for margin trading
@@ -560,7 +549,7 @@ func (b *Bitfinex) GetMarginInfo() ([]MarginInfo, error) {
response := []MarginInfo{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexMarginInfo, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexMarginInfo, nil, &response)
}
// GetAccountBalance returns full wallet balance information
@@ -568,7 +557,7 @@ func (b *Bitfinex) GetAccountBalance() ([]Balance, error) {
response := []Balance{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexBalances, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexBalances, nil, &response)
}
// WalletTransfer move available balances between your wallets
@@ -585,7 +574,7 @@ func (b *Bitfinex) WalletTransfer(amount float64, currency, walletFrom, walletTo
request["walletTo"] = walletTo
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexTransfer, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexTransfer, request, &response)
}
// WithdrawCryptocurrency requests a withdrawal from one of your wallets.
@@ -602,7 +591,7 @@ func (b *Bitfinex) WithdrawCryptocurrency(withdrawType, wallet, address, currenc
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexWithdrawal, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexWithdrawal, request, &response)
}
// WithdrawFIAT requests a withdrawal from one of your wallets.
@@ -638,7 +627,7 @@ func (b *Bitfinex) WithdrawFIAT(withdrawType, wallet, wireCurrency,
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexWithdrawal, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexWithdrawal, request, &response)
}
// NewOrder submits a new order and returns a order information
@@ -660,7 +649,7 @@ func (b *Bitfinex) NewOrder(currencyPair string, amount float64, price float64,
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderNew, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderNew, request, &response)
}
// NewOrderMulti allows several new orders at once
@@ -670,7 +659,7 @@ func (b *Bitfinex) NewOrderMulti(orders []PlaceOrder) (OrderMultiResponse, error
request["orders"] = orders
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderNewMulti, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderNewMulti, request, &response)
}
// CancelExistingOrder cancels a single order by OrderID
@@ -680,7 +669,7 @@ func (b *Bitfinex) CancelExistingOrder(OrderID int64) (Order, error) {
request["order_id"] = OrderID
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderCancel, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderCancel, request, &response)
}
// CancelMultipleOrders cancels multiple orders
@@ -690,7 +679,7 @@ func (b *Bitfinex) CancelMultipleOrders(OrderIDs []int64) (string, error) {
request["order_ids"] = OrderIDs
return response.Result,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderCancelMulti, request, nil)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderCancelMulti, request, nil)
}
// CancelAllExistingOrders cancels all active and open orders
@@ -698,7 +687,7 @@ func (b *Bitfinex) CancelAllExistingOrders() (string, error) {
response := GenericResponse{}
return response.Result,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderCancelAll, nil, nil)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderCancelAll, nil, nil)
}
// ReplaceOrder replaces an older order with a new order
@@ -720,7 +709,7 @@ func (b *Bitfinex) ReplaceOrder(OrderID int64, Symbol string, Amount float64, Pr
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderCancelReplace, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderCancelReplace, request, &response)
}
// GetOrderStatus returns order status information
@@ -730,7 +719,7 @@ func (b *Bitfinex) GetOrderStatus(OrderID int64) (Order, error) {
request["order_id"] = OrderID
return orderStatus,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderStatus, request, &orderStatus)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderStatus, request, &orderStatus)
}
// GetInactiveOrders returns order status information
@@ -740,7 +729,7 @@ func (b *Bitfinex) GetInactiveOrders() ([]Order, error) {
request["limit"] = "100"
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexInactiveOrders, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexInactiveOrders, request, &response)
}
// GetOpenOrders returns all active orders and statuses
@@ -748,7 +737,7 @@ func (b *Bitfinex) GetOpenOrders() ([]Order, error) {
var response []Order
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrders, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrders, nil, &response)
}
// GetActivePositions returns an array of active positions
@@ -756,7 +745,7 @@ func (b *Bitfinex) GetActivePositions() ([]Position, error) {
response := []Position{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexPositions, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexPositions, nil, &response)
}
// ClaimPosition allows positions to be claimed
@@ -766,7 +755,7 @@ func (b *Bitfinex) ClaimPosition(PositionID int) (Position, error) {
request["position_id"] = PositionID
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexClaimPosition, nil, nil)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexClaimPosition, nil, nil)
}
// GetBalanceHistory returns balance history for the account
@@ -789,7 +778,7 @@ func (b *Bitfinex) GetBalanceHistory(symbol string, timeSince, timeUntil time.Ti
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexHistory, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexHistory, request, &response)
}
// GetMovementHistory returns an array of past deposits and withdrawals
@@ -812,7 +801,7 @@ func (b *Bitfinex) GetMovementHistory(symbol, method string, timeSince, timeUnti
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexHistoryMovements, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexHistoryMovements, request, &response)
}
// GetTradeHistory returns past executed trades
@@ -833,7 +822,7 @@ func (b *Bitfinex) GetTradeHistory(currencyPair string, timestamp, until time.Ti
}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexTradeHistory, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexTradeHistory, request, &response)
}
// NewOffer submits a new offer
@@ -847,7 +836,7 @@ func (b *Bitfinex) NewOffer(symbol string, amount, rate float64, period int64, d
request["direction"] = direction
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOfferNew, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOfferNew, request, &response)
}
// CancelOffer cancels offer by offerID
@@ -857,7 +846,7 @@ func (b *Bitfinex) CancelOffer(OfferID int64) (Offer, error) {
request["offer_id"] = OfferID
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOfferCancel, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOfferCancel, request, &response)
}
// GetOfferStatus checks offer status whether it has been cancelled, execute or
@@ -868,7 +857,7 @@ func (b *Bitfinex) GetOfferStatus(OfferID int64) (Offer, error) {
request["offer_id"] = OfferID
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOrderStatus, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOrderStatus, request, &response)
}
// GetActiveCredits returns all available credits
@@ -876,7 +865,7 @@ func (b *Bitfinex) GetActiveCredits() ([]Offer, error) {
response := []Offer{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexActiveCredits, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexActiveCredits, nil, &response)
}
// GetActiveOffers returns all current active offers
@@ -884,7 +873,7 @@ func (b *Bitfinex) GetActiveOffers() ([]Offer, error) {
response := []Offer{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexOffers, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexOffers, nil, &response)
}
// GetActiveMarginFunding returns an array of active margin funds
@@ -892,7 +881,7 @@ func (b *Bitfinex) GetActiveMarginFunding() ([]MarginFunds, error) {
response := []MarginFunds{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexMarginActiveFunds, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexMarginActiveFunds, nil, &response)
}
// GetUnusedMarginFunds returns an array of funding borrowed but not currently
@@ -901,7 +890,7 @@ func (b *Bitfinex) GetUnusedMarginFunds() ([]MarginFunds, error) {
response := []MarginFunds{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexMarginUnusedFunds, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexMarginUnusedFunds, nil, &response)
}
// GetMarginTotalTakenFunds returns an array of active funding used in a
@@ -910,7 +899,7 @@ func (b *Bitfinex) GetMarginTotalTakenFunds() ([]MarginTotalTakenFunds, error) {
response := []MarginTotalTakenFunds{}
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexMarginTotalFunds, nil, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexMarginTotalFunds, nil, &response)
}
// CloseMarginFunding closes an unused or used taken fund
@@ -920,12 +909,12 @@ func (b *Bitfinex) CloseMarginFunding(SwapID int64) (Offer, error) {
request["swap_id"] = SwapID
return response,
b.SendAuthenticatedHTTPRequest("POST", bitfinexMarginClose, request, &response)
b.SendAuthenticatedHTTPRequest(http.MethodPost, bitfinexMarginClose, request, &response)
}
// SendHTTPRequest sends an unauthenticated request
func (b *Bitfinex) SendHTTPRequest(path string, result interface{}, verbose bool) error {
return b.SendPayload("GET", path, nil, nil, result, false, verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, verbose)
}
// SendAuthenticatedHTTPRequest sends an autheticated http request and json
@@ -965,12 +954,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[
headers["X-BFX-PAYLOAD"] = PayloadBase64
headers["X-BFX-SIGNATURE"] = common.HexEncodeToString(hmac)
err = b.SendPayload(method, b.APIUrl+bitfinexAPIVersion+path, headers, nil, result, true, b.Verbose)
if err != nil {
return err
}
return nil
return b.SendPayload(method, b.APIUrl+bitfinexAPIVersion+path, headers, nil, result, true, b.Verbose)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -164,7 +164,7 @@ func (b *Bitfinex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]
}
// SubmitOrder submits a new order
func (b *Bitfinex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (b *Bitfinex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var isBuying bool
@@ -205,7 +205,7 @@ func (b *Bitfinex) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Bitfinex) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *Bitfinex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
_, err := b.CancelAllExistingOrders()
return exchange.CancelAllOrdersResponse{}, err
}

View File

@@ -3,6 +3,7 @@ package bitflyer
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -377,16 +378,17 @@ func (b *Bitflyer) GetTradingCommission() {
// SendHTTPRequest sends an unauthenticated request
func (b *Bitflyer) SendHTTPRequest(path string, result interface{}) error {
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, b.Verbose)
}
// SendAuthHTTPRequest sends an authenticated HTTP request
// Note: HTTP not done due to incorrect account privileges, please open a PR
// if you have access and update the authenticated requests
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(time.Now().UnixNano(), 10)
// TODO: Fill out this function once API access is obtained
func (b *Bitflyer) SendAuthHTTPRequest() {
//headers := make(map[string]string)
//headers["ACCESS-KEY"] = b.APIKey
//headers["ACCESS-TIMESTAMP"] = strconv.FormatInt(time.Now().UnixNano(), 10)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -171,7 +171,7 @@ func (b *Bitflyer) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Bitflyer) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *Bitflyer) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
// TODO, implement BitFlyer API
b.CancelAllExistingOrders()
return exchange.CancelAllOrdersResponse{}, common.ErrNotYetImplemented

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"strconv"
@@ -542,7 +543,7 @@ func (b *Bithumb) MarketSellOrder(currency string, units float64) (MarketSell, e
// SendHTTPRequest sends an unauthenticated HTTP request
func (b *Bithumb) SendHTTPRequest(path string, result interface{}) error {
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, b.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to bithumb
@@ -582,7 +583,7 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r
Message string `json:"message"`
}{}
err := b.SendPayload("POST",
err := b.SendPayload(http.MethodPost,
b.APIUrl+path,
headers,
bytes.NewBufferString(payload),

View File

@@ -170,7 +170,8 @@ func (b *Bithumb) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]e
}
// SubmitOrder submits a new order
func (b *Bithumb) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
// TODO: Fill this out to support limit orders
func (b *Bithumb) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, _ exchange.OrderType, amount, _ float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var err error
var orderID string
@@ -249,7 +250,7 @@ func (b *Bithumb) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Bithumb) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (b *Bithumb) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
addr, err := b.GetWalletAddress(cryptocurrency.String())
if err != nil {
return "", err

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
"time"
@@ -195,7 +196,7 @@ func (b *Bitmex) GetAnnouncement() ([]Announcement, error) {
func (b *Bitmex) GetUrgentAnnouncement() ([]Announcement, error) {
var announcement []Announcement
return announcement, b.SendAuthenticatedHTTPRequest("GET",
return announcement, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointAnnouncementUrgent,
nil,
&announcement)
@@ -205,7 +206,7 @@ func (b *Bitmex) GetUrgentAnnouncement() ([]Announcement, error) {
func (b *Bitmex) GetAPIKeys() ([]APIKey, error) {
var keys []APIKey
return keys, b.SendAuthenticatedHTTPRequest("GET",
return keys, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointAPIkeys,
nil,
&keys)
@@ -215,7 +216,7 @@ func (b *Bitmex) GetAPIKeys() ([]APIKey, error) {
func (b *Bitmex) RemoveAPIKey(params APIKeyParams) (bool, error) {
var keyDeleted bool
return keyDeleted, b.SendAuthenticatedHTTPRequest("DELETE",
return keyDeleted, b.SendAuthenticatedHTTPRequest(http.MethodDelete,
bitmexEndpointAPIkeys,
params,
&keyDeleted)
@@ -225,7 +226,7 @@ func (b *Bitmex) RemoveAPIKey(params APIKeyParams) (bool, error) {
func (b *Bitmex) DisableAPIKey(params APIKeyParams) (APIKey, error) {
var keyInfo APIKey
return keyInfo, b.SendAuthenticatedHTTPRequest("POST",
return keyInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointDisableAPIkey,
params,
&keyInfo)
@@ -235,7 +236,7 @@ func (b *Bitmex) DisableAPIKey(params APIKeyParams) (APIKey, error) {
func (b *Bitmex) EnableAPIKey(params APIKeyParams) (APIKey, error) {
var keyInfo APIKey
return keyInfo, b.SendAuthenticatedHTTPRequest("POST",
return keyInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointEnableAPIkey,
params,
&keyInfo)
@@ -252,7 +253,7 @@ func (b *Bitmex) GetTrollboxMessages(params ChatGetParams) ([]Chat, error) {
func (b *Bitmex) SendTrollboxMessage(params ChatSendParams) ([]Chat, error) {
var messages []Chat
return messages, b.SendAuthenticatedHTTPRequest("POST",
return messages, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointTrollboxSend,
params,
&messages)
@@ -280,7 +281,7 @@ func (b *Bitmex) GetTrollboxConnectedUsers() (ConnectedUsers, error) {
func (b *Bitmex) GetAccountExecutions(params GenericRequestParams) ([]Execution, error) {
var executionList []Execution
return executionList, b.SendAuthenticatedHTTPRequest("GET",
return executionList, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointExecution,
params,
&executionList)
@@ -291,7 +292,7 @@ func (b *Bitmex) GetAccountExecutions(params GenericRequestParams) ([]Execution,
func (b *Bitmex) GetAccountExecutionTradeHistory(params GenericRequestParams) ([]Execution, error) {
var tradeHistory []Execution
return tradeHistory, b.SendAuthenticatedHTTPRequest("GET",
return tradeHistory, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointExecutionTradeHistory,
params,
&tradeHistory)
@@ -393,7 +394,7 @@ func (b *Bitmex) GetLiquidationOrders(params GenericRequestParams) ([]Liquidatio
func (b *Bitmex) GetCurrentNotifications() ([]Notification, error) {
var notifications []Notification
return notifications, b.SendAuthenticatedHTTPRequest("GET",
return notifications, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointNotifications,
nil,
&notifications)
@@ -403,7 +404,7 @@ func (b *Bitmex) GetCurrentNotifications() ([]Notification, error) {
func (b *Bitmex) GetOrders(params OrdersRequest) ([]Order, error) {
var orders []Order
return orders, b.SendAuthenticatedHTTPRequest("GET",
return orders, b.SendAuthenticatedHTTPRequest(http.MethodGet,
fmt.Sprintf("%v%v", bitmexEndpointOrder, ""),
params,
&orders)
@@ -413,7 +414,7 @@ func (b *Bitmex) GetOrders(params OrdersRequest) ([]Order, error) {
func (b *Bitmex) AmendOrder(params OrderAmendParams) (Order, error) {
var order Order
return order, b.SendAuthenticatedHTTPRequest("PUT",
return order, b.SendAuthenticatedHTTPRequest(http.MethodPut,
bitmexEndpointOrder,
params,
&order)
@@ -423,7 +424,7 @@ func (b *Bitmex) AmendOrder(params OrderAmendParams) (Order, error) {
func (b *Bitmex) CreateOrder(params OrderNewParams) (Order, error) {
var orderInfo Order
return orderInfo, b.SendAuthenticatedHTTPRequest("POST",
return orderInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointOrder,
params,
&orderInfo)
@@ -434,7 +435,7 @@ func (b *Bitmex) CreateOrder(params OrderNewParams) (Order, error) {
func (b *Bitmex) CancelOrders(params OrderCancelParams) ([]Order, error) {
var cancelledOrders []Order
return cancelledOrders, b.SendAuthenticatedHTTPRequest("DELETE",
return cancelledOrders, b.SendAuthenticatedHTTPRequest(http.MethodDelete,
bitmexEndpointOrder,
params,
&cancelledOrders)
@@ -444,7 +445,7 @@ func (b *Bitmex) CancelOrders(params OrderCancelParams) ([]Order, error) {
func (b *Bitmex) CancelAllExistingOrders(params OrderCancelAllParams) ([]Order, error) {
var cancelledOrders []Order
return cancelledOrders, b.SendAuthenticatedHTTPRequest("DELETE",
return cancelledOrders, b.SendAuthenticatedHTTPRequest(http.MethodDelete,
bitmexEndpointCancelAllOrders,
params,
&cancelledOrders)
@@ -454,7 +455,7 @@ func (b *Bitmex) CancelAllExistingOrders(params OrderCancelAllParams) ([]Order,
func (b *Bitmex) AmendBulkOrders(params OrderAmendBulkParams) ([]Order, error) {
var amendedOrders []Order
return amendedOrders, b.SendAuthenticatedHTTPRequest("PUT",
return amendedOrders, b.SendAuthenticatedHTTPRequest(http.MethodPut,
bitmexEndpointBulk,
params,
&amendedOrders)
@@ -464,7 +465,7 @@ func (b *Bitmex) AmendBulkOrders(params OrderAmendBulkParams) ([]Order, error) {
func (b *Bitmex) CreateBulkOrders(params OrderNewBulkParams) ([]Order, error) {
var orders []Order
return orders, b.SendAuthenticatedHTTPRequest("POST",
return orders, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointBulk,
params,
&orders)
@@ -474,7 +475,7 @@ func (b *Bitmex) CreateBulkOrders(params OrderNewBulkParams) ([]Order, error) {
func (b *Bitmex) CancelAllOrdersAfterTime(params OrderCancelAllAfterParams) ([]Order, error) {
var cancelledOrder []Order
return cancelledOrder, b.SendAuthenticatedHTTPRequest("POST",
return cancelledOrder, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointCancelOrderAfter,
params,
&cancelledOrder)
@@ -484,7 +485,7 @@ func (b *Bitmex) CancelAllOrdersAfterTime(params OrderCancelAllAfterParams) ([]O
func (b *Bitmex) ClosePosition(params OrderClosePositionParams) ([]Order, error) {
var closedPositions []Order
return closedPositions, b.SendAuthenticatedHTTPRequest("POST",
return closedPositions, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointOrder,
params,
&closedPositions)
@@ -503,7 +504,7 @@ func (b *Bitmex) GetOrderbook(params OrderBookGetL2Params) ([]OrderBookL2, error
func (b *Bitmex) GetPositions(params PositionGetParams) ([]Position, error) {
var positions []Position
return positions, b.SendAuthenticatedHTTPRequest("GET",
return positions, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointPosition,
params,
&positions)
@@ -513,7 +514,7 @@ func (b *Bitmex) GetPositions(params PositionGetParams) ([]Position, error) {
func (b *Bitmex) IsolatePosition(params PositionIsolateMarginParams) (Position, error) {
var position Position
return position, b.SendAuthenticatedHTTPRequest("POST",
return position, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointIsolatePosition,
params,
&position)
@@ -523,7 +524,7 @@ func (b *Bitmex) IsolatePosition(params PositionIsolateMarginParams) (Position,
func (b *Bitmex) LeveragePosition(params PositionUpdateLeverageParams) (Position, error) {
var position Position
return position, b.SendAuthenticatedHTTPRequest("POST",
return position, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointLeveragePosition,
params,
&position)
@@ -533,7 +534,7 @@ func (b *Bitmex) LeveragePosition(params PositionUpdateLeverageParams) (Position
func (b *Bitmex) UpdateRiskLimit(params PositionUpdateRiskLimitParams) (Position, error) {
var position Position
return position, b.SendAuthenticatedHTTPRequest("POST",
return position, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointAdjustRiskLimit,
params,
&position)
@@ -543,7 +544,7 @@ func (b *Bitmex) UpdateRiskLimit(params PositionUpdateRiskLimitParams) (Position
func (b *Bitmex) TransferMargin(params PositionTransferIsolatedMarginParams) (Position, error) {
var position Position
return position, b.SendAuthenticatedHTTPRequest("POST",
return position, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointTransferMargin,
params,
&position)
@@ -617,7 +618,7 @@ func (b *Bitmex) GetPreviousTrades(params TradeGetBucketedParams) ([]Trade, erro
func (b *Bitmex) GetUserInfo() (User, error) {
var userInfo User
return userInfo, b.SendAuthenticatedHTTPRequest("GET",
return userInfo, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUser,
nil,
&userInfo)
@@ -627,7 +628,7 @@ func (b *Bitmex) GetUserInfo() (User, error) {
func (b *Bitmex) UpdateUserInfo(params UserUpdateParams) (User, error) {
var userInfo User
return userInfo, b.SendAuthenticatedHTTPRequest("PUT",
return userInfo, b.SendAuthenticatedHTTPRequest(http.MethodPut,
bitmexEndpointUser,
params,
&userInfo)
@@ -637,7 +638,7 @@ func (b *Bitmex) UpdateUserInfo(params UserUpdateParams) (User, error) {
func (b *Bitmex) GetAffiliateStatus() (AffiliateStatus, error) {
var status AffiliateStatus
return status, b.SendAuthenticatedHTTPRequest("GET",
return status, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserAffiliate,
nil,
&status)
@@ -647,7 +648,7 @@ func (b *Bitmex) GetAffiliateStatus() (AffiliateStatus, error) {
func (b *Bitmex) CancelWithdraw(token string) (TransactionInfo, error) {
var info TransactionInfo
return info, b.SendAuthenticatedHTTPRequest("POST",
return info, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserCancelWithdraw,
UserTokenParams{Token: token},
&info)
@@ -664,10 +665,10 @@ func (b *Bitmex) CheckReferalCode(referralCode string) (float64, error) {
}
// GetUserCommision returns your account's commission status.
func (b *Bitmex) GetUserCommision(token string) (UserCommission, error) {
func (b *Bitmex) GetUserCommision() (UserCommission, error) {
var commissionInfo UserCommission
return commissionInfo, b.SendAuthenticatedHTTPRequest("GET",
return commissionInfo, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserCommision,
nil,
&commissionInfo)
@@ -677,7 +678,7 @@ func (b *Bitmex) GetUserCommision(token string) (UserCommission, error) {
func (b *Bitmex) ConfirmEmail(token string) (ConfirmEmail, error) {
var confirmation ConfirmEmail
return confirmation, b.SendAuthenticatedHTTPRequest("GET",
return confirmation, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserConfirmEmail,
UserTokenParams{Token: token},
&confirmation)
@@ -687,7 +688,7 @@ func (b *Bitmex) ConfirmEmail(token string) (ConfirmEmail, error) {
func (b *Bitmex) ConfirmTwoFactorAuth(token, typ string) (bool, error) {
var working bool
return working, b.SendAuthenticatedHTTPRequest("POST",
return working, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserConfirmTFA,
UserConfirmTFAParams{Token: token, Type: typ},
&working)
@@ -697,7 +698,7 @@ func (b *Bitmex) ConfirmTwoFactorAuth(token, typ string) (bool, error) {
func (b *Bitmex) ConfirmWithdrawal(token string) (TransactionInfo, error) {
var info TransactionInfo
return info, b.SendAuthenticatedHTTPRequest("POST",
return info, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserCancelWithdraw,
UserTokenParams{Token: token},
&info)
@@ -713,7 +714,7 @@ func (b *Bitmex) GetCryptoDepositAddress(currency string) (string, error) {
currency)
}
return address, b.SendAuthenticatedHTTPRequest("GET",
return address, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserDepositAddress,
UserCurrencyParams{Currency: "XBt"},
&address)
@@ -723,7 +724,7 @@ func (b *Bitmex) GetCryptoDepositAddress(currency string) (string, error) {
func (b *Bitmex) DisableTFA(token, typ string) (bool, error) {
var disabled bool
return disabled, b.SendAuthenticatedHTTPRequest("POST",
return disabled, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserDisableTFA,
UserConfirmTFAParams{Token: token, Type: typ},
&disabled)
@@ -731,7 +732,7 @@ func (b *Bitmex) DisableTFA(token, typ string) (bool, error) {
// UserLogOut logs you out of BitMEX
func (b *Bitmex) UserLogOut() error {
return b.SendAuthenticatedHTTPRequest("POST",
return b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserLogout,
nil,
nil)
@@ -741,7 +742,7 @@ func (b *Bitmex) UserLogOut() error {
func (b *Bitmex) UserLogOutAll() (int64, error) {
var status int64
return status, b.SendAuthenticatedHTTPRequest("POST",
return status, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserLogoutAll,
nil,
&status)
@@ -751,7 +752,7 @@ func (b *Bitmex) UserLogOutAll() (int64, error) {
func (b *Bitmex) GetUserMargin(currency string) (UserMargin, error) {
var info UserMargin
return info, b.SendAuthenticatedHTTPRequest("GET",
return info, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserMargin,
UserCurrencyParams{Currency: currency},
&info)
@@ -761,7 +762,7 @@ func (b *Bitmex) GetUserMargin(currency string) (UserMargin, error) {
func (b *Bitmex) GetAllUserMargin() ([]UserMargin, error) {
var info []UserMargin
return info, b.SendAuthenticatedHTTPRequest("GET",
return info, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserMargin,
UserCurrencyParams{Currency: "all"},
&info)
@@ -771,7 +772,7 @@ func (b *Bitmex) GetAllUserMargin() ([]UserMargin, error) {
func (b *Bitmex) GetMinimumWithdrawalFee(currency string) (MinWithdrawalFee, error) {
var fee MinWithdrawalFee
return fee, b.SendAuthenticatedHTTPRequest("GET",
return fee, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserMinWithdrawalFee,
UserCurrencyParams{Currency: currency},
&fee)
@@ -781,7 +782,7 @@ func (b *Bitmex) GetMinimumWithdrawalFee(currency string) (MinWithdrawalFee, err
func (b *Bitmex) GetUserPreferences(params UserPreferencesParams) (User, error) {
var userInfo User
return userInfo, b.SendAuthenticatedHTTPRequest("POST",
return userInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserPreferences,
params,
&userInfo)
@@ -791,7 +792,7 @@ func (b *Bitmex) GetUserPreferences(params UserPreferencesParams) (User, error)
func (b *Bitmex) EnableTFA(typ string) (bool, error) {
var enabled bool
return enabled, b.SendAuthenticatedHTTPRequest("POST",
return enabled, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserRequestTFA,
UserConfirmTFAParams{Type: typ},
&enabled)
@@ -803,7 +804,7 @@ func (b *Bitmex) EnableTFA(typ string) (bool, error) {
func (b *Bitmex) UserRequestWithdrawal(params UserRequestWithdrawalParams) (TransactionInfo, error) {
var info TransactionInfo
return info, b.SendAuthenticatedHTTPRequest("POST",
return info, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointUserRequestWithdraw,
params,
&info)
@@ -813,7 +814,7 @@ func (b *Bitmex) UserRequestWithdrawal(params UserRequestWithdrawalParams) (Tran
func (b *Bitmex) GetWalletInfo(currency string) (WalletInfo, error) {
var info WalletInfo
return info, b.SendAuthenticatedHTTPRequest("GET",
return info, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserWallet,
UserCurrencyParams{Currency: currency},
&info)
@@ -823,7 +824,7 @@ func (b *Bitmex) GetWalletInfo(currency string) (WalletInfo, error) {
func (b *Bitmex) GetWalletHistory(currency string) ([]TransactionInfo, error) {
var info []TransactionInfo
return info, b.SendAuthenticatedHTTPRequest("GET",
return info, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserWalletHistory,
UserCurrencyParams{Currency: currency},
&info)
@@ -833,7 +834,7 @@ func (b *Bitmex) GetWalletHistory(currency string) ([]TransactionInfo, error) {
func (b *Bitmex) GetWalletSummary(currency string) ([]TransactionInfo, error) {
var info []TransactionInfo
return info, b.SendAuthenticatedHTTPRequest("GET",
return info, b.SendAuthenticatedHTTPRequest(http.MethodGet,
bitmexEndpointUserWalletSummary,
UserCurrencyParams{Currency: currency},
&info)
@@ -849,14 +850,14 @@ func (b *Bitmex) SendHTTPRequest(path string, params Parameter, result interface
if err != nil {
return err
}
err = b.SendPayload("GET", encodedPath, nil, nil, &respCheck, false, b.Verbose)
err = b.SendPayload(http.MethodGet, encodedPath, nil, nil, &respCheck, false, b.Verbose)
if err != nil {
return err
}
return b.CaptureError(respCheck, result)
}
}
err := b.SendPayload("GET", path, nil, nil, &respCheck, false, b.Verbose)
err := b.SendPayload(http.MethodGet, path, nil, nil, &respCheck, false, b.Verbose)
if err != nil {
return err
}
@@ -930,11 +931,7 @@ func (b *Bitmex) CaptureError(resp, reType interface{}) error {
Error.Error.Message)
}
err = common.JSONDecode(marshalled, reType)
if err != nil {
return err
}
return nil
return common.JSONDecode(marshalled, reType)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -236,6 +236,7 @@ func (b *Bitmex) wsHandleIncomingData() {
}
p := pair.NewCurrencyPairFromString(orderbooks.Data[0].Symbol)
// TODO: update this to support multiple asset types
err = b.processOrderbook(orderbooks.Data, orderbooks.Action, p, "CONTRACT")
if err != nil {
b.Websocket.DataHandler <- err
@@ -262,6 +263,7 @@ func (b *Bitmex) wsHandleIncomingData() {
continue
}
// TODO: update this to support multiple asset types
b.Websocket.DataHandler <- exchange.TradeData{
Timestamp: timestamp,
Price: trade.Price,
@@ -300,7 +302,7 @@ func (b *Bitmex) wsHandleIncomingData() {
var snapshotloaded = make(map[pair.CurrencyPair]map[string]bool)
// ProcessOrderbook processes orderbook updates
func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPair pair.CurrencyPair, assetType string) error {
func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPair pair.CurrencyPair, assetType string) error { // nolint: unparam
if len(data) < 1 {
return errors.New("bitmex_websocket.go error - no orderbook data")
}
@@ -379,7 +381,6 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai
err := b.Websocket.Orderbook.UpdateUsingID(bids,
asks,
currencyPair,
time.Now(),
b.GetName(),
assetType,
action)
@@ -421,12 +422,7 @@ func (b *Bitmex) websocketSubscribe() error {
// NOTE more added here in future
}
err := b.WebsocketConn.WriteJSON(subscriber)
if err != nil {
return err
}
return nil
return b.WebsocketConn.WriteJSON(subscriber)
}
// WebsocketSendAuth sends an authenticated subscription

View File

@@ -166,7 +166,7 @@ func (b *Bitmex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (b *Bitmex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (b *Bitmex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
if math.Mod(amount, 1) != 0 {
@@ -229,7 +229,7 @@ func (b *Bitmex) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Bitmex) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *Bitmex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -253,7 +253,7 @@ func (b *Bitmex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Bitmex) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (b *Bitmex) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
return b.GetCryptoDepositAddress(cryptocurrency.String())
}

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"strconv"
@@ -634,7 +635,7 @@ func (b *Bitstamp) TransferAccountBalance(amount float64, currency, subAccount s
// SendHTTPRequest sends an unauthenticated HTTP request
func (b *Bitstamp) SendHTTPRequest(path string, result interface{}) error {
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, b.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated request
@@ -680,7 +681,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url
Error string `json:"error"`
}{}
err := b.SendPayload("POST", path, headers, readerValues, &interim, true, b.Verbose)
err := b.SendPayload(http.MethodPost, path, headers, readerValues, &interim, true, b.Verbose)
if err != nil {
return err
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
)
// Please add your private keys and customerID for better tests
@@ -27,13 +27,13 @@ func TestSetDefaults(t *testing.T) {
if b.Name != "Bitstamp" {
t.Error("Test Failed - SetDefaults() error")
}
if b.Enabled != false {
if b.Enabled {
t.Error("Test Failed - SetDefaults() error")
}
if b.Verbose != false {
if b.Verbose {
t.Error("Test Failed - SetDefaults() error")
}
if b.Websocket.IsEnabled() != false {
if b.Websocket.IsEnabled() {
t.Error("Test Failed - SetDefaults() error")
}
if b.RESTPollingDelay != 10 {
@@ -268,7 +268,7 @@ func TestCancelExistingOrder(t *testing.T) {
t.Parallel()
resp, err := b.CancelExistingOrder(1337)
if err == nil || resp != false {
if err == nil || resp {
t.Error("Test Failed - CancelExistingOrder() error")
}
}

View File

@@ -176,7 +176,7 @@ func (b *Bitstamp) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]
}
// SubmitOrder submits a new order
func (b *Bitstamp) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (b *Bitstamp) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
buy := side == exchange.BuyOrderSide
market := orderType == exchange.MarketOrderType
@@ -212,7 +212,7 @@ func (b *Bitstamp) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Bitstamp) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *Bitstamp) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
isCancelAllSuccessful, err := b.CancelAllExistingOrders()
if !isCancelAllSuccessful {
err = errors.New("Cancel all failed. Bitstamp provides no further information. Check order status to verify")
@@ -228,7 +228,7 @@ func (b *Bitstamp) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Bitstamp) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (b *Bitstamp) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
return b.GetCryptoDepositAddress(cryptocurrency.String())
}

View File

@@ -3,6 +3,7 @@ package bittrex
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -393,6 +394,10 @@ func (b *Bittrex) Withdraw(currency, paymentID, address string, quantity float64
values.Set("currency", currency)
values.Set("quantity", fmt.Sprintf("%v", quantity))
values.Set("address", address)
if len(paymentID) > 0 {
values.Set("paymentid", paymentID)
}
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIWithdraw)
if err := b.SendAuthenticatedHTTPRequest(path, values, &id); err != nil {
@@ -487,7 +492,7 @@ func (b *Bittrex) GetDepositHistory(currency string) (WithdrawalHistory, error)
// SendHTTPRequest sends an unauthenticated HTTP request
func (b *Bittrex) SendHTTPRequest(path string, result interface{}) error {
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, b.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated http request to a desired
@@ -511,7 +516,7 @@ func (b *Bittrex) SendAuthenticatedHTTPRequest(path string, values url.Values, r
headers := make(map[string]string)
headers["apisign"] = common.HexEncodeToString(hmac)
return b.SendPayload("GET", rawQuery, headers, nil, result, true, b.Verbose)
return b.SendPayload(http.MethodGet, rawQuery, headers, nil, result, true, b.Verbose)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -178,7 +178,7 @@ func (b *Bittrex) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]e
}
// SubmitOrder submits a new order
func (b *Bittrex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (b *Bittrex) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
buy := side == exchange.BuyOrderSide
var response UUID
@@ -219,7 +219,7 @@ func (b *Bittrex) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Bittrex) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *Bittrex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -245,7 +245,7 @@ func (b *Bittrex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Bittrex) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (b *Bittrex) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
depositAddr, err := b.GetCryptoDepositAddress(cryptocurrency.String())
if err != nil {
return "", err

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"net/url"
"time"
@@ -196,7 +197,7 @@ func (b *BTCMarkets) NewOrder(currency, instrument string, price, amount float64
resp := Response{}
err := b.SendAuthenticatedRequest("POST", btcMarketsOrderCreate, order, &resp)
err := b.SendAuthenticatedRequest(http.MethodPost, btcMarketsOrderCreate, order, &resp)
if err != nil {
return 0, err
}
@@ -217,7 +218,7 @@ func (b *BTCMarkets) CancelExistingOrder(orderID []int64) ([]ResponseDetails, er
orders := CancelOrder{}
orders.OrderIDs = append(orders.OrderIDs, orderID...)
err := b.SendAuthenticatedRequest("POST", btcMarketsOrderCancel, orders, &resp)
err := b.SendAuthenticatedRequest(http.MethodPost, btcMarketsOrderCancel, orders, &resp)
if err != nil {
return resp.Responses, err
}
@@ -258,7 +259,7 @@ func (b *BTCMarkets) GetOrders(currency, instrument string, limit, since int64,
resp := Response{}
err := b.SendAuthenticatedRequest("POST", path, request, &resp)
err := b.SendAuthenticatedRequest(http.MethodPost, path, request, &resp)
if err != nil {
return nil, err
}
@@ -292,7 +293,7 @@ func (b *BTCMarkets) GetOpenOrders() ([]Order, error) {
var resp marketsResp
path := fmt.Sprintf("/v2/order/open")
err := b.SendAuthenticatedRequest("GET", path, request, &resp)
err := b.SendAuthenticatedRequest(http.MethodGet, path, request, &resp)
if err != nil {
return nil, err
}
@@ -327,7 +328,7 @@ func (b *BTCMarkets) GetOrderDetail(orderID []int64) ([]Order, error) {
resp := Response{}
err := b.SendAuthenticatedRequest("POST", btcMarketsOrderDetail, orders, &resp)
err := b.SendAuthenticatedRequest(http.MethodPost, btcMarketsOrderDetail, orders, &resp)
if err != nil {
return nil, err
}
@@ -354,7 +355,7 @@ func (b *BTCMarkets) GetOrderDetail(orderID []int64) ([]Order, error) {
func (b *BTCMarkets) GetAccountBalance() ([]AccountBalance, error) {
balance := []AccountBalance{}
err := b.SendAuthenticatedRequest("GET", btcMarketsAccountBalance, nil, &balance)
err := b.SendAuthenticatedRequest(http.MethodGet, btcMarketsAccountBalance, nil, &balance)
if err != nil {
return nil, err
}
@@ -371,7 +372,7 @@ func (b *BTCMarkets) GetAccountBalance() ([]AccountBalance, error) {
func (b *BTCMarkets) GetTradingFee(firstPair, secondPair string) (TradingFee, error) {
var tradingFee TradingFee
path := fmt.Sprintf(btcMarketsTradingFee, firstPair, secondPair)
return tradingFee, b.SendAuthenticatedRequest("GET", path, nil, &tradingFee)
return tradingFee, b.SendAuthenticatedRequest(http.MethodGet, path, nil, &tradingFee)
}
// WithdrawCrypto withdraws cryptocurrency into a designated address
@@ -385,7 +386,7 @@ func (b *BTCMarkets) WithdrawCrypto(amount float64, currency, address string) (s
}
resp := Response{}
err := b.SendAuthenticatedRequest("POST", btcMarketsWithdrawCrypto, req, &resp)
err := b.SendAuthenticatedRequest(http.MethodPost, btcMarketsWithdrawCrypto, req, &resp)
if err != nil {
return "", err
}
@@ -412,7 +413,7 @@ func (b *BTCMarkets) WithdrawAUD(accountName, accountNumber, bankName, bsbNumber
}
resp := Response{}
err := b.SendAuthenticatedRequest("POST", btcMarketsWithdrawAud, req, &resp)
err := b.SendAuthenticatedRequest(http.MethodPost, btcMarketsWithdrawAud, req, &resp)
if err != nil {
return "", err
}
@@ -426,7 +427,7 @@ func (b *BTCMarkets) WithdrawAUD(accountName, accountNumber, bankName, bsbNumber
// SendHTTPRequest sends an unauthenticated HTTP request
func (b *BTCMarkets) SendHTTPRequest(path string, result interface{}) error {
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
return b.SendPayload(http.MethodGet, path, nil, nil, result, false, b.Verbose)
}
// SendAuthenticatedRequest sends an authenticated HTTP request

View File

@@ -196,7 +196,7 @@ func (b *BTCMarkets) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *BTCMarkets) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (b *BTCMarkets) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -317,7 +318,7 @@ func (c *CoinbasePro) GetAccounts() ([]AccountResponse, error) {
resp := []AccountResponse{}
return resp,
c.SendAuthenticatedHTTPRequest("GET", coinbaseproAccounts, nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproAccounts, nil, &resp)
}
// GetAccount returns information for a single account. Use this endpoint when
@@ -326,7 +327,7 @@ func (c *CoinbasePro) GetAccount(accountID string) (AccountResponse, error) {
resp := AccountResponse{}
path := fmt.Sprintf("%s/%s", coinbaseproAccounts, accountID)
return resp, c.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
}
// GetAccountHistory returns a list of account activity. Account activity either
@@ -336,7 +337,7 @@ func (c *CoinbasePro) GetAccountHistory(accountID string) ([]AccountLedgerRespon
resp := []AccountLedgerResponse{}
path := fmt.Sprintf("%s/%s/%s", coinbaseproAccounts, accountID, coinbaseproLedger)
return resp, c.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
}
// GetHolds returns the holds that are placed on an account for any active
@@ -347,7 +348,7 @@ func (c *CoinbasePro) GetHolds(accountID string) ([]AccountHolds, error) {
resp := []AccountHolds{}
path := fmt.Sprintf("%s/%s/%s", coinbaseproAccounts, accountID, coinbaseproHolds)
return resp, c.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
}
// PlaceLimitOrder places a new limit order. Orders can only be placed if the
@@ -392,7 +393,7 @@ func (c *CoinbasePro) PlaceLimitOrder(clientRef string, price, amount float64, s
request["post_only"] = postOnly
}
err := c.SendAuthenticatedHTTPRequest("POST", coinbaseproOrders, request, &resp)
err := c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproOrders, request, &resp)
if err != nil {
return "", err
}
@@ -436,7 +437,7 @@ func (c *CoinbasePro) PlaceMarketOrder(clientRef string, size, funds float64, si
request["stp"] = stp
}
err := c.SendAuthenticatedHTTPRequest("POST", coinbaseproOrders, request, &resp)
err := c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproOrders, request, &resp)
if err != nil {
return "", err
}
@@ -479,7 +480,7 @@ func (c *CoinbasePro) PlaceMarginOrder(clientRef string, size, funds float64, si
request["stp"] = stp
}
err := c.SendAuthenticatedHTTPRequest("POST", coinbaseproOrders, request, &resp)
err := c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproOrders, request, &resp)
if err != nil {
return "", err
}
@@ -491,7 +492,7 @@ func (c *CoinbasePro) PlaceMarginOrder(clientRef string, size, funds float64, si
func (c *CoinbasePro) CancelExistingOrder(orderID string) error {
path := fmt.Sprintf("%s/%s", coinbaseproOrders, orderID)
return c.SendAuthenticatedHTTPRequest("DELETE", path, nil, nil)
return c.SendAuthenticatedHTTPRequest(http.MethodDelete, path, nil, nil)
}
// CancelAllExistingOrders cancels all open orders on the exchange and returns
@@ -505,7 +506,7 @@ func (c *CoinbasePro) CancelAllExistingOrders(currencyPair string) ([]string, er
if len(currencyPair) > 0 {
request["product_id"] = currencyPair
}
return resp, c.SendAuthenticatedHTTPRequest("DELETE", coinbaseproOrders, request, &resp)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodDelete, coinbaseproOrders, request, &resp)
}
// GetOrders lists current open orders. Only open or un-settled orders are
@@ -528,7 +529,7 @@ func (c *CoinbasePro) GetOrders(status []string, currencyPair string) ([]General
path = common.GetURIPath(path)
return resp,
c.SendAuthenticatedHTTPRequest("GET", path[1:], nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, path[1:], nil, &resp)
}
// GetOrder returns a single order by order id.
@@ -536,7 +537,7 @@ func (c *CoinbasePro) GetOrder(orderID string) (GeneralizedOrderResponse, error)
resp := GeneralizedOrderResponse{}
path := fmt.Sprintf("%s/%s", coinbaseproOrders, orderID)
return resp, c.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
}
// GetFills returns a list of recent fills
@@ -558,7 +559,7 @@ func (c *CoinbasePro) GetFills(orderID, currencyPair string) ([]FillResponse, er
uri := common.GetURIPath(path)
return resp,
c.SendAuthenticatedHTTPRequest("GET", uri[1:], nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, uri[1:], nil, &resp)
}
// GetFundingRecords every order placed with a margin profile that draws funding
@@ -574,7 +575,7 @@ func (c *CoinbasePro) GetFundingRecords(status string) ([]Funding, error) {
uri := common.GetURIPath(path)
return resp,
c.SendAuthenticatedHTTPRequest("GET", uri[1:], nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, uri[1:], nil, &resp)
}
////////////////////////// Not receiving reply from server /////////////////
@@ -589,7 +590,7 @@ func (c *CoinbasePro) GetFundingRecords(status string) ([]Funding, error) {
// params["currency"] = currency
//
// return resp,
// c.SendAuthenticatedHTTPRequest("POST", coinbaseproFundingRepay, params, &resp)
// c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproFundingRepay, params, &resp)
// }
// MarginTransfer sends funds between a standard/default profile and a margin
@@ -612,7 +613,7 @@ func (c *CoinbasePro) MarginTransfer(amount float64, transferType, profileID, cu
request["margin_profile_id"] = profileID
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproMarginTransfer, request, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproMarginTransfer, request, &resp)
}
// GetPosition returns an overview of account profile.
@@ -620,7 +621,7 @@ func (c *CoinbasePro) GetPosition() (AccountOverview, error) {
resp := AccountOverview{}
return resp,
c.SendAuthenticatedHTTPRequest("GET", coinbaseproPosition, nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproPosition, nil, &resp)
}
// ClosePosition closes a position and allowing you to repay position as well
@@ -631,7 +632,7 @@ func (c *CoinbasePro) ClosePosition(repayOnly bool) (AccountOverview, error) {
request["repay_only"] = repayOnly
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproPositionClose, request, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproPositionClose, request, &resp)
}
// GetPayMethods returns a full list of payment methods
@@ -639,7 +640,7 @@ func (c *CoinbasePro) GetPayMethods() ([]PaymentMethod, error) {
resp := []PaymentMethod{}
return resp,
c.SendAuthenticatedHTTPRequest("GET", coinbaseproPaymentMethod, nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproPaymentMethod, nil, &resp)
}
// DepositViaPaymentMethod deposits funds from a payment method. See the Payment
@@ -656,7 +657,7 @@ func (c *CoinbasePro) DepositViaPaymentMethod(amount float64, currency, paymentI
req["payment_method_id"] = paymentID
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproPaymentMethodDeposit, req, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproPaymentMethodDeposit, req, &resp)
}
// DepositViaCoinbase deposits funds from a coinbase account. Move funds between
@@ -675,7 +676,7 @@ func (c *CoinbasePro) DepositViaCoinbase(amount float64, currency, accountID str
req["coinbase_account_id"] = accountID
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproDepositCoinbase, req, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproDepositCoinbase, req, &resp)
}
// WithdrawViaPaymentMethod withdraws funds to a payment method
@@ -691,7 +692,7 @@ func (c *CoinbasePro) WithdrawViaPaymentMethod(amount float64, currency, payment
req["payment_method_id"] = paymentID
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproWithdrawalPaymentMethod, req, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproWithdrawalPaymentMethod, req, &resp)
}
///////////////////////// NO ROUTE FOUND ERROR ////////////////////////////////
@@ -708,7 +709,7 @@ func (c *CoinbasePro) WithdrawViaPaymentMethod(amount float64, currency, payment
// req["coinbase_account_id"] = accountID
//
// return resp,
// c.SendAuthenticatedHTTPRequest("POST", coinbaseproWithdrawalCoinbase, req, &resp)
// c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproWithdrawalCoinbase, req, &resp)
// }
// WithdrawCrypto withdraws funds to a crypto address
@@ -724,7 +725,7 @@ func (c *CoinbasePro) WithdrawCrypto(amount float64, currency, cryptoAddress str
req["crypto_address"] = cryptoAddress
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproWithdrawalCrypto, req, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproWithdrawalCrypto, req, &resp)
}
// GetCoinbaseAccounts returns a list of coinbase accounts
@@ -732,7 +733,7 @@ func (c *CoinbasePro) GetCoinbaseAccounts() ([]CoinbaseAccounts, error) {
resp := []CoinbaseAccounts{}
return resp,
c.SendAuthenticatedHTTPRequest("GET", coinbaseproCoinbaseAccounts, nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproCoinbaseAccounts, nil, &resp)
}
// GetReport returns batches of historic information about your account in
@@ -769,7 +770,7 @@ func (c *CoinbasePro) GetReport(reportType, startDate, endDate, currencyPair, ac
}
return resp,
c.SendAuthenticatedHTTPRequest("POST", coinbaseproReports, request, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodPost, coinbaseproReports, request, &resp)
}
// GetReportStatus once a report request has been accepted for processing, the
@@ -778,7 +779,7 @@ func (c *CoinbasePro) GetReportStatus(reportID string) (Report, error) {
resp := Report{}
path := fmt.Sprintf("%s/%s", coinbaseproReports, reportID)
return resp, c.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
}
// GetTrailingVolume this request will return your 30-day trailing volume for
@@ -787,12 +788,12 @@ func (c *CoinbasePro) GetTrailingVolume() ([]Volume, error) {
resp := []Volume{}
return resp,
c.SendAuthenticatedHTTPRequest("GET", coinbaseproTrailingVolume, nil, &resp)
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproTrailingVolume, nil, &resp)
}
// SendHTTPRequest sends an unauthenticated HTTP request
func (c *CoinbasePro) SendHTTPRequest(path string, result interface{}) error {
return c.SendPayload("GET", path, nil, nil, result, false, c.Verbose)
return c.SendPayload(http.MethodGet, path, nil, nil, result, false, c.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP reque

View File

@@ -154,7 +154,7 @@ func (c *CoinbasePro) GetExchangeHistory(p pair.CurrencyPair, assetType string)
}
// SubmitOrder submits a new order
func (c *CoinbasePro) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (c *CoinbasePro) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var response string
var err error
@@ -190,7 +190,7 @@ func (c *CoinbasePro) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (c *CoinbasePro) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (c *CoinbasePro) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
// CancellAllExisting orders returns a list of successful cancellations, we're only interested in failures
_, err := c.CancelAllExistingOrders("")
return exchange.CancelAllOrdersResponse{}, err

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
"github.com/gorilla/websocket"
@@ -293,7 +294,7 @@ func (c *COINUT) GetDerivativeInstruments(secType string) (interface{}, error) {
}
// GetOptionChain returns option chain
func (c *COINUT) GetOptionChain(asset, secType string, expiry int64) (OptionChainResponse, error) {
func (c *COINUT) GetOptionChain(asset, secType string) (OptionChainResponse, error) {
var result OptionChainResponse
params := make(map[string]interface{})
params["asset"] = asset
@@ -368,7 +369,7 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{
headers["Content-Type"] = "application/json"
var rawMsg json.RawMessage
err = c.SendPayload("POST", c.APIUrl, headers, bytes.NewBuffer(payload), &rawMsg, authenticated, c.Verbose)
err = c.SendPayload(http.MethodPost, c.APIUrl, headers, bytes.NewBuffer(payload), &rawMsg, authenticated, c.Verbose)
if err != nil {
return err
}

View File

@@ -290,7 +290,7 @@ func (c *COINUT) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (c *COINUT) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (c *COINUT) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
// TODO, this is a terrible implementation. Requires DB to improve
// Coinut provides no way of retrieving orders without a currency
// So we need to retrieve all currencies, then retrieve orders for each currency

View File

@@ -143,7 +143,7 @@ func TestSetAutoPairDefaults(t *testing.T) {
t.Fatalf("Test failed. TestSetAutoPairDefaults load config failed. Error %s", err)
}
if exch.SupportsAutoPairUpdates != false {
if exch.SupportsAutoPairUpdates {
t.Fatal("Test failed. TestSetAutoPairDefaults Incorrect value")
}
@@ -157,7 +157,7 @@ func TestSetAutoPairDefaults(t *testing.T) {
t.Fatalf("Test failed. TestSetAutoPairDefaults load config failed. Error %s", err)
}
if exch.SupportsAutoPairUpdates == false {
if !exch.SupportsAutoPairUpdates {
t.Fatal("Test failed. TestSetAutoPairDefaults Incorrect value")
}

View File

@@ -500,7 +500,6 @@ func (w *WebsocketOrderbookLocal) LoadSnapshot(newOrderbook orderbook.Base, exch
// UpdateUsingID updates orderbooks using specified ID
func (w *WebsocketOrderbookLocal) UpdateUsingID(bidTargets, askTargets []orderbook.Item,
p pair.CurrencyPair,
updated time.Time,
exchName, assetType, action string) error {
w.m.Lock()
defer w.m.Unlock()

View File

@@ -3,6 +3,7 @@ package exmo
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -162,7 +163,7 @@ func (e *EXMO) GetCurrency() ([]string, error) {
// GetUserInfo returns the user info
func (e *EXMO) GetUserInfo() (UserInfo, error) {
var result UserInfo
err := e.SendAuthenticatedHTTPRequest("POST", exmoUserInfo, url.Values{}, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoUserInfo, url.Values{}, &result)
return result, err
}
@@ -183,7 +184,7 @@ func (e *EXMO) CreateOrder(pair, orderType string, price, amount float64) (int64
v.Set("quantity", strconv.FormatFloat(amount, 'f', -1, 64))
var resp response
err := e.SendAuthenticatedHTTPRequest("POST", exmoOrderCreate, v, &resp)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoOrderCreate, v, &resp)
if !resp.Result {
return -1, errors.New(resp.Error)
}
@@ -199,7 +200,7 @@ func (e *EXMO) CancelExistingOrder(orderID int64) error {
Error string `json:"error"`
}
var resp response
err := e.SendAuthenticatedHTTPRequest("POST", exmoOrderCancel, v, &resp)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoOrderCancel, v, &resp)
if !resp.Result {
return errors.New(resp.Error)
}
@@ -209,7 +210,7 @@ func (e *EXMO) CancelExistingOrder(orderID int64) error {
// GetOpenOrders returns the users open orders
func (e *EXMO) GetOpenOrders() (map[string]OpenOrders, error) {
result := make(map[string]OpenOrders)
err := e.SendAuthenticatedHTTPRequest("POST", exmoOpenOrders, url.Values{}, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoOpenOrders, url.Values{}, &result)
return result, err
}
@@ -227,7 +228,7 @@ func (e *EXMO) GetUserTrades(pair, offset, limit string) (map[string][]UserTrade
v.Set("limit", limit)
}
err := e.SendAuthenticatedHTTPRequest("POST", exmoUserTrades, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoUserTrades, v, &result)
return result, err
}
@@ -244,7 +245,7 @@ func (e *EXMO) GetCancelledOrders(offset, limit string) ([]CancelledOrder, error
v.Set("limit", limit)
}
err := e.SendAuthenticatedHTTPRequest("POST", exmoCancelledOrders, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoCancelledOrders, v, &result)
return result, err
}
@@ -254,7 +255,7 @@ func (e *EXMO) GetOrderTrades(orderID int64) (OrderTrades, error) {
v := url.Values{}
v.Set("order_id", strconv.FormatInt(orderID, 10))
err := e.SendAuthenticatedHTTPRequest("POST", exmoOrderTrades, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoOrderTrades, v, &result)
return result, err
}
@@ -265,14 +266,14 @@ func (e *EXMO) GetRequiredAmount(pair string, amount float64) (RequiredAmount, e
v.Set("pair", pair)
v.Set("quantity", strconv.FormatFloat(amount, 'f', -1, 64))
var result RequiredAmount
err := e.SendAuthenticatedHTTPRequest("POST", exmoRequiredAmount, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoRequiredAmount, v, &result)
return result, err
}
// GetCryptoDepositAddress returns a list of addresses for cryptocurrency deposits
func (e *EXMO) GetCryptoDepositAddress() (map[string]string, error) {
var result interface{}
err := e.SendAuthenticatedHTTPRequest("POST", exmoDepositAddress, url.Values{}, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoDepositAddress, url.Values{}, &result)
if err != nil {
return nil, err
}
@@ -313,7 +314,7 @@ func (e *EXMO) WithdrawCryptocurrency(currency, address, invoice string, amount
v.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
var resp response
err := e.SendAuthenticatedHTTPRequest("POST", exmoWithdrawCrypt, v, &resp)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoWithdrawCrypt, v, &resp)
if err != nil {
return -1, err
}
@@ -334,7 +335,7 @@ func (e *EXMO) GetWithdrawTXID(taskID int64) (string, error) {
v.Set("task_id", strconv.FormatInt(taskID, 10))
var result response
err := e.SendAuthenticatedHTTPRequest("POST", exmoGetWithdrawTXID, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoGetWithdrawTXID, v, &result)
return result.TXID, err
}
@@ -345,7 +346,7 @@ func (e *EXMO) ExcodeCreate(currency string, amount float64) (ExcodeCreate, erro
v.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
var result ExcodeCreate
err := e.SendAuthenticatedHTTPRequest("POST", exmoExcodeCreate, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoExcodeCreate, v, &result)
return result, err
}
@@ -355,7 +356,7 @@ func (e *EXMO) ExcodeLoad(excode string) (ExcodeLoad, error) {
v.Set("code", excode)
var result ExcodeLoad
err := e.SendAuthenticatedHTTPRequest("POST", exmoExcodeLoad, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoExcodeLoad, v, &result)
return result, err
}
@@ -365,13 +366,13 @@ func (e *EXMO) GetWalletHistory(date int64) (WalletHistory, error) {
v.Set("date", strconv.FormatInt(date, 10))
var result WalletHistory
err := e.SendAuthenticatedHTTPRequest("POST", exmoWalletHistory, v, &result)
err := e.SendAuthenticatedHTTPRequest(http.MethodPost, exmoWalletHistory, v, &result)
return result, err
}
// SendHTTPRequest sends an unauthenticated HTTP request
func (e *EXMO) SendHTTPRequest(path string, result interface{}) error {
return e.SendPayload("GET", path, nil, nil, result, false, e.Verbose)
return e.SendPayload(http.MethodGet, path, nil, nil, result, false, e.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request

View File

@@ -185,7 +185,7 @@ func (e *EXMO) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exch
}
// SubmitOrder submits a new order
func (e *EXMO) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (e *EXMO) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var oT string
if orderType == exchange.LimitOrderType {
@@ -231,7 +231,7 @@ func (e *EXMO) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (e *EXMO) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (e *EXMO) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -257,7 +257,7 @@ func (e *EXMO) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (e *EXMO) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (e *EXMO) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
fullAddr, err := e.GetCryptoDepositAddress()
if err != nil {
return "", err

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"time"
@@ -189,13 +190,8 @@ func (g *Gateio) GetLatestSpotPrice(symbol string) (float64, error) {
// updated every 10 seconds
func (g *Gateio) GetTicker(symbol string) (TickerResponse, error) {
url := fmt.Sprintf("%s/%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioTicker, symbol)
var res TickerResponse
err := g.SendHTTPRequest(url, &res)
if err != nil {
return res, err
}
return res, nil
return res, g.SendHTTPRequest(url, &res)
}
// GetTickers returns tickers for all symbols
@@ -347,7 +343,7 @@ func (g *Gateio) GetBalances() (BalancesResponse, error) {
var result BalancesResponse
return result,
g.SendAuthenticatedHTTPRequest("POST", gateioBalances, "", &result)
g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioBalances, "", &result)
}
// SpotNewOrder places a new order
@@ -362,13 +358,7 @@ func (g *Gateio) SpotNewOrder(arg SpotNewOrderRequestParams) (SpotNewOrderRespon
)
strRequestURL := fmt.Sprintf("%s/%s", gateioOrder, arg.Type)
err := g.SendAuthenticatedHTTPRequest("POST", strRequestURL, params, &result)
if err != nil {
return result, err
}
return result, nil
return result, g.SendAuthenticatedHTTPRequest(http.MethodPost, strRequestURL, params, &result)
}
// CancelExistingOrder cancels an order given the supplied orderID and symbol
@@ -387,7 +377,7 @@ func (g *Gateio) CancelExistingOrder(orderID int64, symbol string) (bool, error)
orderID,
symbol,
)
err := g.SendAuthenticatedHTTPRequest("POST", gateioCancelOrder, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioCancelOrder, params, &result)
if err != nil {
return false, err
}
@@ -400,7 +390,7 @@ func (g *Gateio) CancelExistingOrder(orderID int64, symbol string) (bool, error)
// SendHTTPRequest sends an unauthenticated HTTP request
func (g *Gateio) SendHTTPRequest(path string, result interface{}) error {
return g.SendPayload("GET", path, nil, nil, result, false, g.Verbose)
return g.SendPayload(http.MethodGet, path, nil, nil, result, false, g.Verbose)
}
// CancelAllExistingOrders all orders for a given symbol and side
@@ -417,7 +407,7 @@ func (g *Gateio) CancelAllExistingOrders(orderType int64, symbol string) error {
orderType,
symbol,
)
err := g.SendAuthenticatedHTTPRequest("POST", gateioCancelAllOrders, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioCancelAllOrders, params, &result)
if err != nil {
return err
}
@@ -438,7 +428,7 @@ func (g *Gateio) GetOpenOrders(symbol string) (OpenOrdersResponse, error) {
params = fmt.Sprintf("currencyPair=%s", symbol)
}
err := g.SendAuthenticatedHTTPRequest("POST", gateioOpenOrders, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioOpenOrders, params, &result)
if err != nil {
return result, err
}
@@ -456,7 +446,7 @@ func (g *Gateio) GetTradeHistory(symbol string) (TradHistoryResponse, error) {
var result TradHistoryResponse
params = fmt.Sprintf("currencyPair=%s", symbol)
err := g.SendAuthenticatedHTTPRequest("POST", gateioTradeHistory, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioTradeHistory, params, &result)
if err != nil {
return result, err
}
@@ -560,7 +550,7 @@ func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (strin
address,
amount,
)
err := g.SendAuthenticatedHTTPRequest("POST", gateioWithdraw, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioWithdraw, params, &result)
if err != nil {
return "", err
}
@@ -568,7 +558,7 @@ func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (strin
return "", fmt.Errorf("code:%d message:%s", result.Code, result.Message)
}
return "", nil
return result.Message, nil
}
// GetCryptoDepositAddress returns a deposit address for a cryptocurrency
@@ -584,7 +574,7 @@ func (g *Gateio) GetCryptoDepositAddress(currency string) (string, error) {
params := fmt.Sprintf("currency=%s",
currency)
err := g.SendAuthenticatedHTTPRequest("POST", gateioDepositAddress, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioDepositAddress, params, &result)
if err != nil {
return "", err
}

View File

@@ -188,7 +188,8 @@ func (g *Gateio) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (g *Gateio) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
// TODO: support multiple order types (IOC)
func (g *Gateio) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, _ exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var orderTypeFormat SpotNewOrderRequestParamsType
@@ -237,7 +238,7 @@ func (g *Gateio) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (g *Gateio) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (g *Gateio) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -268,7 +269,7 @@ func (g *Gateio) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (g *Gateio) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (g *Gateio) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
addr, err := g.GetCryptoDepositAddress(cryptocurrency.String())
if err != nil {
return "", err

View File

@@ -3,6 +3,7 @@ package gemini
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -285,8 +286,8 @@ func (g *Gemini) GetAuctionHistory(currencyPair string, params url.Values) ([]Au
return auctionHist, g.SendHTTPRequest(path, &auctionHist)
}
func (g *Gemini) isCorrectSession(role string) error {
if g.Role != role {
func (g *Gemini) isCorrectSession() error {
if g.Role != geminiRoleTrader {
return errors.New("incorrect role for APIKEY cannot use this function")
}
return nil
@@ -295,7 +296,7 @@ func (g *Gemini) isCorrectSession(role string) error {
// NewOrder Only limit orders are supported through the API at present.
// returns order ID if successful
func (g *Gemini) NewOrder(symbol string, amount, price float64, side, orderType string) (int64, error) {
if err := g.isCorrectSession(geminiRoleTrader); err != nil {
if err := g.isCorrectSession(); err != nil {
return 0, err
}
@@ -307,7 +308,7 @@ func (g *Gemini) NewOrder(symbol string, amount, price float64, side, orderType
request["type"] = orderType
response := Order{}
err := g.SendAuthenticatedHTTPRequest("POST", geminiOrderNew, request, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiOrderNew, request, &response)
if err != nil {
return 0, err
}
@@ -321,7 +322,7 @@ func (g *Gemini) CancelExistingOrder(OrderID int64) (Order, error) {
request["order_id"] = OrderID
response := Order{}
err := g.SendAuthenticatedHTTPRequest("POST", geminiOrderCancel, request, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiOrderCancel, request, &response)
if err != nil {
return Order{}, err
}
@@ -343,7 +344,7 @@ func (g *Gemini) CancelExistingOrders(CancelBySession bool) (OrderResult, error)
path = geminiOrderCancelSession
}
err := g.SendAuthenticatedHTTPRequest("POST", path, nil, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, path, nil, &response)
if err != nil {
return response, err
}
@@ -360,7 +361,7 @@ func (g *Gemini) GetOrderStatus(orderID int64) (Order, error) {
response := Order{}
err := g.SendAuthenticatedHTTPRequest("POST", geminiOrderStatus, request, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiOrderStatus, request, &response)
if err != nil {
return response, err
}
@@ -379,7 +380,7 @@ func (g *Gemini) GetOrders() ([]Order, error) {
orders []Order
}
err := g.SendAuthenticatedHTTPRequest("POST", geminiOrders, nil, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiOrders, nil, &response)
if err != nil {
return nil, err
}
@@ -405,7 +406,7 @@ func (g *Gemini) GetTradeHistory(currencyPair string, timestamp int64) ([]TradeH
}
return response,
g.SendAuthenticatedHTTPRequest("POST", geminiMyTrades, request, &response)
g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiMyTrades, request, &response)
}
// GetNotionalVolume returns the volume in price currency that has been traded across all pairs over a period of 30 days
@@ -413,7 +414,7 @@ func (g *Gemini) GetNotionalVolume() (NotionalVolume, error) {
response := NotionalVolume{}
return response,
g.SendAuthenticatedHTTPRequest("POST", geminiVolume, nil, &response)
g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiVolume, nil, &response)
}
// GetTradeVolume returns a multi-arrayed volume response
@@ -421,7 +422,7 @@ func (g *Gemini) GetTradeVolume() ([][]TradeVolume, error) {
response := [][]TradeVolume{}
return response,
g.SendAuthenticatedHTTPRequest("POST", geminiTradeVolume, nil, &response)
g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiTradeVolume, nil, &response)
}
// GetBalances returns available balances in the supported currencies
@@ -429,14 +430,19 @@ func (g *Gemini) GetBalances() ([]Balance, error) {
response := []Balance{}
return response,
g.SendAuthenticatedHTTPRequest("POST", geminiBalances, nil, &response)
g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiBalances, nil, &response)
}
// GetCryptoDepositAddress returns a deposit address
func (g *Gemini) GetCryptoDepositAddress(depositAddlabel, currency string) (DepositAddress, error) {
response := DepositAddress{}
request := make(map[string]interface{})
err := g.SendAuthenticatedHTTPRequest("POST", geminiDeposit+"/"+currency+"/"+geminiNewAddress, nil, &response)
if len(depositAddlabel) > 0 {
request["label"] = depositAddlabel
}
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiDeposit+"/"+currency+"/"+geminiNewAddress, request, &response)
if err != nil {
return response, err
}
@@ -453,7 +459,7 @@ func (g *Gemini) WithdrawCrypto(address, currency string, amount float64) (Withd
request["address"] = address
request["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
err := g.SendAuthenticatedHTTPRequest("POST", geminiWithdraw+common.StringToLower(currency), request, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiWithdraw+common.StringToLower(currency), request, &response)
if err != nil {
return response, err
}
@@ -472,7 +478,7 @@ func (g *Gemini) PostHeartbeat() (string, error) {
}
response := Response{}
err := g.SendAuthenticatedHTTPRequest("POST", geminiHeartbeat, nil, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiHeartbeat, nil, &response)
if err != nil {
return response.Result, err
}
@@ -484,7 +490,7 @@ func (g *Gemini) PostHeartbeat() (string, error) {
// SendHTTPRequest sends an unauthenticated request
func (g *Gemini) SendHTTPRequest(path string, result interface{}) error {
return g.SendPayload("GET", path, nil, nil, result, false, g.Verbose)
return g.SendPayload(http.MethodGet, path, nil, nil, result, false, g.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to the

View File

@@ -139,7 +139,7 @@ func (g *Gemini) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (g *Gemini) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (g *Gemini) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := g.NewOrder(p.Pair().String(), amount, price, side.ToString(), orderType.ToString())
@@ -172,7 +172,7 @@ func (g *Gemini) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (g *Gemini) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (g *Gemini) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -195,7 +195,7 @@ func (g *Gemini) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (g *Gemini) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (g *Gemini) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
addr, err := g.GetCryptoDepositAddress("", cryptocurrency.String())
if err != nil {
return "", err

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -348,7 +349,7 @@ func (h *HitBTC) GetCandles(currencyPair, limit, period string) ([]ChartData, er
// GetBalances returns full balance for your account
func (h *HitBTC) GetBalances() (map[string]Balance, error) {
result := []Balance{}
err := h.SendAuthenticatedHTTPRequest("GET", apiV2Balance, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, apiV2Balance, url.Values{}, &result)
ret := make(map[string]Balance)
if err != nil {
@@ -367,7 +368,7 @@ func (h *HitBTC) GetDepositAddresses(currency string) (DepositCryptoAddresses, e
var resp DepositCryptoAddresses
return resp,
h.SendAuthenticatedHTTPRequest("GET",
h.SendAuthenticatedHTTPRequest(http.MethodGet,
apiV2CryptoAddress+"/"+currency,
url.Values{},
&resp)
@@ -376,7 +377,7 @@ func (h *HitBTC) GetDepositAddresses(currency string) (DepositCryptoAddresses, e
// GenerateNewAddress generates a new deposit address for a currency
func (h *HitBTC) GenerateNewAddress(currency string) (DepositCryptoAddresses, error) {
resp := DepositCryptoAddresses{}
err := h.SendAuthenticatedHTTPRequest("POST", apiV2CryptoAddress+"/"+currency, url.Values{}, &resp)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, apiV2CryptoAddress+"/"+currency, url.Values{}, &resp)
return resp, err
}
@@ -384,7 +385,7 @@ func (h *HitBTC) GenerateNewAddress(currency string) (DepositCryptoAddresses, er
// GetActiveorders returns all your active orders
func (h *HitBTC) GetActiveorders(currency string) ([]Order, error) {
resp := []Order{}
err := h.SendAuthenticatedHTTPRequest("GET", orders+"?symbol="+currency, url.Values{}, &resp)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, orders+"?symbol="+currency, url.Values{}, &resp)
return resp, err
}
@@ -404,11 +405,11 @@ func (h *HitBTC) GetTradeHistoryForCurrency(currency, start, end string) (Authen
values.Set("currencyPair", currency)
result := AuthenticatedTradeHistoryResponse{}
return result, h.SendAuthenticatedHTTPRequest("POST", apiV2TradeHistory, values, &result.Data)
return result, h.SendAuthenticatedHTTPRequest(http.MethodPost, apiV2TradeHistory, values, &result.Data)
}
// GetTradeHistoryForAllCurrencies returns your trade history
func (h *HitBTC) GetTradeHistoryForAllCurrencies(currency, start, end string) (AuthenticatedTradeHistoryAll, error) {
func (h *HitBTC) GetTradeHistoryForAllCurrencies(start, end string) (AuthenticatedTradeHistoryAll, error) {
values := url.Values{}
if start != "" {
@@ -422,7 +423,7 @@ func (h *HitBTC) GetTradeHistoryForAllCurrencies(currency, start, end string) (A
values.Set("currencyPair", "all")
result := AuthenticatedTradeHistoryAll{}
return result, h.SendAuthenticatedHTTPRequest("POST", apiV2TradeHistory, values, &result.Data)
return result, h.SendAuthenticatedHTTPRequest(http.MethodPost, apiV2TradeHistory, values, &result.Data)
}
// GetOrders List of your order history.
@@ -431,7 +432,7 @@ func (h *HitBTC) GetOrders(currency string) ([]OrderHistoryResponse, error) {
values.Set("symbol", currency)
var result []OrderHistoryResponse
return result, h.SendAuthenticatedHTTPRequest("GET", apiV2OrderHistory, values, &result)
return result, h.SendAuthenticatedHTTPRequest(http.MethodGet, apiV2OrderHistory, values, &result)
}
// GetOpenOrders List of your currently open orders.
@@ -440,7 +441,7 @@ func (h *HitBTC) GetOpenOrders(currency string) ([]OrderHistoryResponse, error)
values.Set("symbol", currency)
var result []OrderHistoryResponse
return result, h.SendAuthenticatedHTTPRequest("GET", apiv2OpenOrders, values, &result)
return result, h.SendAuthenticatedHTTPRequest(http.MethodGet, apiv2OpenOrders, values, &result)
}
// PlaceOrder places an order on the exchange
@@ -453,14 +454,9 @@ func (h *HitBTC) PlaceOrder(currency string, rate, amount float64, orderType, si
values.Set("quantity", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("side", side)
values.Set("price", strconv.FormatFloat(rate, 'f', -1, 64))
values.Set("type", orderType)
err := h.SendAuthenticatedHTTPRequest("POST", orderBuy, values, &result)
if err != nil {
return result, err
}
return result, nil
return result, h.SendAuthenticatedHTTPRequest(http.MethodPost, orderBuy, values, &result)
}
// CancelExistingOrder cancels a specific order by OrderID
@@ -468,7 +464,7 @@ func (h *HitBTC) CancelExistingOrder(orderID int64) (bool, error) {
result := GenericResponse{}
values := url.Values{}
err := h.SendAuthenticatedHTTPRequest("DELETE", orderBuy+"/"+strconv.FormatInt(orderID, 10), values, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodDelete, orderBuy+"/"+strconv.FormatInt(orderID, 10), values, &result)
if err != nil {
return false, err
@@ -485,13 +481,7 @@ func (h *HitBTC) CancelExistingOrder(orderID int64) (bool, error) {
func (h *HitBTC) CancelAllExistingOrders() ([]Order, error) {
var result []Order
values := url.Values{}
err := h.SendAuthenticatedHTTPRequest("DELETE", orderBuy, values, &result)
if err != nil {
return result, err
}
return result, nil
return result, h.SendAuthenticatedHTTPRequest(http.MethodDelete, orderBuy, values, &result)
}
// MoveOrder generates a new move order
@@ -505,7 +495,7 @@ func (h *HitBTC) MoveOrder(orderID int64, rate, amount float64) (MoveOrderRespon
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
}
err := h.SendAuthenticatedHTTPRequest("POST", orderMove, values, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, orderMove, values, &result)
if err != nil {
return result, err
@@ -527,7 +517,7 @@ func (h *HitBTC) Withdraw(currency, address string, amount float64) (bool, error
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("address", address)
err := h.SendAuthenticatedHTTPRequest("POST", apiV2CryptoWithdraw, values, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, apiV2CryptoWithdraw, values, &result)
if err != nil {
return false, err
@@ -543,7 +533,7 @@ func (h *HitBTC) Withdraw(currency, address string, amount float64) (bool, error
// GetFeeInfo returns current fee information
func (h *HitBTC) GetFeeInfo(currencyPair string) (Fee, error) {
result := Fee{}
err := h.SendAuthenticatedHTTPRequest("GET", apiV2FeeInfo+"/"+currencyPair, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, apiV2FeeInfo+"/"+currencyPair, url.Values{}, &result)
return result, err
}
@@ -555,7 +545,7 @@ func (h *HitBTC) GetTradableBalances() (map[string]map[string]float64, error) {
}
result := Response{}
err := h.SendAuthenticatedHTTPRequest("POST", tradableBalances, url.Values{}, &result.Data)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, tradableBalances, url.Values{}, &result.Data)
if err != nil {
return nil, err
@@ -583,7 +573,7 @@ func (h *HitBTC) TransferBalance(currency, from, to string, amount float64) (boo
values.Set("fromAccount", from)
values.Set("toAccount", to)
err := h.SendAuthenticatedHTTPRequest("POST", transferBalance, values, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, transferBalance, values, &result)
if err != nil {
return false, err
@@ -598,7 +588,7 @@ func (h *HitBTC) TransferBalance(currency, from, to string, amount float64) (boo
// SendHTTPRequest sends an unauthenticated HTTP request
func (h *HitBTC) SendHTTPRequest(path string, result interface{}) error {
return h.SendPayload("GET", path, nil, nil, result, false, h.Verbose)
return h.SendPayload(http.MethodGet, path, nil, nil, result, false, h.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated http request

View File

@@ -44,12 +44,7 @@ func (h *HitBTC) WsConnect() error {
go h.WsHandleData()
err = h.WsSubscribe()
if err != nil {
return err
}
return nil
return h.WsSubscribe()
}
// WsSubscribe subscribes to the relevant channels

View File

@@ -166,7 +166,7 @@ func (h *HitBTC) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (h *HitBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (h *HitBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := h.PlaceOrder(p.Pair().String(), price, amount, common.StringToLower(orderType.ToString()), common.StringToLower(side.ToString()))
@@ -201,7 +201,7 @@ func (h *HitBTC) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (h *HitBTC) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (h *HitBTC) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -224,7 +224,7 @@ func (h *HitBTC) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (h *HitBTC) GetDepositAddress(currency pair.CurrencyItem, accountID string) (string, error) {
func (h *HitBTC) GetDepositAddress(currency pair.CurrencyItem, _ string) (string, error) {
resp, err := h.GetDepositAddresses(currency.String())
if err != nil {
return "", err

View File

@@ -358,7 +358,7 @@ func (h *HUOBI) GetAccounts() ([]Account, error) {
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobiAccounts, url.Values{}, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobiAccounts, url.Values{}, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -379,7 +379,7 @@ func (h *HUOBI) GetAccountBalance(accountID string) ([]AccountBalanceDetail, err
v := url.Values{}
v.Set("account-id", accountID)
err := h.SendAuthenticatedHTTPRequest("GET", endpoint, v, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, endpoint, v, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -418,7 +418,7 @@ func (h *HUOBI) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", huobiOrderPlace, nil, data, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, huobiOrderPlace, nil, data, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -435,7 +435,7 @@ func (h *HUOBI) CancelExistingOrder(orderID int64) (int64, error) {
var result response
endpoint := fmt.Sprintf(huobiOrderCancel, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("POST", endpoint, url.Values{}, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, endpoint, url.Values{}, nil, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -444,14 +444,14 @@ func (h *HUOBI) CancelExistingOrder(orderID int64) (int64, error) {
}
// CancelOrderBatch cancels a batch of orders -- to-do
func (h *HUOBI) CancelOrderBatch(orderIDs []int64) ([]CancelOrderBatch, error) {
func (h *HUOBI) CancelOrderBatch(_ []int64) ([]CancelOrderBatch, error) {
type response struct {
Response
Data []CancelOrderBatch `json:"data"`
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", huobiOrderCancelBatch, url.Values{}, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, huobiOrderCancelBatch, url.Values{}, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -474,7 +474,7 @@ func (h *HUOBI) CancelOpenOrdersBatch(accountID, symbol string) (CancelOpenOrder
Symbol: symbol,
}
err := h.SendAuthenticatedHTTPRequest("POST", huobiBatchCancelOpenOrders, url.Values{}, data, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, huobiBatchCancelOpenOrders, url.Values{}, data, &result)
if result.Data.FailedCount > 0 {
return result, fmt.Errorf("There were %v failed order cancellations", result.Data.FailedCount)
}
@@ -491,7 +491,7 @@ func (h *HUOBI) GetOrder(orderID int64) (OrderInfo, error) {
var result response
endpoint := fmt.Sprintf(huobiGetOrder, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("GET", endpoint, url.Values{}, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, endpoint, url.Values{}, nil, &result)
if result.ErrorMessage != "" {
return result.Order, errors.New(result.ErrorMessage)
@@ -508,7 +508,7 @@ func (h *HUOBI) GetOrderMatchResults(orderID int64) ([]OrderMatchInfo, error) {
var result response
endpoint := fmt.Sprintf(huobiGetOrderMatch, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("GET", endpoint, url.Values{}, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, endpoint, url.Values{}, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -552,7 +552,7 @@ func (h *HUOBI) GetOrders(symbol, types, start, end, states, from, direct, size
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobiGetOrders, vals, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobiGetOrders, vals, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -576,7 +576,7 @@ func (h *HUOBI) GetOpenOrders(accountID, symbol, side string, size int) ([]Order
vals.Set("size", fmt.Sprintf("%v", size))
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobiGetOpenOrders, vals, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobiGetOpenOrders, vals, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -620,7 +620,7 @@ func (h *HUOBI) GetOrdersMatch(symbol, types, start, end, from, direct, size str
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobiGetOrdersMatch, vals, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobiGetOrdersMatch, vals, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -651,7 +651,7 @@ func (h *HUOBI) MarginTransfer(symbol, currency string, amount float64, in bool)
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", path, nil, data, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, path, nil, data, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -677,7 +677,7 @@ func (h *HUOBI) MarginOrder(symbol, currency string, amount float64) (int64, err
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", huobiMarginOrders, nil, data, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, huobiMarginOrders, nil, data, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -700,7 +700,7 @@ func (h *HUOBI) MarginRepayment(orderID int64, amount float64) (int64, error) {
var result response
endpoint := fmt.Sprintf(huobiMarginRepay, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("POST", endpoint, nil, data, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, endpoint, nil, data, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -744,7 +744,7 @@ func (h *HUOBI) GetMarginLoanOrders(symbol, currency, start, end, states, from,
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobiMarginLoanOrders, vals, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobiMarginLoanOrders, vals, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -765,7 +765,7 @@ func (h *HUOBI) GetMarginAccountBalance(symbol string) ([]MarginAccountBalance,
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobiMarginAccountBalance, vals, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobiMarginAccountBalance, vals, nil, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -801,7 +801,7 @@ func (h *HUOBI) Withdraw(address, currency, addrTag string, amount, fee float64)
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", huobiWithdrawCreate, nil, data, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, huobiWithdrawCreate, nil, data, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -821,7 +821,7 @@ func (h *HUOBI) CancelWithdraw(withdrawID int64) (int64, error) {
var result response
endpoint := fmt.Sprintf(huobiWithdrawCancel, strconv.FormatInt(withdrawID, 10))
err := h.SendAuthenticatedHTTPRequest("POST", endpoint, vals, nil, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, endpoint, vals, nil, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -831,7 +831,7 @@ func (h *HUOBI) CancelWithdraw(withdrawID int64) (int64, error) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (h *HUOBI) SendHTTPRequest(path string, result interface{}) error {
return h.SendPayload("GET", path, nil, nil, result, false, h.Verbose)
return h.SendPayload(http.MethodGet, path, nil, nil, result, false, h.Verbose)
}
// SendAuthenticatedHTTPRequest sends authenticated requests to the HUOBI API

View File

@@ -51,12 +51,7 @@ func (h *HUOBI) WsConnect() error {
go h.WsHandleData()
err = h.WsSubscribe()
if err != nil {
return err
}
return nil
return h.WsSubscribe()
}
// WsReadData reads data from the websocket connection

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -351,7 +352,7 @@ func (h *HUOBIHADAX) GetAccounts() ([]Account, error) {
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobihadaxAccounts, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobihadaxAccounts, url.Values{}, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -368,7 +369,7 @@ func (h *HUOBIHADAX) GetAccountBalance(accountID string) ([]AccountBalanceDetail
var result response
endpoint := fmt.Sprintf("%s/%s", huobihadaxAPIName, fmt.Sprintf(huobihadaxAccountBalance, accountID))
err := h.SendAuthenticatedHTTPRequest("GET", endpoint, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, endpoint, url.Values{}, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -409,7 +410,7 @@ func (h *HUOBIHADAX) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error)
var result response
endpoint := fmt.Sprintf("%s/%s", huobihadaxAPIName, huobihadaxOrderPlace)
err := h.SendAuthenticatedHTTPPostRequest("POST", endpoint, postBodyParams, &result)
err := h.SendAuthenticatedHTTPPostRequest(http.MethodPost, endpoint, postBodyParams, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -426,7 +427,7 @@ func (h *HUOBIHADAX) CancelExistingOrder(orderID int64) (int64, error) {
var result response
endpoint := fmt.Sprintf(huobihadaxOrderCancel, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("POST", endpoint, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, endpoint, url.Values{}, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -451,7 +452,7 @@ func (h *HUOBIHADAX) CancelOrderBatch(orderIDs []int64) (CancelOrderBatch, error
postBodyParams := string(bytesParams)
var result response
err := h.SendAuthenticatedHTTPPostRequest("POST", huobihadaxOrderCancelBatch, postBodyParams, &result)
err := h.SendAuthenticatedHTTPPostRequest(http.MethodPost, huobihadaxOrderCancelBatch, postBodyParams, &result)
if len(result.Data.Failed) != 0 {
errJSON, _ := common.JSONEncode(result.Data.Failed)
@@ -478,7 +479,7 @@ func (h *HUOBIHADAX) CancelOpenOrdersBatch(accountID, symbol string) (CancelOpen
bytesParams, _ := common.JSONEncode(data)
postBodyParams := string(bytesParams)
err := h.SendAuthenticatedHTTPPostRequest("POST", huobiHadaxBatchCancelOpenOrders, postBodyParams, &result)
err := h.SendAuthenticatedHTTPPostRequest(http.MethodPost, huobiHadaxBatchCancelOpenOrders, postBodyParams, &result)
if result.Data.FailedCount > 0 {
return result, fmt.Errorf("There were %v failed order cancellations", result.Data.FailedCount)
@@ -503,7 +504,7 @@ func (h *HUOBIHADAX) GetOpenOrders(accountID, symbol, side string, size int) ([]
vals.Set("size", fmt.Sprintf("%v", size))
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobihadaxGetOpenOrders, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobihadaxGetOpenOrders, vals, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -521,7 +522,7 @@ func (h *HUOBIHADAX) GetOrder(orderID int64) (OrderInfo, error) {
var result response
endpoint := fmt.Sprintf(huobihadaxGetOrder, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("GET", endpoint, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, endpoint, url.Values{}, &result)
if result.ErrorMessage != "" {
return result.Order, errors.New(result.ErrorMessage)
@@ -538,7 +539,7 @@ func (h *HUOBIHADAX) GetOrderMatchResults(orderID int64) ([]OrderMatchInfo, erro
var result response
endpoint := fmt.Sprintf(huobihadaxGetOrderMatch, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("GET", endpoint, url.Values{}, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, endpoint, url.Values{}, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -582,7 +583,7 @@ func (h *HUOBIHADAX) GetOrders(symbol, types, start, end, states, from, direct,
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobihadaxGetOrders, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobihadaxGetOrders, vals, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -625,7 +626,7 @@ func (h *HUOBIHADAX) GetOrdersMatch(symbol, types, start, end, from, direct, siz
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobihadaxGetOrdersMatch, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobihadaxGetOrdersMatch, vals, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -651,7 +652,7 @@ func (h *HUOBIHADAX) MarginTransfer(symbol, currency string, amount float64, in
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", path, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, path, vals, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -672,7 +673,7 @@ func (h *HUOBIHADAX) MarginOrder(symbol, currency string, amount float64) (int64
}
var result response
err := h.SendAuthenticatedHTTPRequest("POST", huobihadaxMarginOrders, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, huobihadaxMarginOrders, vals, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -693,7 +694,7 @@ func (h *HUOBIHADAX) MarginRepayment(orderID int64, amount float64) (int64, erro
var result response
endpoint := fmt.Sprintf(huobihadaxMarginRepay, strconv.FormatInt(orderID, 10))
err := h.SendAuthenticatedHTTPRequest("POST", endpoint, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, endpoint, vals, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -737,7 +738,7 @@ func (h *HUOBIHADAX) GetMarginLoanOrders(symbol, currency, start, end, states, f
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobihadaxMarginLoanOrders, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobihadaxMarginLoanOrders, vals, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -758,7 +759,7 @@ func (h *HUOBIHADAX) GetMarginAccountBalance(symbol string) ([]MarginAccountBala
}
var result response
err := h.SendAuthenticatedHTTPRequest("GET", huobihadaxMarginAccountBalance, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, huobihadaxMarginAccountBalance, vals, &result)
if result.ErrorMessage != "" {
return nil, errors.New(result.ErrorMessage)
@@ -795,7 +796,7 @@ func (h *HUOBIHADAX) Withdraw(address, currency, addrTag string, amount, fee flo
var result response
bytesParams, _ := common.JSONEncode(data)
postBodyParams := string(bytesParams)
err := h.SendAuthenticatedHTTPPostRequest("POST", huobihadaxWithdrawCreate, postBodyParams, &result)
err := h.SendAuthenticatedHTTPPostRequest(http.MethodPost, huobihadaxWithdrawCreate, postBodyParams, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -815,7 +816,7 @@ func (h *HUOBIHADAX) CancelWithdraw(withdrawID int64) (int64, error) {
var result response
endpoint := fmt.Sprintf(huobihadaxWithdrawCancel, strconv.FormatInt(withdrawID, 10))
err := h.SendAuthenticatedHTTPRequest("POST", endpoint, vals, &result)
err := h.SendAuthenticatedHTTPRequest(http.MethodPost, endpoint, vals, &result)
if result.ErrorMessage != "" {
return 0, errors.New(result.ErrorMessage)
@@ -825,7 +826,7 @@ func (h *HUOBIHADAX) CancelWithdraw(withdrawID int64) (int64, error) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (h *HUOBIHADAX) SendHTTPRequest(path string, result interface{}) error {
return h.SendPayload("GET", path, nil, nil, result, false, h.Verbose)
return h.SendPayload(http.MethodGet, path, nil, nil, result, false, h.Verbose)
}
// SendAuthenticatedHTTPPostRequest sends authenticated requests to the HUOBI API
@@ -922,7 +923,7 @@ func (h *HUOBIHADAX) GetDepositWithdrawalHistory(associatedID string, currency s
vals.Set("size", strconv.FormatInt(size, 10))
vals.Set("currency", common.StringToLower(currency))
err := h.SendAuthenticatedHTTPRequest("GET",
err := h.SendAuthenticatedHTTPRequest(http.MethodGet,
huobiHadaxDepositAddress,
vals,
&resp)

View File

@@ -51,12 +51,7 @@ func (h *HUOBIHADAX) WsConnect() error {
go h.WsHandleData()
err = h.WsSubscribe()
if err != nil {
return err
}
return nil
return h.WsSubscribe()
}
// WsReadData reads data from the websocket connection

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -145,7 +146,7 @@ func (i *ItBit) GetWallets(params url.Values) ([]Wallet, error) {
params.Set("userId", i.ClientID)
path := fmt.Sprintf("/%s?%s", itbitWallets, params.Encode())
return resp, i.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
return resp, i.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
}
// CreateWallet creates a new wallet with a specified name.
@@ -155,7 +156,7 @@ func (i *ItBit) CreateWallet(walletName string) (Wallet, error) {
params["userId"] = i.ClientID
params["name"] = walletName
err := i.SendAuthenticatedHTTPRequest("POST", "/"+itbitWallets, params, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodPost, "/"+itbitWallets, params, &resp)
if err != nil {
return resp, err
}
@@ -170,7 +171,7 @@ func (i *ItBit) GetWallet(walletID string) (Wallet, error) {
resp := Wallet{}
path := fmt.Sprintf("/%s/%s", itbitWallets, walletID)
err := i.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
if err != nil {
return resp, err
}
@@ -186,7 +187,7 @@ func (i *ItBit) GetWalletBalance(walletID, currency string) (Balance, error) {
resp := Balance{}
path := fmt.Sprintf("/%s/%s/%s/%s", itbitWallets, walletID, itbitBalances, currency)
err := i.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
if err != nil {
return resp, err
}
@@ -216,12 +217,7 @@ func (i *ItBit) GetOrders(walletID, symbol, status string, page, perPage int64)
params["perPage"] = strconv.FormatInt(perPage, 10)
}
err := i.SendAuthenticatedHTTPRequest("GET", itbitOrders, params, &resp)
if err != nil {
return resp, err
}
return resp, nil
return resp, i.SendAuthenticatedHTTPRequest(http.MethodGet, itbitOrders, params, &resp)
}
// GetWalletTrades returns all trades for a specified wallet.
@@ -230,7 +226,7 @@ func (i *ItBit) GetWalletTrades(walletID string, params url.Values) (Records, er
url := fmt.Sprintf("/%s/%s/%s", itbitWallets, walletID, itbitTrades)
path := common.EncodeURLValues(url, params)
err := i.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
if err != nil {
return resp, err
}
@@ -246,7 +242,7 @@ func (i *ItBit) GetFundingHistoryForWallet(walletID string, params url.Values) (
url := fmt.Sprintf("/%s/%s/%s", itbitWallets, walletID, itbitFundingHistory)
path := common.EncodeURLValues(url, params)
err := i.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
if err != nil {
return resp, err
}
@@ -273,7 +269,7 @@ func (i *ItBit) PlaceOrder(walletID, side, orderType, currency string, amount, p
params["clientOrderIdentifier"] = clientRef
}
err := i.SendAuthenticatedHTTPRequest("POST", path, params, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodPost, path, params, &resp)
if err != nil {
return resp, err
}
@@ -289,7 +285,7 @@ func (i *ItBit) GetOrder(walletID string, params url.Values) (Order, error) {
url := fmt.Sprintf("/%s/%s/%s", itbitWallets, walletID, itbitOrders)
path := common.EncodeURLValues(url, params)
err := i.SendAuthenticatedHTTPRequest("GET", path, nil, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
if err != nil {
return resp, err
}
@@ -304,7 +300,7 @@ func (i *ItBit) GetOrder(walletID string, params url.Values) (Order, error) {
func (i *ItBit) CancelExistingOrder(walletID, orderID string) error {
path := fmt.Sprintf("/%s/%s/%s/%s", itbitWallets, walletID, itbitOrders, orderID)
return i.SendAuthenticatedHTTPRequest("DELETE", path, nil, nil)
return i.SendAuthenticatedHTTPRequest(http.MethodDelete, path, nil, nil)
}
// GetCryptoDepositAddress returns a deposit address to send cryptocurrency to.
@@ -314,7 +310,7 @@ func (i *ItBit) GetCryptoDepositAddress(walletID, currency string) (CryptoCurren
params := make(map[string]interface{})
params["currency"] = currency
err := i.SendAuthenticatedHTTPRequest("POST", path, params, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodPost, path, params, &resp)
if err != nil {
return resp, err
}
@@ -335,7 +331,7 @@ func (i *ItBit) WalletTransfer(walletID, sourceWallet, destWallet string, amount
params["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
params["currencyCode"] = currency
err := i.SendAuthenticatedHTTPRequest("POST", path, params, &resp)
err := i.SendAuthenticatedHTTPRequest(http.MethodPost, path, params, &resp)
if err != nil {
return resp, err
}
@@ -347,7 +343,7 @@ func (i *ItBit) WalletTransfer(walletID, sourceWallet, destWallet string, amount
// SendHTTPRequest sends an unauthenticated HTTP request
func (i *ItBit) SendHTTPRequest(path string, result interface{}) error {
return i.SendPayload("GET", path, nil, nil, result, false, i.Verbose)
return i.SendPayload(http.MethodGet, path, nil, nil, result, false, i.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated request to itBit

View File

@@ -170,7 +170,7 @@ func (i *ItBit) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exc
}
// SubmitOrder submits a new order
func (i *ItBit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (i *ItBit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var wallet string

View File

@@ -3,6 +3,7 @@ package kraken
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -354,11 +355,7 @@ func (k *Kraken) GetDepth(symbol string) (Orderbook, error) {
}
orderBook.Asks, err = processOrderbook(asksData)
if err != nil {
return orderBook, err
}
return orderBook, nil
return orderBook, err
}
// GetTrades returns current trades on Kraken
@@ -909,7 +906,7 @@ func GetError(errors []string) error {
// SendHTTPRequest sends an unauthenticated HTTP requests
func (k *Kraken) SendHTTPRequest(path string, result interface{}) error {
return k.SendPayload("GET", path, nil, nil, result, false, k.Verbose)
return k.SendPayload(http.MethodGet, path, nil, nil, result, false, k.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request
@@ -944,7 +941,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values,
headers["API-Key"] = k.APIKey
headers["API-Sign"] = signature
return k.SendPayload("POST", k.APIUrl+path, headers, strings.NewReader(encoded), result, true, k.Verbose)
return k.SendPayload(http.MethodPost, k.APIUrl+path, headers, strings.NewReader(encoded), result, true, k.Verbose)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -182,7 +182,7 @@ func (k *Kraken) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (k *Kraken) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (k *Kraken) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var args = AddOrderOptions{}
@@ -213,7 +213,7 @@ func (k *Kraken) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (k *Kraken) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (k *Kraken) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -242,7 +242,7 @@ func (k *Kraken) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (k *Kraken) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (k *Kraken) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
methods, err := k.GetDepositMethods(cryptocurrency.String())
if err != nil {
return "", err

View File

@@ -3,6 +3,7 @@ package lakebtc
import (
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"time"
@@ -335,7 +336,7 @@ func (l *LakeBTC) CreateWithdraw(amount float64, accountID string) (Withdraw, er
// SendHTTPRequest sends an unauthenticated http request
func (l *LakeBTC) SendHTTPRequest(path string, result interface{}) error {
return l.SendPayload("GET", path, nil, nil, result, false, l.Verbose)
return l.SendPayload(http.MethodGet, path, nil, nil, result, false, l.Verbose)
}
// SendAuthenticatedHTTPRequest sends an autheticated HTTP request to a LakeBTC
@@ -372,7 +373,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int
headers["Authorization"] = "Basic " + common.Base64Encode([]byte(l.APIKey+":"+common.HexEncodeToString(hmac)))
headers["Content-Type"] = "application/json-rpc"
return l.SendPayload("POST", l.APIUrl, headers, strings.NewReader(string(data)), result, true, l.Verbose)
return l.SendPayload(http.MethodPost, l.APIUrl, headers, strings.NewReader(string(data)), result, true, l.Verbose)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -149,7 +149,7 @@ func (l *LakeBTC) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]e
}
// SubmitOrder submits a new order
func (l *LakeBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (l *LakeBTC) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, _ exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
isBuyOrder := side == exchange.BuyOrderSide
response, err := l.Trade(isBuyOrder, amount, price, common.StringToLower(p.Pair().String()))
@@ -183,7 +183,7 @@ func (l *LakeBTC) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (l *LakeBTC) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (l *LakeBTC) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -209,7 +209,7 @@ func (l *LakeBTC) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (l *LakeBTC) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (l *LakeBTC) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
if !strings.EqualFold(cryptocurrency.String(), symbol.BTC) {
return "", fmt.Errorf("unsupported currency %s deposit address can only be BTC, manual deposit is required for other currencies",
cryptocurrency.String())

View File

@@ -3,6 +3,7 @@ package localbitcoins
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -180,7 +181,7 @@ func (l *LocalBitcoins) GetAccountInformation(username string, self bool) (Accou
resp := response{}
if self {
err := l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIMyself, nil, &resp)
err := l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIMyself, nil, &resp)
if err != nil {
return resp.Data, err
}
@@ -205,19 +206,20 @@ func (l *LocalBitcoins) Getads(args ...string) (AdData, error) {
}
if len(args) == 0 {
return resp.Data, l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIAds, nil, &resp)
return resp.Data, l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIAds, nil, &resp)
}
params := url.Values{"ads": {strings.Join(args, ",")}}
return resp.Data, l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIAdGet, params, &resp)
return resp.Data, l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIAdGet, params, &resp)
}
// EditAd updates set advertisements
//
// params - see localbitcoins_types.go AdEdit for reference
// adID - string for the ad you already created
func (l *LocalBitcoins) EditAd(params AdEdit, adID string) error {
// TODO
func (l *LocalBitcoins) EditAd(_ AdEdit, adID string) error {
type response struct {
Data AdData `json:"data"`
}
@@ -225,14 +227,15 @@ func (l *LocalBitcoins) EditAd(params AdEdit, adID string) error {
resp := response{}
//request := make(map[string]interface{})
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIAdEdit+adID+"/", nil, &resp)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIAdEdit+adID+"/", nil, &resp)
}
// CreateAd creates a new advertisement
//
// params - see localbitcoins_types.go AdCreate for reference
func (l *LocalBitcoins) CreateAd(params AdCreate) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIAdCreate, nil, nil)
// TODO
func (l *LocalBitcoins) CreateAd(_ AdCreate) error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIAdCreate, nil, nil)
}
// UpdatePriceEquation updates price equation of an advertisement. If there are
@@ -241,33 +244,36 @@ func (l *LocalBitcoins) CreateAd(params AdCreate) error {
//
// equation - string of equation
// adID - string of specific ad identification
func (l *LocalBitcoins) UpdatePriceEquation(equation, adID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIUpdateEquation+adID, nil, nil)
// TODO
func (l *LocalBitcoins) UpdatePriceEquation(adID string) error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIUpdateEquation+adID, nil, nil)
}
// DeleteAd deletes the advertisement by adID.
//
// adID - string of specific ad identification
// TODO
func (l *LocalBitcoins) DeleteAd(adID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIDeleteAd+adID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIDeleteAd+adID, nil, nil)
}
// ReleaseFunds releases Bitcoin trades specified by ID {contact_id}. If the
// release was successful a message is returned on the data key.
func (l *LocalBitcoins) ReleaseFunds(contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIRelease+contactID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIRelease+contactID, nil, nil)
}
// ReleaseFundsByPin releases Bitcoin trades specified by ID {contact_id}. if
// the current pincode is provided. If the release was successful a message is
// returned on the data key.
func (l *LocalBitcoins) ReleaseFundsByPin(pin int, contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIReleaseByPin+contactID, nil, nil)
// TODO
func (l *LocalBitcoins) ReleaseFundsByPin(contactID string) error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIReleaseByPin+contactID, nil, nil)
}
// MarkAsPaid marks a trade as paid.
func (l *LocalBitcoins) MarkAsPaid(contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIMarkAsPaid+contactID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIMarkAsPaid+contactID, nil, nil)
}
// GetMessages returns all chat messages from the trade. Messages are on the message_list key.
@@ -278,56 +284,59 @@ func (l *LocalBitcoins) GetMessages(contactID string) (Message, error) {
resp := response{}
return resp.MessageList,
l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIMessages+contactID, nil, &resp)
l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIMessages+contactID, nil, &resp)
}
// SendMessage posts a message and/or uploads an image to the trade. Encode
// images with multipart/form-data encoding.
func (l *LocalBitcoins) SendMessage(msg, contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPISendMessage+contactID, nil, nil)
// TODO
func (l *LocalBitcoins) SendMessage(contactID string) error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPISendMessage+contactID, nil, nil)
}
// Dispute starts a dispute on the specified trade ID if the requirements for
// starting the dispute has been fulfilled.
//
// topic - [optional] String Short description of issue to LocalBitcoins customer support.
func (l *LocalBitcoins) Dispute(topic, contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIDispute+contactID, nil, nil)
// TODO
func (l *LocalBitcoins) Dispute(_, contactID string) error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIDispute+contactID, nil, nil)
}
// CancelTrade cancels the trade if the token owner is the Bitcoin buyer.
// Bitcoin sellers cannot cancel trades.
func (l *LocalBitcoins) CancelTrade(contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPICancelTrade+contactID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICancelTrade+contactID, nil, nil)
}
// FundTrade attempts to fund an unfunded local trade from the token owners
// wallet. Works only if the token owner is the Bitcoin seller in the trade.
func (l *LocalBitcoins) FundTrade(contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIFundTrade+contactID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIFundTrade+contactID, nil, nil)
}
// ConfirmRealName creates or updates real name confirmation.
func (l *LocalBitcoins) ConfirmRealName(contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIConfirmRealName+contactID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIConfirmRealName+contactID, nil, nil)
}
// VerifyIdentity marks the identity of trade partner as verified. You must be
// the advertiser in this trade.
func (l *LocalBitcoins) VerifyIdentity(contactID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIVerifyIdentity+contactID, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIVerifyIdentity+contactID, nil, nil)
}
// InitiateTrade sttempts to start a Bitcoin trade from the specified
// advertisement ID.
func (l *LocalBitcoins) InitiateTrade(amount int, message, adID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIInitiateTrade+adID, nil, nil)
// TODO
func (l *LocalBitcoins) InitiateTrade(adID string) error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIInitiateTrade+adID, nil, nil)
}
// GetTradeInfo returns information about a single trade that the token owner is
// part in.
func (l *LocalBitcoins) GetTradeInfo(contactID string) (dbi DashBoardInfo, err error) {
err = l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPITradeInfo+contactID+"/", nil, &dbi)
err = l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPITradeInfo+contactID+"/", nil, &dbi)
return
}
@@ -359,7 +368,7 @@ func (l *LocalBitcoins) GetDashboardInfo() ([]DashBoardInfo, error) {
}
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboard, nil, &resp)
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboard, nil, &resp)
}
// GetDashboardReleasedTrades returns a list of all released trades where the
@@ -373,7 +382,7 @@ func (l *LocalBitcoins) GetDashboardReleasedTrades() ([]DashBoardInfo, error) {
}
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboardReleased, nil, &resp)
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboardReleased, nil, &resp)
}
// GetDashboardCancelledTrades returns a list of all canceled trades where the
@@ -387,7 +396,7 @@ func (l *LocalBitcoins) GetDashboardCancelledTrades() ([]DashBoardInfo, error) {
}
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboardCancelled, nil, &resp)
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboardCancelled, nil, &resp)
}
// GetDashboardClosedTrades returns a list of all closed trades where the token
@@ -401,7 +410,7 @@ func (l *LocalBitcoins) GetDashboardClosedTrades() ([]DashBoardInfo, error) {
}
return resp.Data.ContactList,
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIDashboardClosed, nil, &resp)
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboardClosed, nil, &resp)
}
// SetFeedback gives feedback to user. Possible feedback values are: trust,
@@ -416,47 +425,52 @@ func (l *LocalBitcoins) GetDashboardClosedTrades() ([]DashBoardInfo, error) {
// msg - [optional] Feedback message displayed alongside feedback on receivers
// profile page.
// username - username of trade contact
func (l *LocalBitcoins) SetFeedback(msg, feedback, username string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIFeedback, nil, nil)
// TODO
func (l *LocalBitcoins) SetFeedback() error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIFeedback, nil, nil)
}
// Logout expires the current access token immediately. To get a new token
// afterwards, public apps will need to re-authenticate, confidential apps can
// turn in a refresh token.
func (l *LocalBitcoins) Logout() error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPILogout, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPILogout, nil, nil)
}
// CreateNewInvoice creates a new invoice.
func (l *LocalBitcoins) CreateNewInvoice(currency, description, returnURL string, amount float64, internal bool) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPICreateInvoice, nil, nil)
// TODO
func (l *LocalBitcoins) CreateNewInvoice() error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICreateInvoice, nil, nil)
}
// GetInvoice returns information about a specific invoice created by the token
// owner.
func (l *LocalBitcoins) GetInvoice(invoiceID string) (Invoice, error) {
// TODO
func (l *LocalBitcoins) GetInvoice() (Invoice, error) {
resp := Invoice{}
return resp, l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPICreateInvoice, nil, &resp)
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICreateInvoice, nil, &resp)
}
// DeleteInvoice deletes a specific invoice. Deleting invoices is possible when
// it is sure that receiver cannot accidentally pay the invoice at the same time
// as the merchant is deleting it. You can use the API request
// /api/merchant/invoice/{invoice_id}/ to check if deleting is possible.
func (l *LocalBitcoins) DeleteInvoice(invoiceID string) (Invoice, error) {
// TODO
func (l *LocalBitcoins) DeleteInvoice() (Invoice, error) {
resp := Invoice{}
return resp, l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPICreateInvoice, nil, &resp)
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICreateInvoice, nil, &resp)
}
// GetNotifications returns recent notifications.
func (l *LocalBitcoins) GetNotifications() ([]NotificationInfo, error) {
resp := []NotificationInfo{}
return resp, l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIGetNotification, nil, &resp)
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIGetNotification, nil, &resp)
}
// MarkNotifications marks a specific notification as read.
func (l *LocalBitcoins) MarkNotifications(notificationID string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIMarkNotification, nil, nil)
// TODO
func (l *LocalBitcoins) MarkNotifications() error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIMarkNotification, nil, nil)
}
// GetPaymentMethods returns a list of valid payment methods. Also contains name
@@ -487,7 +501,7 @@ func (l *LocalBitcoins) CheckPincode(pin int) (bool, error) {
resp := response{}
values := url.Values{}
values.Set("pincode", strconv.Itoa(pin))
err := l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIPinCode, values, &resp)
err := l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIPinCode, values, &resp)
if err != nil {
return false, err
@@ -502,21 +516,23 @@ func (l *LocalBitcoins) CheckPincode(pin int) (bool, error) {
// GetPlaces Looks up places near lat, lon and provides full URLs to buy and
// sell listings for each.
func (l *LocalBitcoins) GetPlaces(lat, lon int, location, countryCode string) error {
// TODO
func (l *LocalBitcoins) GetPlaces() error {
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPIPlaces, nil)
}
// VerifyUsername returns list of real name verifiers for the user. Returns a
// list only when you have a trade with the user where you are the seller.
func (l *LocalBitcoins) VerifyUsername() error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIVerifyUsername, nil, nil)
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIVerifyUsername, nil, nil)
}
// GetRecentMessages returns maximum of 25 newest trade messages. Does not
// return messages older than one month. Messages are ordered by sending time,
// and the newest one is first.
func (l *LocalBitcoins) GetRecentMessages(after string) error {
return l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIVerifyUsername, nil, nil)
// TODO
func (l *LocalBitcoins) GetRecentMessages() error {
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIVerifyUsername, nil, nil)
}
// GetWalletInfo gets information about the token owner's wallet balance.
@@ -525,7 +541,7 @@ func (l *LocalBitcoins) GetWalletInfo() (WalletInfo, error) {
Data WalletInfo `json:"data"`
}
resp := response{}
err := l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIWallet, nil, &resp)
err := l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIWallet, nil, &resp)
if err != nil {
return WalletInfo{}, err
@@ -546,7 +562,7 @@ func (l *LocalBitcoins) GetWalletBalance() (WalletBalanceInfo, error) {
Data WalletBalanceInfo `json:"data"`
}
resp := response{}
err := l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIWalletBalance, nil, &resp)
err := l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIWalletBalance, nil, &resp)
if err != nil {
return WalletBalanceInfo{}, err
@@ -581,7 +597,7 @@ func (l *LocalBitcoins) WalletSend(address string, amount float64, pin int64) (b
}
resp := response{}
err := l.SendAuthenticatedHTTPRequest("POST", path, values, &resp)
err := l.SendAuthenticatedHTTPRequest(http.MethodPost, path, values, &resp)
if err != nil {
return false, err
}
@@ -604,7 +620,7 @@ func (l *LocalBitcoins) GetWalletAddress() (string, error) {
}
}
resp := response{}
err := l.SendAuthenticatedHTTPRequest("POST", localbitcoinsAPIWalletAddress, nil, &resp)
err := l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIWalletAddress, nil, &resp)
if err != nil {
return "", err
}
@@ -617,12 +633,14 @@ func (l *LocalBitcoins) GetWalletAddress() (string, error) {
}
// GetBitcoinsWithCashAd returns buy or sell as cash local advertisements.
func (l *LocalBitcoins) GetBitcoinsWithCashAd(locationID, locationSlug string, BuySide bool) error {
// TODO
func (l *LocalBitcoins) GetBitcoinsWithCashAd() error {
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPICashBuy, nil)
}
// GetBitcoinsOnlineAd this API returns buy or sell Bitcoin online ads.
func (l *LocalBitcoins) GetBitcoinsOnlineAd(countryCode, countryName, paymentMethod string, BuySide bool) error {
// TODO
func (l *LocalBitcoins) GetBitcoinsOnlineAd() error {
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPIOnlineBuy, nil)
}
@@ -710,7 +728,7 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (l *LocalBitcoins) SendHTTPRequest(path string, result interface{}) error {
return l.SendPayload("GET", path, nil, nil, result, false, l.Verbose)
return l.SendPayload(http.MethodGet, path, nil, nil, result, false, l.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to
@@ -740,7 +758,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params
log.Debugf("Sending POST request to `%s`, path: `%s`, params: `%s`.", l.APIUrl, path, encoded)
}
if method == "GET" && len(encoded) > 0 {
if method == http.MethodGet && len(encoded) > 0 {
path += "?" + encoded
}

View File

@@ -147,7 +147,7 @@ func (l *LocalBitcoins) GetExchangeHistory(p pair.CurrencyPair, assetType string
}
// SubmitOrder submits a new order
func (l *LocalBitcoins) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (l *LocalBitcoins) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, _ exchange.OrderType, amount, _ float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
// These are placeholder details
// TODO store a user's localbitcoin details to use here
@@ -225,7 +225,7 @@ func (l *LocalBitcoins) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (l *LocalBitcoins) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (l *LocalBitcoins) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -252,7 +252,7 @@ func (l *LocalBitcoins) GetOrderInfo(orderID int64) (exchange.OrderDetail, error
}
// GetDepositAddress returns a deposit address for a specified currency
func (l *LocalBitcoins) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (l *LocalBitcoins) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
if !strings.EqualFold(symbol.BTC, cryptocurrency.String()) {
return "", fmt.Errorf("Localbitcoins do not have support for currency %s just bitcoin",
cryptocurrency.String())

View File

@@ -3,6 +3,7 @@ package okcoin
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -447,15 +448,9 @@ func (o *OKCoin) BatchTrade(orderData string, symbol, orderType string) (BatchTr
v.Set("orders_data", orderData)
v.Set("symbol", symbol)
v.Set("type", orderType)
result := BatchTrade{}
err := o.SendAuthenticatedHTTPRequest(okcoinTradeBatch, v, &result)
if err != nil {
return result, err
}
return result, nil
return result, o.SendAuthenticatedHTTPRequest(okcoinTradeBatch, v, &result)
}
// CancelExistingOrder cancels a specific order or list of orders by orderID
@@ -540,15 +535,9 @@ func (o *OKCoin) GetOrderHistoryForCurrency(pageLength, currentPage, status int6
v.Set("status", strconv.FormatInt(status, 10))
v.Set("current_page", strconv.FormatInt(currentPage, 10))
v.Set("page_length", strconv.FormatInt(pageLength, 10))
result := OrderHistory{}
err := o.SendAuthenticatedHTTPRequest(okcoinOrderHistory, v, &result)
if err != nil {
return result, err
}
return result, nil
return result, o.SendAuthenticatedHTTPRequest(okcoinOrderHistory, v, &result)
}
// Withdrawal withdraws a cryptocurrency to a supplied address
@@ -850,7 +839,7 @@ func (o *OKCoin) FuturesTrade(amount, price float64, matchPrice, leverage int64,
}
// FuturesBatchTrade initiates a batch of futures contract trades
func (o *OKCoin) FuturesBatchTrade(orderData, symbol, contractType string, leverage int64, orderType string) {
func (o *OKCoin) FuturesBatchTrade(orderData, symbol, contractType string, leverage int64, _ string) {
v := url.Values{} //to-do batch trade support for orders_data)
v.Set("symbol", symbol)
v.Set("contract_type", contractType)
@@ -936,7 +925,7 @@ func (o *OKCoin) GetFuturesUserPosition4Fix(symbol, contractType string) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (o *OKCoin) SendHTTPRequest(path string, result interface{}) error {
return o.SendPayload("GET", path, nil, nil, result, false, o.Verbose)
return o.SendPayload(http.MethodGet, path, nil, nil, result, false, o.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request
@@ -959,7 +948,7 @@ func (o *OKCoin) SendAuthenticatedHTTPRequest(method string, v url.Values, resul
headers := make(map[string]string)
headers["Content-Type"] = "application/x-www-form-urlencoded"
return o.SendPayload("POST", path, headers, strings.NewReader(encoded), result, true, o.Verbose)
return o.SendPayload(http.MethodPost, path, headers, strings.NewReader(encoded), result, true, o.Verbose)
}
// SetErrorDefaults sets default error map

View File

@@ -25,7 +25,7 @@ const (
)
// PingHandler handles the keep alive
func (o *OKCoin) PingHandler(message string) error {
func (o *OKCoin) PingHandler(_ string) error {
return o.WebsocketConn.WriteControl(websocket.PingMessage,
[]byte("{'event':'ping'}"),
time.Now().Add(time.Second))

View File

@@ -201,7 +201,7 @@ func (o *OKCoin) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (o *OKCoin) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (o *OKCoin) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var oT string
if orderType == exchange.LimitOrderType {

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"strconv"
@@ -662,22 +663,13 @@ func (o *OKEX) GetTokenOrders(symbol string, orderID int64) (TokenOrdersResponse
values := url.Values{}
values.Set("symbol", symbol)
values.Set("order_id", strconv.FormatInt(orderID, 10))
if err := o.SendAuthenticatedHTTPRequest(contractFutureTradeHistory, values, &resp); err != nil {
return resp, err
}
return resp, nil
return resp, o.SendAuthenticatedHTTPRequest(contractFutureTradeHistory, values, &resp)
}
// GetUserInfo returns the user info
func (o *OKEX) GetUserInfo() (SpotUserInfo, error) {
var resp SpotUserInfo
err := o.SendAuthenticatedHTTPRequest(spotUserInfo, url.Values{}, &resp)
if err != nil {
return resp, err
}
return resp, nil
return resp, o.SendAuthenticatedHTTPRequest(spotUserInfo, url.Values{}, &resp)
}
// SpotNewOrder creates a new spot order
@@ -932,7 +924,7 @@ func (o *OKEX) GetErrorCode(code interface{}) error {
// SendHTTPRequest sends an unauthenticated HTTP request
func (o *OKEX) SendHTTPRequest(path string, result interface{}) error {
return o.SendPayload("GET", path, nil, nil, result, false, o.Verbose)
return o.SendPayload(http.MethodGet, path, nil, nil, result, false, o.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated http request to a desired
@@ -963,7 +955,7 @@ func (o *OKEX) SendAuthenticatedHTTPRequest(method string, values url.Values, re
Error int64 `json:"error_code"`
}{}
err = o.SendPayload("POST", path, headers, strings.NewReader(encoded), &intermediary, true, o.Verbose)
err = o.SendPayload(http.MethodPost, path, headers, strings.NewReader(encoded), &intermediary, true, o.Verbose)
if err != nil {
return err
}
@@ -1290,11 +1282,5 @@ func (o *OKEX) GetOrderHistoryForCurrency(pageLength, currentPage, status int64,
v.Set("current_page", strconv.FormatInt(currentPage, 10))
v.Set("page_length", strconv.FormatInt(pageLength, 10))
result := OrderHistory{}
err := o.SendAuthenticatedHTTPRequest(spotOrderHistory, v, &result)
if err != nil {
return result, err
}
return result, nil
return result, o.SendAuthenticatedHTTPRequest(spotOrderHistory, v, &result)
}

View File

@@ -192,7 +192,7 @@ func (o *OKEX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exch
}
// SubmitOrder submits a new order
func (o *OKEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (o *OKEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var oT SpotNewOrderRequestType
@@ -250,7 +250,7 @@ func (o *OKEX) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders for all enabled currencies
func (o *OKEX) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (o *OKEX) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
@@ -316,7 +317,7 @@ func (p *Poloniex) GetLoanOrders(currency string) (LoanOrders, error) {
// GetBalances returns balances for your account.
func (p *Poloniex) GetBalances() (Balance, error) {
var result interface{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexBalances, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexBalances, url.Values{}, &result)
if err != nil {
return Balance{}, err
@@ -336,7 +337,7 @@ func (p *Poloniex) GetBalances() (Balance, error) {
// GetCompleteBalances returns complete balances from your account.
func (p *Poloniex) GetCompleteBalances() (CompleteBalances, error) {
var result interface{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexBalancesComplete, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexBalancesComplete, url.Values{}, &result)
if err != nil {
return CompleteBalances{}, err
@@ -362,7 +363,7 @@ func (p *Poloniex) GetCompleteBalances() (CompleteBalances, error) {
func (p *Poloniex) GetDepositAddresses() (DepositAddresses, error) {
var result interface{}
addresses := DepositAddresses{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexDepositAddresses, url.Values{}, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexDepositAddresses, url.Values{}, &result)
if err != nil {
return addresses, err
@@ -388,7 +389,7 @@ func (p *Poloniex) GenerateNewAddress(currency string) (string, error) {
values := url.Values{}
values.Set("currency", currency)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexGenerateNewAddress, values, &resp)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexGenerateNewAddress, values, &resp)
if err != nil {
return "", err
@@ -418,28 +419,15 @@ func (p *Poloniex) GetDepositsWithdrawals(start, end string) (DepositsWithdrawal
values.Set("end", strconv.FormatInt(time.Now().Unix(), 10))
}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexDepositsWithdrawals, values, &resp)
if err != nil {
return resp, err
}
return resp, nil
return resp, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexDepositsWithdrawals, values, &resp)
}
// GetOpenOrders returns current unfilled opened orders
func (p *Poloniex) GetOpenOrders(currency string) (OpenOrdersResponse, error) {
values := url.Values{}
values.Set("currencyPair", currency)
result := OpenOrdersResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrders, values, &result.Data)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexOrders, values, &result.Data)
}
// GetOpenOrdersForAllCurrencies returns all open orders
@@ -447,13 +435,7 @@ func (p *Poloniex) GetOpenOrdersForAllCurrencies() (OpenOrdersResponseAll, error
values := url.Values{}
values.Set("currencyPair", "all")
result := OpenOrdersResponseAll{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrders, values, &result.Data)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexOrders, values, &result.Data)
}
// GetAuthenticatedTradeHistoryForCurrency returns account trade history
@@ -474,13 +456,7 @@ func (p *Poloniex) GetAuthenticatedTradeHistoryForCurrency(currency string, star
values.Set("currencyPair", currency)
result := AuthenticatedTradeHistoryResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTradeHistory, values, &result.Data)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexTradeHistory, values, &result.Data)
}
// GetAuthenticatedTradeHistory returns account trade history
@@ -502,7 +478,7 @@ func (p *Poloniex) GetAuthenticatedTradeHistory(start, end, limit int64) (Authen
values.Set("currencyPair", "all")
var result interface{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTradeHistory, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexTradeHistory, values, &result)
if err != nil {
return AuthenticatedTradeHistoryAll{}, err
}
@@ -540,13 +516,7 @@ func (p *Poloniex) PlaceOrder(currency string, rate, amount float64, immediate,
values.Set("fillOrKill", "1")
}
err := p.SendAuthenticatedHTTPRequest("POST", orderType, values, &result)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, orderType, values, &result)
}
// CancelExistingOrder cancels and order by orderID
@@ -555,7 +525,7 @@ func (p *Poloniex) CancelExistingOrder(orderID int64) (bool, error) {
values := url.Values{}
values.Set("orderNumber", strconv.FormatInt(orderID, 10))
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOrderCancel, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexOrderCancel, values, &result)
if err != nil {
return false, err
@@ -596,7 +566,7 @@ func (p *Poloniex) MoveOrder(orderID int64, rate, amount float64, postOnly, imme
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
}
err := p.SendAuthenticatedHTTPRequest("POST",
err := p.SendAuthenticatedHTTPRequest(http.MethodPost,
poloniexOrderMove,
values,
&result)
@@ -620,7 +590,7 @@ func (p *Poloniex) Withdraw(currency, address string, amount float64) (bool, err
values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64))
values.Set("address", address)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexWithdraw, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexWithdraw, values, &result)
if err != nil {
return false, err
@@ -637,7 +607,7 @@ func (p *Poloniex) Withdraw(currency, address string, amount float64) (bool, err
func (p *Poloniex) GetFeeInfo() (Fee, error) {
result := Fee{}
return result, p.SendAuthenticatedHTTPRequest("POST", poloniexFeeInfo, url.Values{}, &result)
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexFeeInfo, url.Values{}, &result)
}
// GetTradableBalances returns tradable balances
@@ -647,7 +617,7 @@ func (p *Poloniex) GetTradableBalances() (map[string]map[string]float64, error)
}
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTradableBalances, url.Values{}, &result.Data)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexTradableBalances, url.Values{}, &result.Data)
if err != nil {
return nil, err
@@ -675,7 +645,7 @@ func (p *Poloniex) TransferBalance(currency, from, to string, amount float64) (b
values.Set("fromAccount", from)
values.Set("toAccount", to)
err := p.SendAuthenticatedHTTPRequest("POST", poloniexTransferBalance, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexTransferBalance, values, &result)
if err != nil {
return false, err
@@ -691,13 +661,7 @@ func (p *Poloniex) TransferBalance(currency, from, to string, amount float64) (b
// GetMarginAccountSummary returns a summary on your margin accounts
func (p *Poloniex) GetMarginAccountSummary() (Margin, error) {
result := Margin{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginAccountSummary, url.Values{}, &result)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexMarginAccountSummary, url.Values{}, &result)
}
// PlaceMarginOrder places a margin order
@@ -720,13 +684,7 @@ func (p *Poloniex) PlaceMarginOrder(currency string, rate, amount, lendingRate f
values.Set("lendingRate", strconv.FormatFloat(lendingRate, 'f', -1, 64))
}
err := p.SendAuthenticatedHTTPRequest("POST", orderType, values, &result)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, orderType, values, &result)
}
// GetMarginPosition returns a position on a margin order
@@ -736,13 +694,7 @@ func (p *Poloniex) GetMarginPosition(currency string) (interface{}, error) {
if currency != "" && currency != "all" {
values.Set("currencyPair", currency)
result := MarginPosition{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginPosition, values, &result)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexMarginPosition, values, &result)
}
values.Set("currencyPair", "all")
@@ -750,13 +702,7 @@ func (p *Poloniex) GetMarginPosition(currency string) (interface{}, error) {
Data map[string]MarginPosition
}
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginPosition, values, &result.Data)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexMarginPosition, values, &result.Data)
}
// CloseMarginPosition closes a current margin position
@@ -765,7 +711,7 @@ func (p *Poloniex) CloseMarginPosition(currency string) (bool, error) {
values.Set("currencyPair", currency)
result := GenericResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexMarginPositionClose, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexMarginPositionClose, values, &result)
if err != nil {
return false, err
@@ -801,7 +747,7 @@ func (p *Poloniex) CreateLoanOffer(currency string, amount, rate float64, durati
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexCreateLoanOffer, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexCreateLoanOffer, values, &result)
if err != nil {
return 0, err
@@ -820,7 +766,7 @@ func (p *Poloniex) CancelLoanOffer(orderNumber int64) (bool, error) {
values := url.Values{}
values.Set("orderID", strconv.FormatInt(orderNumber, 10))
err := p.SendAuthenticatedHTTPRequest("POST", poloniexCancelLoanOffer, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexCancelLoanOffer, values, &result)
if err != nil {
return false, err
@@ -840,7 +786,7 @@ func (p *Poloniex) GetOpenLoanOffers() (map[string][]LoanOffer, error) {
}
result := Response{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexOpenLoanOffers, url.Values{}, &result.Data)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexOpenLoanOffers, url.Values{}, &result.Data)
if err != nil {
return nil, err
@@ -856,13 +802,7 @@ func (p *Poloniex) GetOpenLoanOffers() (map[string][]LoanOffer, error) {
// GetActiveLoans returns active loans
func (p *Poloniex) GetActiveLoans() (ActiveLoans, error) {
result := ActiveLoans{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexActiveLoans, url.Values{}, &result)
if err != nil {
return result, err
}
return result, nil
return result, p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexActiveLoans, url.Values{}, &result)
}
// GetLendingHistory returns lending history for the account
@@ -878,7 +818,7 @@ func (p *Poloniex) GetLendingHistory(start, end string) ([]LendingHistory, error
}
resp := []LendingHistory{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexLendingHistory, vals, &resp)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexLendingHistory, vals, &resp)
if err != nil {
return nil, err
@@ -892,7 +832,7 @@ func (p *Poloniex) ToggleAutoRenew(orderNumber int64) (bool, error) {
values.Set("orderNumber", strconv.FormatInt(orderNumber, 10))
result := GenericResponse{}
err := p.SendAuthenticatedHTTPRequest("POST", poloniexAutoRenew, values, &result)
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexAutoRenew, values, &result)
if err != nil {
return false, err
@@ -907,7 +847,7 @@ func (p *Poloniex) ToggleAutoRenew(orderNumber int64) (bool, error) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (p *Poloniex) SendHTTPRequest(path string, result interface{}) error {
return p.SendPayload("GET", path, nil, nil, result, false, p.Verbose)
return p.SendPayload(http.MethodGet, path, nil, nil, result, false, p.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request

View File

@@ -164,7 +164,7 @@ func (p *Poloniex) GetExchangeHistory(currencyPair pair.CurrencyPair, assetType
}
// SubmitOrder submits a new order
func (p *Poloniex) SubmitOrder(currencyPair pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (p *Poloniex) SubmitOrder(currencyPair pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
fillOrKill := orderType == exchange.MarketOrderType
isBuyOrder := side == exchange.BuyOrderSide
@@ -215,7 +215,7 @@ func (p *Poloniex) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (p *Poloniex) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (p *Poloniex) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -243,7 +243,7 @@ func (p *Poloniex) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (p *Poloniex) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (p *Poloniex) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
a, err := p.GetDepositAddresses()
if err != nil {
return "", err

View File

@@ -16,7 +16,8 @@ import (
log "github.com/thrasher-/gocryptotrader/logger"
)
var supportedMethods = []string{"GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS", "CONNECT"}
var supportedMethods = []string{http.MethodGet, http.MethodPost, http.MethodHead,
http.MethodPut, http.MethodDelete, http.MethodOptions, http.MethodConnect}
const (
maxRequestJobs = 50
@@ -256,10 +257,10 @@ func (r *Requester) checkRequest(method, path string, body io.Reader, headers ma
}
// DoRequest performs a HTTP/HTTPS request with the supplied params
func (r *Requester) DoRequest(req *http.Request, method, path string, headers map[string]string, body io.Reader, result interface{}, authRequest, verbose bool) error {
func (r *Requester) DoRequest(req *http.Request, path string, body io.Reader, result interface{}, authRequest, verbose bool) error {
if verbose {
log.Debugf("%s exchange request path: %s requires rate limiter: %v", r.Name, path, r.RequiresRateLimiter())
for k, d := range headers {
for k, d := range req.Header {
log.Debugf("%s exchange request header [%s]: %s", r.Name, k, d)
}
log.Debug(body)
@@ -353,7 +354,7 @@ func (r *Requester) worker() {
if !r.IsRateLimited(x.AuthRequest) {
r.IncrementRequests(x.AuthRequest)
err := r.DoRequest(x.Request, x.Method, x.Path, x.Headers, x.Body, x.Result, x.AuthRequest, x.Verbose)
err := r.DoRequest(x.Request, x.Path, x.Body, x.Result, x.AuthRequest, x.Verbose)
x.JobResult <- &JobResult{
Error: err,
Result: x.Result,
@@ -374,7 +375,7 @@ func (r *Requester) worker() {
log.Debugf("%s request. No longer rate limited! Doing request", r.Name)
}
err := r.DoRequest(x.Request, x.Method, x.Path, x.Headers, x.Body, x.Result, x.AuthRequest, x.Verbose)
err := r.DoRequest(x.Request, x.Path, x.Body, x.Result, x.AuthRequest, x.Verbose)
x.JobResult <- &JobResult{
Error: err,
Result: x.Result,
@@ -407,7 +408,7 @@ func (r *Requester) SendPayload(method, path string, headers map[string]string,
}
if !r.RequiresRateLimiter() {
return r.DoRequest(req, method, path, headers, body, result, authRequest, verbose)
return r.DoRequest(req, path, body, result, authRequest, verbose)
}
if len(r.Jobs) == maxRequestJobs {

View File

@@ -200,7 +200,7 @@ func TestCheckRequest(t *testing.T) {
func TestDoRequest(t *testing.T) {
var test *Requester
err := test.SendPayload("GET", "https://www.google.com", nil, nil, nil, false, true)
err := test.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, true)
if err == nil {
t.Fatal("not iniitalised")
}
@@ -216,12 +216,12 @@ func TestDoRequest(t *testing.T) {
t.Fatal("unexpected values")
}
err = r.SendPayload("GET", "", nil, nil, nil, false, true)
err = r.SendPayload(http.MethodGet, "", nil, nil, nil, false, true)
if err == nil {
t.Fatal("unexpected values")
}
err = r.SendPayload("GET", "https://www.google.com", nil, nil, nil, false, true)
err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, true)
if err != nil {
t.Fatal("unexpected values")
}
@@ -233,7 +233,7 @@ func TestDoRequest(t *testing.T) {
r.SetRateLimit(false, time.Second, 0)
r.SetRateLimit(true, time.Second, 0)
err = r.SendPayload("GET", "https://www.google.com", nil, nil, nil, false, true)
err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, true)
if err != nil {
t.Fatal("unexpected values")
}
@@ -250,7 +250,7 @@ func TestDoRequest(t *testing.T) {
t.Fatal("unexepcted values")
}
err = r.SendPayload("GET", "https://www.google.com", nil, nil, nil, false, true)
err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, true)
if err != nil {
t.Fatal("unexpected values")
}
@@ -261,27 +261,27 @@ func TestDoRequest(t *testing.T) {
t.Fatal("unexepcted values")
}
err = r.SendPayload("GET", "https://www.google.com", nil, nil, nil, true, true)
err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, true, true)
if err != nil {
t.Fatal("unexpected values")
}
var result interface{}
err = r.SendPayload("GET", "https://www.google.com", nil, nil, result, false, true)
err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, result, false, true)
if err != nil {
t.Fatal(err)
}
headers := make(map[string]string)
headers["content-type"] = "content/text"
err = r.SendPayload("POST", "https://bitfinex.com", headers, nil, result, false, true)
err = r.SendPayload(http.MethodPost, "https://bitfinex.com", headers, nil, result, false, true)
if err != nil {
t.Fatal(err)
}
r.StartCycle()
r.UnauthLimit.SetRequests(100)
err = r.SendPayload("GET", "https://www.google.com", nil, nil, result, false, false)
err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, result, false, false)
if err != nil {
t.Fatal("unexpected values")
}
@@ -297,7 +297,7 @@ func TestDoRequest(t *testing.T) {
}
r.HTTPClient.Timeout = 1 * time.Second
err = r.SendPayload("POST", "https://httpstat.us/200?sleep=20000", nil, nil, nil, false, true)
err = r.SendPayload(http.MethodPost, "https://httpstat.us/200?sleep=20000", nil, nil, nil, false, true)
if err == nil {
t.Fatal(err)
}

View File

@@ -3,6 +3,7 @@ package wex
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -356,7 +357,7 @@ func (w *WEX) RedeemCoupon(coupon string) (RedeemCoupon, error) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (w *WEX) SendHTTPRequest(path string, result interface{}) error {
return w.SendPayload("GET", path, nil, nil, result, false, w.Verbose)
return w.SendPayload(http.MethodGet, path, nil, nil, result, false, w.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to WEX
@@ -389,7 +390,7 @@ func (w *WEX) SendAuthenticatedHTTPRequest(method string, values url.Values, res
headers["Sign"] = common.HexEncodeToString(hmac)
headers["Content-Type"] = "application/x-www-form-urlencoded"
return w.SendPayload("POST",
return w.SendPayload(http.MethodPost,
w.APIUrlSecondary,
headers,
strings.NewReader(encoded),

View File

@@ -1,6 +1,7 @@
package wex
import (
"errors"
"fmt"
"math"
"strconv"
@@ -167,10 +168,14 @@ func (w *WEX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]excha
}
// SubmitOrder submits a new order
func (w *WEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (w *WEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := w.Trade(common.StringToLower(p.Pair().String()), common.StringToLower(side.ToString()), amount, price)
if orderType != exchange.LimitOrderType {
return submitOrderResponse, errors.New("only limit orders are allowed")
}
response, err := w.Trade(p.Pair().String(), side.ToString(), amount, price)
if response > 0 {
submitOrderResponse.OrderID = fmt.Sprintf("%v", response)
}
@@ -201,7 +206,7 @@ func (w *WEX) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (w *WEX) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (w *WEX) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}

View File

@@ -3,6 +3,7 @@ package yobit
import (
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -329,7 +330,7 @@ func (y *Yobit) RedeemCoupon(coupon string) (RedeemCoupon, error) {
// SendHTTPRequest sends an unauthenticated HTTP request
func (y *Yobit) SendHTTPRequest(path string, result interface{}) error {
return y.SendPayload("GET", path, nil, nil, result, false, y.Verbose)
return y.SendPayload(http.MethodGet, path, nil, nil, result, false, y.Verbose)
}
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to Yobit
@@ -362,7 +363,7 @@ func (y *Yobit) SendAuthenticatedHTTPRequest(path string, params url.Values, res
headers["Sign"] = common.HexEncodeToString(hmac)
headers["Content-Type"] = "application/x-www-form-urlencoded"
return y.SendPayload("POST", apiPrivateURL, headers, strings.NewReader(encoded), result, true, y.Verbose)
return y.SendPayload(http.MethodPost, apiPrivateURL, headers, strings.NewReader(encoded), result, true, y.Verbose)
}
// GetFee returns an estimate of fee based on type of transaction

View File

@@ -150,10 +150,15 @@ func (y *Yobit) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exc
}
// SubmitOrder submits a new order
func (y *Yobit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
// Yobit only supports limit orders
func (y *Yobit) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
response, err := y.Trade(p.Pair().String(), orderType.ToString(), amount, price)
if orderType != exchange.LimitOrderType {
return submitOrderResponse, errors.New("only limit orders are allowed")
}
response, err := y.Trade(p.Pair().String(), side.ToString(), amount, price)
if response > 0 {
submitOrderResponse.OrderID = fmt.Sprintf("%v", response)
}
@@ -183,7 +188,7 @@ func (y *Yobit) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (y *Yobit) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (y *Yobit) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -222,7 +227,7 @@ func (y *Yobit) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (y *Yobit) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (y *Yobit) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
a, err := y.GetCryptoDepositAddress(cryptocurrency.String())
if err != nil {
return "", err
@@ -241,7 +246,7 @@ func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReq
if len(resp.Error) > 0 {
return "", errors.New(resp.Error)
}
return "", nil
return "success", nil
}
// WithdrawFiatFunds returns a withdrawal ID when a

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
@@ -139,7 +140,7 @@ func (z *ZB) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
vals.Set("price", strconv.FormatFloat(arg.Price, 'f', -1, 64))
vals.Set("tradeType", string(arg.Type))
err := z.SendAuthenticatedHTTPRequest("GET", vals, &result)
err := z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &result)
if err != nil {
return 0, err
}
@@ -167,7 +168,7 @@ func (z *ZB) CancelExistingOrder(orderID int64, symbol string) error {
vals.Set("currency", symbol)
var result response
err := z.SendAuthenticatedHTTPRequest("GET", vals, &result)
err := z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &result)
if err != nil {
return err
}
@@ -187,11 +188,7 @@ func (z *ZB) GetAccountInformation() (AccountsResponse, error) {
vals.Set("accesskey", z.APIKey)
vals.Set("method", "getAccountInfo")
err := z.SendAuthenticatedHTTPRequest("GET", vals, &result)
if err != nil {
return result, err
}
return result, nil
return result, z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &result)
}
// GetUnfinishedOrdersIgnoreTradeType returns unfinished orders
@@ -204,12 +201,8 @@ func (z *ZB) GetUnfinishedOrdersIgnoreTradeType(currency string, pageindex, page
vals.Set("pageIndex", strconv.FormatInt(pageindex, 10))
vals.Set("pageSize", strconv.FormatInt(pagesize, 10))
err := z.SendAuthenticatedHTTPRequest("GET", vals, &result)
if err != nil {
return result, err
}
return result, nil
err := z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &result)
return result, err
}
// GetOrders returns finished orders
@@ -221,13 +214,7 @@ func (z *ZB) GetOrders(currency string, pageindex, side int64) ([]Order, error)
vals.Set("currency", currency)
vals.Set("pageIndex", strconv.FormatInt(pageindex, 10))
vals.Set("tradeType", strconv.FormatInt(side, 10))
err := z.SendAuthenticatedHTTPRequest("GET", vals, &response)
if err != nil {
return response, err
}
return response, nil
return response, z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &response)
}
// GetMarkets returns market information including pricing, symbols and
@@ -273,11 +260,7 @@ func (z *ZB) GetTicker(symbol string) (TickerResponse, error) {
var res TickerResponse
err := z.SendHTTPRequest(url, &res)
if err != nil {
return res, err
}
return res, nil
return res, err
}
// GetTickers returns ticker data for all supported symbols
@@ -286,11 +269,7 @@ func (z *ZB) GetTickers() (map[string]TickerChildResponse, error) {
resp := make(map[string]TickerChildResponse)
err := z.SendHTTPRequest(url, &resp)
if err != nil {
return resp, err
}
return resp, nil
return resp, err
}
// GetOrderbook returns the orderbook for a given symbol
@@ -376,12 +355,12 @@ func (z *ZB) GetCryptoAddress(currency pair.CurrencyItem) (UserAddress, error) {
vals.Set("currency", currency.Lower().String())
return resp,
z.SendAuthenticatedHTTPRequest("GET", vals, &resp)
z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &resp)
}
// SendHTTPRequest sends an unauthenticated HTTP request
func (z *ZB) SendHTTPRequest(path string, result interface{}) error {
return z.SendPayload("GET", path, nil, nil, result, false, z.Verbose)
return z.SendPayload(http.MethodGet, path, nil, nil, result, false, z.Verbose)
}
// SendAuthenticatedHTTPRequest sends authenticated requests to the zb API
@@ -509,7 +488,7 @@ func (z *ZB) Withdraw(currency, address, safepassword string, amount, fees float
vals.Set("safePwd", safepassword)
var resp response
err := z.SendAuthenticatedHTTPRequest("GET", vals, &resp)
err := z.SendAuthenticatedHTTPRequest(http.MethodGet, vals, &resp)
if err != nil {
return "", err
}

View File

@@ -168,7 +168,7 @@ func (z *ZB) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchan
}
// SubmitOrder submits a new order
func (z *ZB) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
func (z *ZB) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, _ exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var oT SpotNewOrderRequestParamsType
@@ -215,7 +215,7 @@ func (z *ZB) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (z *ZB) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (z *ZB) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -255,7 +255,7 @@ func (z *ZB) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (z *ZB) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (z *ZB) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
address, err := z.GetCryptoAddress(cryptocurrency)
if err != nil {
return "", err

View File

@@ -36,11 +36,7 @@ func GetEthereumBalance(address string) (EthplorerResponse, error) {
"%s/%s/%s?apiKey=freekey", ethplorerAPIURL, ethplorerAddressInfo, address,
)
result := EthplorerResponse{}
err := common.SendHTTPGetRequest(url, true, false, &result)
if err != nil {
return result, err
}
return result, nil
return result, common.SendHTTPGetRequest(url, true, false, &result)
}
// GetCryptoIDAddress queries CryptoID for an address balance for a

View File

@@ -52,7 +52,7 @@ func TestGetAddressBalance(t *testing.T) {
if addBalance != 0 {
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
}
if found != false {
if found {
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
}
}

View File

@@ -47,61 +47,61 @@ func NewRouter() *mux.Router {
routes = Routes{
Route{
"",
"GET",
http.MethodGet,
"/",
getIndex,
},
Route{
"GetAllSettings",
"GET",
http.MethodGet,
"/config/all",
RESTGetAllSettings,
},
Route{
"SaveAllSettings",
"POST",
http.MethodPost,
"/config/all/save",
RESTSaveAllSettings,
},
Route{
"AllEnabledAccountInfo",
"GET",
http.MethodGet,
"/exchanges/enabled/accounts/all",
RESTGetAllEnabledAccountInfo,
},
Route{
"AllActiveExchangesAndCurrencies",
"GET",
http.MethodGet,
"/exchanges/enabled/latest/all",
RESTGetAllActiveTickers,
},
Route{
"IndividualExchangeAndCurrency",
"GET",
http.MethodGet,
"/exchanges/{exchangeName}/latest/{currency}",
RESTGetTicker,
},
Route{
"GetPortfolio",
"GET",
http.MethodGet,
"/portfolio/all",
RESTGetPortfolio,
},
Route{
"AllActiveExchangesAndOrderbooks",
"GET",
http.MethodGet,
"/exchanges/orderbook/latest/all",
RESTGetAllActiveOrderbooks,
},
Route{
"IndividualExchangeOrderbook",
"GET",
http.MethodGet,
"/exchanges/{exchangeName}/orderbook/latest/{currency}",
RESTGetOrderbook,
},
Route{
"ws",
"GET",
http.MethodGet,
"/ws",
WebsocketClientHandler,
},

View File

@@ -42,32 +42,14 @@ func encodePEM(privKey *ecdsa.PrivateKey, pubKey bool) ([]byte, error) {
), nil
}
func decodePEM(PEMPrivKey, PEMPubKey []byte) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error) {
func decodePEM(PEMPrivKey []byte) (*ecdsa.PrivateKey, error) {
block, _ := pem.Decode(PEMPrivKey)
if block == nil {
return nil, nil, errors.New("priv block data is nil")
return nil, errors.New("priv block data is nil")
}
x509Enc := block.Bytes
privateKey, err := x509.ParseECPrivateKey(x509Enc)
if err != nil {
return nil, nil, err
}
blockPub, _ := pem.Decode(PEMPubKey)
if block == nil {
return nil, nil, errors.New("pub block data is nil")
}
x509EncPub := blockPub.Bytes
genPubkey, err := x509.ParsePKIXPublicKey(x509EncPub)
if err != nil {
return nil, nil, err
}
publicKey := genPubkey.(*ecdsa.PublicKey)
return privateKey, publicKey, nil
return x509.ParseECPrivateKey(x509Enc)
}
func writeFile(file string, data []byte) error {
@@ -124,7 +106,7 @@ func main() {
log.Println("Successfully read PEM files.")
var priv *ecdsa.PrivateKey
priv, _, err = decodePEM(privKeyData, pubKeyData)
priv, err = decodePEM(privKeyData)
if err != nil {
log.Fatal(err)
}