mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
exchanges: improves GetDefaultConfig method (#1245)
* exchanges: Add function to get standard config * exchanges: add tests (cherry-pick here and above) * after pick stuff * cleanup --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -1048,23 +1048,23 @@ func (c *Config) CheckExchangeConfigValues() error {
|
||||
log.Warnf(log.ConfigMgr,
|
||||
"Exchange %s Websocket response check timeout value not set, defaulting to %v.",
|
||||
c.Exchanges[i].Name,
|
||||
defaultWebsocketResponseCheckTimeout)
|
||||
c.Exchanges[i].WebsocketResponseCheckTimeout = defaultWebsocketResponseCheckTimeout
|
||||
DefaultWebsocketResponseCheckTimeout)
|
||||
c.Exchanges[i].WebsocketResponseCheckTimeout = DefaultWebsocketResponseCheckTimeout
|
||||
}
|
||||
|
||||
if c.Exchanges[i].WebsocketResponseMaxLimit <= 0 {
|
||||
log.Warnf(log.ConfigMgr,
|
||||
"Exchange %s Websocket response max limit value not set, defaulting to %v.",
|
||||
c.Exchanges[i].Name,
|
||||
defaultWebsocketResponseMaxLimit)
|
||||
c.Exchanges[i].WebsocketResponseMaxLimit = defaultWebsocketResponseMaxLimit
|
||||
DefaultWebsocketResponseMaxLimit)
|
||||
c.Exchanges[i].WebsocketResponseMaxLimit = DefaultWebsocketResponseMaxLimit
|
||||
}
|
||||
if c.Exchanges[i].WebsocketTrafficTimeout <= 0 {
|
||||
log.Warnf(log.ConfigMgr,
|
||||
"Exchange %s Websocket response traffic timeout value not set, defaulting to %v.",
|
||||
c.Exchanges[i].Name,
|
||||
defaultWebsocketTrafficTimeout)
|
||||
c.Exchanges[i].WebsocketTrafficTimeout = defaultWebsocketTrafficTimeout
|
||||
DefaultWebsocketTrafficTimeout)
|
||||
c.Exchanges[i].WebsocketTrafficTimeout = DefaultWebsocketTrafficTimeout
|
||||
}
|
||||
if c.Exchanges[i].Orderbook.WebsocketBufferLimit <= 0 {
|
||||
log.Warnf(log.ConfigMgr,
|
||||
|
||||
@@ -26,10 +26,7 @@ const (
|
||||
fileEncryptionDisabled = -1
|
||||
pairsLastUpdatedWarningThreshold = 30 // 30 days
|
||||
defaultHTTPTimeout = time.Second * 15
|
||||
defaultWebsocketResponseCheckTimeout = time.Millisecond * 30
|
||||
defaultWebsocketResponseMaxLimit = time.Second * 7
|
||||
defaultWebsocketOrderbookBufferLimit = 5
|
||||
defaultWebsocketTrafficTimeout = time.Second * 30
|
||||
DefaultConnectionMonitorDelay = time.Second * 2
|
||||
maxAuthFailures = 3
|
||||
defaultNTPAllowedDifference = 50000000
|
||||
@@ -47,6 +44,15 @@ const (
|
||||
DefaultSyncerTimeoutREST = time.Second * 15
|
||||
// DefaultSyncerTimeoutWebsocket the default time to switch from websocket to REST protocols without a response
|
||||
DefaultSyncerTimeoutWebsocket = time.Minute
|
||||
// DefaultWebsocketResponseCheckTimeout is the default timeout for
|
||||
// websocket responses.
|
||||
DefaultWebsocketResponseCheckTimeout = time.Millisecond * 30
|
||||
// DefaultWebsocketResponseMaxLimit is the default maximum time for
|
||||
// websocket responses.
|
||||
DefaultWebsocketResponseMaxLimit = time.Second * 7
|
||||
// DefaultWebsocketTrafficTimeout is the default timeout for websocket
|
||||
// traffic.
|
||||
DefaultWebsocketTrafficTimeout = time.Second * 30
|
||||
)
|
||||
|
||||
// Constants here hold some messages
|
||||
|
||||
@@ -380,12 +380,38 @@ func TestGetDefaultConfigurations(t *testing.T) {
|
||||
|
||||
defaultCfg, err := exch.GetDefaultConfig(context.Background())
|
||||
if err != nil {
|
||||
// Use Error instead of fatal to allow all issues to arise
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if defaultCfg == nil {
|
||||
t.Error("expected config")
|
||||
t.Fatal("expected config")
|
||||
}
|
||||
|
||||
if defaultCfg.Name == "" {
|
||||
t.Error("name unset SetDefaults() not called")
|
||||
}
|
||||
|
||||
if !defaultCfg.Enabled {
|
||||
t.Error("expected enabled", defaultCfg.Name)
|
||||
}
|
||||
|
||||
if exch.SupportsWebsocket() {
|
||||
if defaultCfg.WebsocketResponseCheckTimeout <= 0 {
|
||||
t.Error("expected websocketResponseCheckTimeout to be greater than 0", defaultCfg.Name)
|
||||
}
|
||||
|
||||
if defaultCfg.WebsocketResponseMaxLimit <= 0 {
|
||||
t.Error("expected WebsocketResponseMaxLimit to be greater than 0", defaultCfg.Name)
|
||||
}
|
||||
|
||||
if defaultCfg.WebsocketTrafficTimeout <= 0 {
|
||||
t.Error("expected WebsocketTrafficTimeout to be greater than 0", defaultCfg.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// Makes sure the config is valid and can be used to setup the exchange
|
||||
if err := exch.Setup(defaultCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Binance) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -237,15 +237,14 @@ func (b *Binance) Setup(exch *config.Exchange) error {
|
||||
return err
|
||||
}
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: binanceDefaultWebsocketURL,
|
||||
RunningURL: ePoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: binanceDefaultWebsocketURL,
|
||||
RunningURL: ePoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -32,12 +32,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (bi *Binanceus) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
bi.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = bi.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = bi.BaseCurrencies
|
||||
exchCfg, err := bi.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := bi.SetupDefaults(exchCfg)
|
||||
err = bi.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -188,15 +188,14 @@ func (bi *Binanceus) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = bi.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: binanceusDefaultWebsocketURL,
|
||||
RunningURL: ePoint,
|
||||
Connector: bi.WsConnect,
|
||||
Subscriber: bi.Subscribe,
|
||||
Unsubscriber: bi.Unsubscribe,
|
||||
GenerateSubscriptions: bi.GenerateSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &bi.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: binanceusDefaultWebsocketURL,
|
||||
RunningURL: ePoint,
|
||||
Connector: bi.WsConnect,
|
||||
Subscriber: bi.Subscribe,
|
||||
Unsubscriber: bi.Unsubscribe,
|
||||
GenerateSubscriptions: bi.GenerateSubscriptions,
|
||||
Features: &bi.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -34,12 +34,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bitfinex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -214,15 +214,14 @@ func (b *Bitfinex) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: publicBitfinexWebsocketEndpoint,
|
||||
RunningURL: wsEndpoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: publicBitfinexWebsocketEndpoint,
|
||||
RunningURL: wsEndpoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
UpdateEntriesByID: true,
|
||||
},
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bitflyer) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ var errNotEnoughPairs = errors.New("at least one currency is required to fetch o
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bithumb) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -179,14 +179,13 @@ func (b *Bithumb) Setup(exch *config.Exchange) error {
|
||||
return err
|
||||
}
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: wsEndpoint,
|
||||
RunningURL: ePoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
GenerateSubscriptions: b.GenerateSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: wsEndpoint,
|
||||
RunningURL: ePoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
GenerateSubscriptions: b.GenerateSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -34,12 +34,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bitmex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -183,15 +183,14 @@ func (b *Bitmex) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bitmexWSURL,
|
||||
RunningURL: wsEndpoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bitmexWSURL,
|
||||
RunningURL: wsEndpoint,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
UpdateEntriesByID: true,
|
||||
},
|
||||
|
||||
@@ -32,11 +32,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bitstamp) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,15 +172,14 @@ func (b *Bitstamp) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bitstampWSURL,
|
||||
RunningURL: wsURL,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.generateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bitstampWSURL,
|
||||
RunningURL: wsURL,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.generateDefaultSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -37,12 +37,12 @@ var (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bittrex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,15 +171,14 @@ func (b *Bittrex) Setup(exch *config.Exchange) error {
|
||||
|
||||
// Websocket details setup below
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bittrexAPIWSURL, // Default ws endpoint so we can roll back via CLI if needed.
|
||||
RunningURL: wsRunningEndpoint,
|
||||
Connector: b.WsConnect, // Connector function outlined above.
|
||||
Subscriber: b.Subscribe, // Subscriber function outlined above.
|
||||
Unsubscriber: b.Unsubscribe, // Unsubscriber function outlined above.
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions, // GenerateDefaultSubscriptions function outlined above.
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities, // Defines the capabilities of the websocket outlined in supported features struct. This allows the websocket connection to be flushed appropriately if we have a pair/asset enable/disable change. This is outlined below.
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bittrexAPIWSURL, // Default ws endpoint so we can roll back via CLI if needed.
|
||||
RunningURL: wsRunningEndpoint,
|
||||
Connector: b.WsConnect, // Connector function outlined above.
|
||||
Subscriber: b.Subscribe, // Subscriber function outlined above.
|
||||
Unsubscriber: b.Unsubscribe, // Unsubscriber function outlined above.
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions, // GenerateDefaultSubscriptions function outlined above.
|
||||
Features: &b.Features.Supports.WebsocketCapabilities, // Defines the capabilities of the websocket outlined in supported features struct. This allows the websocket connection to be flushed appropriately if we have a pair/asset enable/disable change. This is outlined below.
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -36,12 +36,12 @@ var errFailedToConvertToCandle = errors.New("cannot convert time series data to
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *BTCMarkets) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -176,15 +176,14 @@ func (b *BTCMarkets) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: btcMarketsWSURL,
|
||||
RunningURL: wsURL,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.generateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: btcMarketsWSURL,
|
||||
RunningURL: wsURL,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.generateDefaultSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
UpdateIDProgression: true,
|
||||
|
||||
@@ -33,12 +33,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *BTSE) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
b.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
exchCfg, err := b.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := b.SetupDefaults(exchCfg)
|
||||
err = b.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -185,15 +185,14 @@ func (b *BTSE) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: btseWebsocket,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: btseWebsocket,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: b.WsConnect,
|
||||
Subscriber: b.Subscribe,
|
||||
Unsubscriber: b.Unsubscribe,
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
|
||||
Features: &b.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -32,12 +32,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (by *Bybit) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
by.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = by.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = by.BaseCurrencies
|
||||
exchCfg, err := by.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := by.SetupDefaults(exchCfg)
|
||||
err = by.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -204,16 +204,15 @@ func (by *Bybit) Setup(exch *config.Exchange) error {
|
||||
|
||||
err = by.Websocket.Setup(
|
||||
&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bybitWSBaseURL + wsSpotPublicTopicV2,
|
||||
RunningURL: wsRunningEndpoint,
|
||||
RunningURLAuth: bybitWSBaseURL + wsSpotPrivate,
|
||||
Connector: by.WsConnect,
|
||||
Subscriber: by.Subscribe,
|
||||
Unsubscriber: by.Unsubscribe,
|
||||
GenerateSubscriptions: by.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &by.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bybitWSBaseURL + wsSpotPublicTopicV2,
|
||||
RunningURL: wsRunningEndpoint,
|
||||
RunningURLAuth: bybitWSBaseURL + wsSpotPrivate,
|
||||
Connector: by.WsConnect,
|
||||
Subscriber: by.Subscribe,
|
||||
Unsubscriber: by.Unsubscribe,
|
||||
GenerateSubscriptions: by.GenerateDefaultSubscriptions,
|
||||
Features: &by.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -31,12 +31,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (c *CoinbasePro) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
c.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = c.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = c.BaseCurrencies
|
||||
exchCfg, err := c.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := c.SetupDefaults(exchCfg)
|
||||
err = c.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,20 +171,20 @@ func (c *CoinbasePro) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = c.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: coinbaseproWebsocketURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: c.WsConnect,
|
||||
Subscriber: c.Subscribe,
|
||||
Unsubscriber: c.Unsubscribe,
|
||||
GenerateSubscriptions: c.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &c.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: coinbaseproWebsocketURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: c.WsConnect,
|
||||
Subscriber: c.Subscribe,
|
||||
Unsubscriber: c.Unsubscribe,
|
||||
GenerateSubscriptions: c.GenerateDefaultSubscriptions,
|
||||
Features: &c.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("COINBASE ISSUE")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (c *COINUT) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
c.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = c.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = c.BaseCurrencies
|
||||
exchCfg, err := c.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := c.SetupDefaults(exchCfg)
|
||||
err = c.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -153,15 +153,14 @@ func (c *COINUT) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = c.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: coinutWebsocketURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: c.WsConnect,
|
||||
Subscriber: c.Subscribe,
|
||||
Unsubscriber: c.Unsubscribe,
|
||||
GenerateSubscriptions: c.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &c.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: coinutWebsocketURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: c.WsConnect,
|
||||
Subscriber: c.Subscribe,
|
||||
Unsubscriber: c.Unsubscribe,
|
||||
GenerateSubscriptions: c.GenerateDefaultSubscriptions,
|
||||
Features: &c.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -51,6 +51,8 @@ var (
|
||||
errGlobalConfigFormatIsNil = errors.New("global config format is nil")
|
||||
errAssetRequestFormatIsNil = errors.New("asset type request format is nil")
|
||||
errAssetConfigFormatIsNil = errors.New("asset type config format is nil")
|
||||
errSetDefaultsNotCalled = errors.New("set defaults not called")
|
||||
errExchangeIsNil = errors.New("exchange is nil")
|
||||
)
|
||||
|
||||
// SetRequester sets the instance of the requester
|
||||
@@ -1659,3 +1661,30 @@ func (b *Base) Shutdown() error {
|
||||
}
|
||||
return b.Requester.Shutdown()
|
||||
}
|
||||
|
||||
// GetStandardConfig returns a standard default exchange config. Set defaults
|
||||
// must populate base struct with exchange specific defaults before calling
|
||||
// this function.
|
||||
func (b *Base) GetStandardConfig() (*config.Exchange, error) {
|
||||
if b == nil {
|
||||
return nil, errExchangeIsNil
|
||||
}
|
||||
|
||||
if b.Name == "" {
|
||||
return nil, errSetDefaultsNotCalled
|
||||
}
|
||||
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = b.Name
|
||||
exchCfg.Enabled = b.Enabled
|
||||
exchCfg.HTTPTimeout = DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = b.BaseCurrencies
|
||||
|
||||
if b.SupportsWebsocket() {
|
||||
exchCfg.WebsocketResponseCheckTimeout = config.DefaultWebsocketResponseCheckTimeout
|
||||
exchCfg.WebsocketResponseMaxLimit = config.DefaultWebsocketResponseMaxLimit
|
||||
exchCfg.WebsocketTrafficTimeout = config.DefaultWebsocketTrafficTimeout
|
||||
}
|
||||
|
||||
return exchCfg, nil
|
||||
}
|
||||
|
||||
@@ -2988,3 +2988,47 @@ func TestEnsureOnePairEnabled(t *testing.T) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", len(b.CurrencyPairs.Pairs[asset.Spot].Enabled), 1)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStandardConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var b *Base
|
||||
_, err := b.GetStandardConfig()
|
||||
if !errors.Is(err, errExchangeIsNil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, errExchangeIsNil)
|
||||
}
|
||||
|
||||
b = &Base{}
|
||||
_, err = b.GetStandardConfig()
|
||||
if !errors.Is(err, errSetDefaultsNotCalled) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, errSetDefaultsNotCalled)
|
||||
}
|
||||
|
||||
b.Name = "test"
|
||||
b.Features.Supports.Websocket = true
|
||||
|
||||
cfg, err := b.GetStandardConfig()
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
if cfg.Name != "test" {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", cfg.Name, "test")
|
||||
}
|
||||
|
||||
if cfg.HTTPTimeout != DefaultHTTPTimeout {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", cfg.HTTPTimeout, DefaultHTTPTimeout)
|
||||
}
|
||||
|
||||
if cfg.WebsocketResponseCheckTimeout != config.DefaultWebsocketResponseCheckTimeout {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", cfg.WebsocketResponseCheckTimeout, config.DefaultWebsocketResponseCheckTimeout)
|
||||
}
|
||||
|
||||
if cfg.WebsocketResponseMaxLimit != config.DefaultWebsocketResponseMaxLimit {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", cfg.WebsocketResponseMaxLimit, config.DefaultWebsocketResponseMaxLimit)
|
||||
}
|
||||
|
||||
if cfg.WebsocketTrafficTimeout != config.DefaultWebsocketTrafficTimeout {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", cfg.WebsocketTrafficTimeout, config.DefaultWebsocketTrafficTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (e *EXMO) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
e.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = e.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = e.BaseCurrencies
|
||||
exchCfg, err := e.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := e.SetupDefaults(exchCfg)
|
||||
err = e.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (g *Gateio) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
g.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = g.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = g.BaseCurrencies
|
||||
exchCfg, err := g.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := g.SetupDefaults(exchCfg)
|
||||
err = g.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -201,17 +201,16 @@ func (g *Gateio) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = g.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: gateioWebsocketEndpoint,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: g.WsConnect,
|
||||
Subscriber: g.Subscribe,
|
||||
Unsubscriber: g.Unsubscribe,
|
||||
GenerateSubscriptions: g.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &g.Features.Supports.WebsocketCapabilities,
|
||||
FillsFeed: g.Features.Enabled.FillsFeed,
|
||||
TradeFeed: g.Features.Enabled.TradeFeed,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: gateioWebsocketEndpoint,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: g.WsConnect,
|
||||
Subscriber: g.Subscribe,
|
||||
Unsubscriber: g.Unsubscribe,
|
||||
GenerateSubscriptions: g.GenerateDefaultSubscriptions,
|
||||
Features: &g.Features.Supports.WebsocketCapabilities,
|
||||
FillsFeed: g.Features.Enabled.FillsFeed,
|
||||
TradeFeed: g.Features.Enabled.TradeFeed,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -32,12 +32,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (g *Gemini) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
g.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = g.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = g.BaseCurrencies
|
||||
exchCfg, err := g.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := g.SetupDefaults(exchCfg)
|
||||
err = g.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -160,15 +160,14 @@ func (g *Gemini) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = g.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: geminiWebsocketEndpoint,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: g.WsConnect,
|
||||
Subscriber: g.Subscribe,
|
||||
Unsubscriber: g.Unsubscribe,
|
||||
GenerateSubscriptions: g.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &g.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: geminiWebsocketEndpoint,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: g.WsConnect,
|
||||
Subscriber: g.Subscribe,
|
||||
Unsubscriber: g.Unsubscribe,
|
||||
GenerateSubscriptions: g.GenerateDefaultSubscriptions,
|
||||
Features: &g.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -33,12 +33,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (h *HitBTC) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
h.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = h.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = h.BaseCurrencies
|
||||
exchCfg, err := h.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := h.SetupDefaults(exchCfg)
|
||||
err = h.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,15 +173,14 @@ func (h *HitBTC) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = h.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: hitbtcWebsocketAddress,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: h.WsConnect,
|
||||
Subscriber: h.Subscribe,
|
||||
Unsubscriber: h.Unsubscribe,
|
||||
GenerateSubscriptions: h.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &h.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: hitbtcWebsocketAddress,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: h.WsConnect,
|
||||
Subscriber: h.Subscribe,
|
||||
Unsubscriber: h.Unsubscribe,
|
||||
GenerateSubscriptions: h.GenerateDefaultSubscriptions,
|
||||
Features: &h.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -32,12 +32,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (h *HUOBI) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
h.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = h.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = h.BaseCurrencies
|
||||
exchCfg, err := h.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := h.SetupDefaults(exchCfg)
|
||||
err = h.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -209,15 +209,14 @@ func (h *HUOBI) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = h.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: wsMarketURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: h.WsConnect,
|
||||
Subscriber: h.Subscribe,
|
||||
Unsubscriber: h.Unsubscribe,
|
||||
GenerateSubscriptions: h.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &h.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: wsMarketURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: h.WsConnect,
|
||||
Subscriber: h.Subscribe,
|
||||
Unsubscriber: h.Unsubscribe,
|
||||
GenerateSubscriptions: h.GenerateDefaultSubscriptions,
|
||||
Features: &h.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (i *ItBit) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
i.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = i.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = i.BaseCurrencies
|
||||
exchCfg, err := i.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := i.SetupDefaults(exchCfg)
|
||||
err = i.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (k *Kraken) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
k.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = k.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = k.BaseCurrencies
|
||||
exchCfg, err := k.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := k.SetupDefaults(exchCfg)
|
||||
err = k.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -220,16 +220,15 @@ func (k *Kraken) Setup(exch *config.Exchange) error {
|
||||
return err
|
||||
}
|
||||
err = k.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: krakenWSURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: k.WsConnect,
|
||||
Subscriber: k.Subscribe,
|
||||
Unsubscriber: k.Unsubscribe,
|
||||
GenerateSubscriptions: k.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &k.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{SortBuffer: true},
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: krakenWSURL,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: k.WsConnect,
|
||||
Subscriber: k.Subscribe,
|
||||
Unsubscriber: k.Unsubscribe,
|
||||
GenerateSubscriptions: k.GenerateDefaultSubscriptions,
|
||||
Features: &k.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{SortBuffer: true},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (l *Lbank) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
l.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = l.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = l.BaseCurrencies
|
||||
exchCfg, err := l.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := l.SetupDefaults(exchCfg)
|
||||
err = l.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (o *Okcoin) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
o.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = o.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = o.BaseCurrencies
|
||||
exchCfg, err := o.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := o.Setup(exchCfg)
|
||||
err = o.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -175,16 +175,15 @@ func (o *Okcoin) Setup(exch *config.Exchange) error {
|
||||
return err
|
||||
}
|
||||
err = o.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: wsEndpoint,
|
||||
RunningURL: wsEndpoint,
|
||||
RunningURLAuth: okcoinPrivateWebsocketURL,
|
||||
Connector: o.WsConnect,
|
||||
Subscriber: o.Subscribe,
|
||||
Unsubscriber: o.Unsubscribe,
|
||||
GenerateSubscriptions: o.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &o.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: wsEndpoint,
|
||||
RunningURL: wsEndpoint,
|
||||
RunningURLAuth: okcoinPrivateWebsocketURL,
|
||||
Connector: o.WsConnect,
|
||||
Subscriber: o.Subscribe,
|
||||
Unsubscriber: o.Unsubscribe,
|
||||
GenerateSubscriptions: o.GenerateDefaultSubscriptions,
|
||||
Features: &o.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -39,12 +39,12 @@ const (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (ok *Okx) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
ok.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = ok.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = ok.BaseCurrencies
|
||||
exchCfg, err := ok.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := ok.SetupDefaults(exchCfg)
|
||||
err = ok.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -204,15 +204,14 @@ func (ok *Okx) Setup(exch *config.Exchange) error {
|
||||
return err
|
||||
}
|
||||
if err := ok.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: okxAPIWebsocketPublicURL,
|
||||
RunningURL: wsRunningEndpoint,
|
||||
Connector: ok.WsConnect,
|
||||
Subscriber: ok.Subscribe,
|
||||
Unsubscriber: ok.Unsubscribe,
|
||||
GenerateSubscriptions: ok.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &ok.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: okxAPIWebsocketPublicURL,
|
||||
RunningURL: wsRunningEndpoint,
|
||||
Connector: ok.WsConnect,
|
||||
Subscriber: ok.Subscribe,
|
||||
Unsubscriber: ok.Unsubscribe,
|
||||
GenerateSubscriptions: ok.GenerateDefaultSubscriptions,
|
||||
Features: &ok.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
Checksum: ok.CalculateUpdateOrderbookChecksum,
|
||||
},
|
||||
|
||||
@@ -33,12 +33,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (p *Poloniex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
p.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = p.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = p.BaseCurrencies
|
||||
exchCfg, err := p.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := p.SetupDefaults(exchCfg)
|
||||
err = p.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -185,15 +185,14 @@ func (p *Poloniex) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = p.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: poloniexWebsocketAddress,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: p.WsConnect,
|
||||
Subscriber: p.Subscribe,
|
||||
Unsubscriber: p.Unsubscribe,
|
||||
GenerateSubscriptions: p.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Features: &p.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: poloniexWebsocketAddress,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: p.WsConnect,
|
||||
Subscriber: p.Subscribe,
|
||||
Unsubscriber: p.Unsubscribe,
|
||||
GenerateSubscriptions: p.GenerateDefaultSubscriptions,
|
||||
Features: &p.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferConfig: buffer.Config{
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
|
||||
@@ -119,7 +119,7 @@ func (w *Websocket) Setup(s *WebsocketSetup) error {
|
||||
if w.features.Unsubscribe && s.Unsubscriber == nil {
|
||||
return fmt.Errorf("%s %w", w.exchangeName, errWebsocketUnsubscriberUnset)
|
||||
}
|
||||
w.connectionMonitorDelay = s.ConnectionMonitorDelay
|
||||
w.connectionMonitorDelay = s.ExchangeConfig.ConnectionMonitorDelay
|
||||
if w.connectionMonitorDelay <= 0 {
|
||||
w.connectionMonitorDelay = config.DefaultConnectionMonitorDelay
|
||||
}
|
||||
|
||||
@@ -97,16 +97,15 @@ type Websocket struct {
|
||||
|
||||
// WebsocketSetup defines variables for setting up a websocket connection
|
||||
type WebsocketSetup struct {
|
||||
ExchangeConfig *config.Exchange
|
||||
DefaultURL string
|
||||
RunningURL string
|
||||
RunningURLAuth string
|
||||
Connector func() error
|
||||
Subscriber func([]ChannelSubscription) error
|
||||
Unsubscriber func([]ChannelSubscription) error
|
||||
GenerateSubscriptions func() ([]ChannelSubscription, error)
|
||||
Features *protocol.Features
|
||||
ConnectionMonitorDelay time.Duration
|
||||
ExchangeConfig *config.Exchange
|
||||
DefaultURL string
|
||||
RunningURL string
|
||||
RunningURLAuth string
|
||||
Connector func() error
|
||||
Subscriber func([]ChannelSubscription) error
|
||||
Unsubscriber func([]ChannelSubscription) error
|
||||
GenerateSubscriptions func() ([]ChannelSubscription, error)
|
||||
Features *protocol.Features
|
||||
|
||||
// Local orderbook buffer config values
|
||||
OrderbookBufferConfig buffer.Config
|
||||
|
||||
@@ -31,12 +31,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (y *Yobit) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
y.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = y.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = y.BaseCurrencies
|
||||
exchCfg, err := y.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := y.SetupDefaults(exchCfg)
|
||||
err = y.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ import (
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (z *ZB) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
z.SetDefaults()
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = z.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = z.BaseCurrencies
|
||||
exchCfg, err := z.GetStandardConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := z.SetupDefaults(exchCfg)
|
||||
err = z.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -175,14 +175,13 @@ func (z *ZB) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
err = z.Websocket.Setup(&stream.WebsocketSetup{
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: zbWebsocketAPI,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: z.WsConnect,
|
||||
GenerateSubscriptions: z.GenerateDefaultSubscriptions,
|
||||
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
|
||||
Subscriber: z.Subscribe,
|
||||
Features: &z.Features.Supports.WebsocketCapabilities,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: zbWebsocketAPI,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: z.WsConnect,
|
||||
GenerateSubscriptions: z.GenerateDefaultSubscriptions,
|
||||
Subscriber: z.Subscribe,
|
||||
Features: &z.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user