mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 15:10:19 +00:00
Engine: Protocol Features, coverage, types, BTC markets websocket (#368)
* Attempts to update orderbook so it doesn't need to sort * Reverts the ws ob stuff. Gets rid of sorting because it happens later. Adds some exchange features * update existing feature lists. Expands list definition to match my emotions * Adds bithumb bitmex and bitstamp. adds a couple more types * Features for you, features for me, features for bittrex, btcmarkets, btse, coinbasepro, coinut, exmo, gateio and gemini * Features for hitbtc, huobi, itbit, kraken, lakebtc, lbank, localbitcoins, okcoin, okex, poloniex, yobit, zb * Who can forget good old alphapoint? * Adds btcmarksets websocket :glitch_crab: fixes alphapoint features * Adds extra data not in the documentation :/ * Replaces websocket features by using protocol features. However, it breaks it due to import cycles. I'm not sure what I'll do just yet * Removes import cycle via duplicate structs. * Increases coverage of config with `TestCheckCurrencyConfigValues`. Moves all currency pair package types into their own files or places it at the bottom of files if necessary * Increase coverage in code.go * One way of determining a test has failed, is when to it fails. Removed redundant explanation * Increases code coverage of conversion * Lint fixes * Fixes orderbook tests * Re-adds sorting because its important to still have the internal pre-processed orderbook to be representative of a real orderbook * Secret lints that did not show up via Windows linting * Adds protocol package to contain exchange features * Fixes protocol implementation * Fixes ws tests * Addresses the following: Removes st-st-stutters in config types, changes GetAvailableForexProviders -> GetSupportedForexProviders, removes errors from tests where error is nil, removes orderbook setup when not necessary, removes import newlines, removes false bools from declaration, changes should of to should have * imports and casing * Fixes two more nil error checks
This commit is contained in:
@@ -32,11 +32,11 @@ func TestSetup(t *testing.T) {
|
||||
cfg := config.GetConfig()
|
||||
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
||||
if err != nil {
|
||||
t.Fatal("Test Failed - GateIO load config error", err)
|
||||
t.Fatal("GateIO load config error", err)
|
||||
}
|
||||
gateioConfig, err := cfg.GetExchangeConfig("GateIO")
|
||||
if err != nil {
|
||||
t.Error("Test Failed - GateIO Setup() init error")
|
||||
t.Error("GateIO Setup() init error")
|
||||
}
|
||||
gateioConfig.API.AuthenticatedSupport = true
|
||||
gateioConfig.API.AuthenticatedWebsocketSupport = true
|
||||
@@ -45,7 +45,7 @@ func TestSetup(t *testing.T) {
|
||||
|
||||
err = g.Setup(gateioConfig)
|
||||
if err != nil {
|
||||
t.Fatal("Test Failed - GateIO setup error", err)
|
||||
t.Fatal("GateIO setup error", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestGetSymbols(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetSymbols()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio TestGetSymbols: %s", err)
|
||||
t.Errorf("Gateio TestGetSymbols: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestGetMarketInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetMarketInfo()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetMarketInfo: %s", err)
|
||||
t.Errorf("Gateio GetMarketInfo: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestSpotNewOrder(t *testing.T) {
|
||||
Type: exchange.SellOrderSide.ToLower().ToString(),
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio SpotNewOrder: %s", err)
|
||||
t.Errorf("Gateio SpotNewOrder: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestCancelExistingOrder(t *testing.T) {
|
||||
|
||||
_, err := g.CancelExistingOrder(917591554, "btc_usdt")
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio CancelExistingOrder: %s", err)
|
||||
t.Errorf("Gateio CancelExistingOrder: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestGetBalances(t *testing.T) {
|
||||
|
||||
_, err := g.GetBalances()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetBalances: %s", err)
|
||||
t.Errorf("Gateio GetBalances: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func TestGetLatestSpotPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetLatestSpotPrice("btc_usdt")
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetLatestSpotPrice: %s", err)
|
||||
t.Errorf("Gateio GetLatestSpotPrice: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func TestGetTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetTicker("btc_usdt")
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetTicker: %s", err)
|
||||
t.Errorf("Gateio GetTicker: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestGetTickers(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetTickers()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetTicker: %s", err)
|
||||
t.Errorf("Gateio GetTicker: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func TestGetOrderbook(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetOrderbook("btc_usdt")
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetTicker: %s", err)
|
||||
t.Errorf("Gateio GetTicker: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestGetSpotKline(t *testing.T) {
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Gateio GetSpotKline: %s", err)
|
||||
t.Errorf("Gateio GetSpotKline: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ func TestGetFee(t *testing.T) {
|
||||
// CryptocurrencyTradeFee Basic
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0.002) || err != nil {
|
||||
t.Error(err)
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0.002), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0.002), resp)
|
||||
}
|
||||
|
||||
// CryptocurrencyTradeFee High quantity
|
||||
@@ -200,7 +200,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder.Amount = 1000
|
||||
feeBuilder.PurchasePrice = 1000
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(2000) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(2000), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(2000), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder = setFeeBuilder()
|
||||
feeBuilder.IsMaker = true
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0.002) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0.002), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0.002), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder = setFeeBuilder()
|
||||
feeBuilder.PurchasePrice = -1000
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder = setFeeBuilder()
|
||||
feeBuilder.FeeType = exchange.CryptocurrencyWithdrawalFee
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0.001) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0.001), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0.001), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder.Pair.Base = currency.NewCode("hello")
|
||||
feeBuilder.FeeType = exchange.CryptocurrencyWithdrawalFee
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder = setFeeBuilder()
|
||||
feeBuilder.FeeType = exchange.CyptocurrencyDepositFee
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder = setFeeBuilder()
|
||||
feeBuilder.FeeType = exchange.InternationalBankDepositFee
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ func TestGetFee(t *testing.T) {
|
||||
feeBuilder.FeeType = exchange.InternationalBankWithdrawalFee
|
||||
feeBuilder.FiatCurrency = currency.USD
|
||||
if resp, err := g.GetFee(feeBuilder); resp != float64(0) || err != nil {
|
||||
t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@@ -405,12 +405,12 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
if apiSecret == "" || apiKey == "" {
|
||||
_, err := g.GetAccountInfo()
|
||||
if err == nil {
|
||||
t.Error("Test Failed - GetAccountInfo() error")
|
||||
t.Error("GetAccountInfo() Expected error")
|
||||
}
|
||||
} else {
|
||||
_, err := g.GetAccountInfo()
|
||||
if err != nil {
|
||||
t.Error("Test Failed - GetAccountInfo() error", err)
|
||||
t.Error("GetAccountInfo() error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ func TestGetAccountInfo(t *testing.T) {
|
||||
func TestModifyOrder(t *testing.T) {
|
||||
_, err := g.ModifyOrder(&exchange.ModifyOrder{})
|
||||
if err == nil {
|
||||
t.Error("Test failed - ModifyOrder() error")
|
||||
t.Error("ModifyOrder() Expected error")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/protocol"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
|
||||
@@ -69,9 +70,34 @@ func (g *Gateio) SetDefaults() {
|
||||
Supports: exchange.FeaturesSupported{
|
||||
REST: true,
|
||||
Websocket: true,
|
||||
RESTCapabilities: exchange.ProtocolFeatures{
|
||||
AutoPairUpdates: true,
|
||||
TickerBatching: true,
|
||||
RESTCapabilities: protocol.Features{
|
||||
TickerBatching: true,
|
||||
TickerFetching: true,
|
||||
KlineFetching: true,
|
||||
TradeFetching: true,
|
||||
OrderbookFetching: true,
|
||||
AutoPairUpdates: true,
|
||||
AccountInfo: true,
|
||||
GetOrder: true,
|
||||
GetOrders: true,
|
||||
CancelOrders: true,
|
||||
CancelOrder: true,
|
||||
SubmitOrder: true,
|
||||
UserTradeHistory: true,
|
||||
CryptoDeposit: true,
|
||||
CryptoWithdrawal: true,
|
||||
TradeFee: true,
|
||||
CryptoWithdrawalFee: true,
|
||||
},
|
||||
WebsocketCapabilities: protocol.Features{
|
||||
TickerFetching: true,
|
||||
OrderbookFetching: true,
|
||||
TradeFetching: true,
|
||||
KlineFetching: true,
|
||||
Subscribe: true,
|
||||
Unsubscribe: true,
|
||||
AuthenticatedEndpoints: true,
|
||||
MessageCorrelation: true,
|
||||
},
|
||||
WithdrawPermissions: exchange.AutoWithdrawCrypto |
|
||||
exchange.NoFiatWithdrawals,
|
||||
@@ -92,14 +118,6 @@ func (g *Gateio) SetDefaults() {
|
||||
g.API.Endpoints.URLSecondary = g.API.Endpoints.URLSecondaryDefault
|
||||
g.API.Endpoints.WebsocketURL = gateioWebsocketEndpoint
|
||||
g.Websocket = wshandler.New()
|
||||
g.Websocket.Functionality = wshandler.WebsocketTickerSupported |
|
||||
wshandler.WebsocketTradeDataSupported |
|
||||
wshandler.WebsocketOrderbookSupported |
|
||||
wshandler.WebsocketKlineSupported |
|
||||
wshandler.WebsocketSubscribeSupported |
|
||||
wshandler.WebsocketUnsubscribeSupported |
|
||||
wshandler.WebsocketAuthenticatedEndpointsSupported |
|
||||
wshandler.WebsocketMessageCorrelationSupported
|
||||
g.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit
|
||||
g.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout
|
||||
g.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit
|
||||
@@ -129,6 +147,7 @@ func (g *Gateio) Setup(exch *config.ExchangeConfig) error {
|
||||
Connector: g.WsConnect,
|
||||
Subscriber: g.Subscribe,
|
||||
UnSubscriber: g.Unsubscribe,
|
||||
Features: &g.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user