mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 15:10:46 +00:00
exchanges: shift GetDefaultConfig wrapper function to exchange.go (#1472)
* Shift wrapper function GetDefaultConfig to exchange.Base method definition, to ensure set defaults doesn't get called twice and to reduce code * rm alphapoint bootstrap method as is defined as exchange.Base method * add tests * glorious: make it a function and make it IBOTEXCHANGE --------- Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -398,9 +398,7 @@ func (d *dataChecker) FetchLatestData() (bool, error) {
|
|||||||
if !d.hasUpdatedFunding {
|
if !d.hasUpdatedFunding {
|
||||||
err = d.UpdateFunding(false)
|
err = d.UpdateFunding(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != nil {
|
log.Errorln(common.LiveStrategy, err)
|
||||||
log.Errorln(common.LiveStrategy, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,14 +145,16 @@ func (bt *BackTest) SetupFromConfig(cfg *config.Config, templatePath, output str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
exch.SetDefaults()
|
|
||||||
exchBase := exch.GetBase()
|
|
||||||
exchBase.Verbose = cfg.DataSettings.VerboseExchangeRequests
|
|
||||||
var dc *gctconfig.Exchange
|
var dc *gctconfig.Exchange
|
||||||
dc, err = exch.GetDefaultConfig(context.TODO())
|
dc, err = gctexchange.GetDefaultConfig(context.TODO(), exch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exchBase := exch.GetBase()
|
||||||
|
exchBase.Verbose = cfg.DataSettings.VerboseExchangeRequests
|
||||||
|
|
||||||
err = exch.Setup(dc)
|
err = exch.Setup(dc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func main() {
|
|||||||
cfgs := make([]config.Exchange, 0, len(exchanges))
|
cfgs := make([]config.Exchange, 0, len(exchanges))
|
||||||
for x := range exchanges {
|
for x := range exchanges {
|
||||||
var cfg *config.Exchange
|
var cfg *config.Exchange
|
||||||
cfg, err = exchanges[x].GetDefaultConfig(context.Background())
|
cfg, err = exchange.GetDefaultConfig(context.Background(), exchanges[x])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to get exchanges default config. Err: %s", err)
|
log.Printf("Failed to get exchanges default config. Err: %s", err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -26,25 +26,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func ({{.Variable}} *{{.CapitalName}}) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
{{.Variable}}.SetDefaults()
|
|
||||||
exchCfg := new(config.Exchange)
|
|
||||||
exchCfg.Name = {{.Variable}}.Name
|
|
||||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
|
||||||
exchCfg.BaseCurrencies = {{.Variable}}.BaseCurrencies
|
|
||||||
|
|
||||||
{{.Variable}}.SetupDefaults(exchCfg)
|
|
||||||
|
|
||||||
if {{.Variable}}.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err := {{.Variable}}.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for {{.CapitalName}}
|
// SetDefaults sets the basic defaults for {{.CapitalName}}
|
||||||
func ({{.Variable}} *{{.CapitalName}}) SetDefaults() {
|
func ({{.Variable}} *{{.CapitalName}}) SetDefaults() {
|
||||||
{{.Variable}}.Name = "{{.CapitalName}}"
|
{{.Variable}}.Name = "{{.CapitalName}}"
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ func TestGetDefaultConfigurations(t *testing.T) {
|
|||||||
t.Skipf("skipping %s unsupported", name)
|
t.Skipf("skipping %s unsupported", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultCfg, err := exch.GetDefaultConfig(context.Background())
|
defaultCfg, err := exchange.GetDefaultConfig(context.Background(), exch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||||
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
||||||
)
|
)
|
||||||
@@ -281,8 +282,7 @@ func TestCheckEventCondition(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exch.SetDefaults()
|
conf, err := exchange.GetDefaultConfig(context.Background(), exch)
|
||||||
conf, err := exch.GetDefaultConfig(context.Background())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1054,7 +1054,7 @@ func NewExchangeByNameWithDefaults(ctx context.Context, name string) (exchange.I
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defaultConfig, err := exch.GetDefaultConfig(ctx)
|
defaultConfig, err := exchange.GetDefaultConfig(ctx, exch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,9 +267,8 @@ func OrdersSetup(t *testing.T) *OrderManager {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exch.SetDefaults()
|
|
||||||
|
|
||||||
cfg, err := exch.GetDefaultConfig(context.Background())
|
cfg, err := exchange.GetDefaultConfig(context.Background(), exch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ func withdrawManagerTestHelper(t *testing.T) (*ExchangeManager, *portfolioManage
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
em := NewExchangeManager()
|
em := NewExchangeManager()
|
||||||
b := new(okx.Okx)
|
b := new(okx.Okx)
|
||||||
b.SetDefaults()
|
cfg, err := exchange.GetDefaultConfig(context.Background(), b)
|
||||||
cfg, err := b.GetDefaultConfig(context.Background())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,16 +26,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config for Alphapoint
|
|
||||||
func (a *Alphapoint) GetDefaultConfig(_ context.Context) (*config.Exchange, error) {
|
|
||||||
return nil, common.ErrFunctionNotSupported
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bootstrap loads the exchange and performs initialisation tasks
|
|
||||||
func (a *Alphapoint) Bootstrap(_ context.Context) (continueBootstrap bool, err error) {
|
|
||||||
return false, common.ErrNotYetImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets current default settings
|
// SetDefaults sets current default settings
|
||||||
func (a *Alphapoint) SetDefaults() {
|
func (a *Alphapoint) SetDefaults() {
|
||||||
a.Name = "Alphapoint"
|
a.Name = "Alphapoint"
|
||||||
|
|||||||
@@ -36,29 +36,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *Binance) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Binance
|
// SetDefaults sets the basic defaults for Binance
|
||||||
func (b *Binance) SetDefaults() {
|
func (b *Binance) SetDefaults() {
|
||||||
b.Name = "Binance"
|
b.Name = "Binance"
|
||||||
|
|||||||
@@ -30,28 +30,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (bi *Binanceus) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
bi.SetDefaults()
|
|
||||||
exchCfg, err := bi.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = bi.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if bi.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err := bi.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Binanceus
|
// SetDefaults sets the basic defaults for Binanceus
|
||||||
func (bi *Binanceus) SetDefaults() {
|
func (bi *Binanceus) SetDefaults() {
|
||||||
bi.Name = "Binanceus"
|
bi.Name = "Binanceus"
|
||||||
|
|||||||
@@ -33,29 +33,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *Bitfinex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for bitfinex
|
// SetDefaults sets the basic defaults for bitfinex
|
||||||
func (b *Bitfinex) SetDefaults() {
|
func (b *Bitfinex) SetDefaults() {
|
||||||
b.Name = "Bitfinex"
|
b.Name = "Bitfinex"
|
||||||
|
|||||||
@@ -28,29 +28,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *Bitflyer) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Bitflyer
|
// SetDefaults sets the basic defaults for Bitflyer
|
||||||
func (b *Bitflyer) SetDefaults() {
|
func (b *Bitflyer) SetDefaults() {
|
||||||
b.Name = "Bitflyer"
|
b.Name = "Bitflyer"
|
||||||
|
|||||||
@@ -36,29 +36,6 @@ const wsRateLimitMillisecond = 1000
|
|||||||
|
|
||||||
var errNotEnoughPairs = errors.New("at least one currency is required to fetch order history")
|
var errNotEnoughPairs = errors.New("at least one currency is required to fetch order history")
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *Bithumb) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Bithumb
|
// SetDefaults sets the basic defaults for Bithumb
|
||||||
func (b *Bithumb) SetDefaults() {
|
func (b *Bithumb) SetDefaults() {
|
||||||
b.Name = "Bithumb"
|
b.Name = "Bithumb"
|
||||||
|
|||||||
@@ -34,29 +34,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *Bitmex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Bitmex
|
// SetDefaults sets the basic defaults for Bitmex
|
||||||
func (b *Bitmex) SetDefaults() {
|
func (b *Bitmex) SetDefaults() {
|
||||||
b.Name = "Bitmex"
|
b.Name = "Bitmex"
|
||||||
|
|||||||
@@ -30,29 +30,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *Bitstamp) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets default for Bitstamp
|
// SetDefaults sets default for Bitstamp
|
||||||
func (b *Bitstamp) SetDefaults() {
|
func (b *Bitstamp) SetDefaults() {
|
||||||
b.Name = "Bitstamp"
|
b.Name = "Bitstamp"
|
||||||
|
|||||||
@@ -34,29 +34,6 @@ import (
|
|||||||
|
|
||||||
var errFailedToConvertToCandle = errors.New("cannot convert time series data to kline.Candle, insufficient data")
|
var errFailedToConvertToCandle = errors.New("cannot convert time series data to kline.Candle, insufficient data")
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *BTCMarkets) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets basic defaults
|
// SetDefaults sets basic defaults
|
||||||
func (b *BTCMarkets) SetDefaults() {
|
func (b *BTCMarkets) SetDefaults() {
|
||||||
b.Name = "BTC Markets"
|
b.Name = "BTC Markets"
|
||||||
|
|||||||
@@ -33,29 +33,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (b *BTSE) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
b.SetDefaults()
|
|
||||||
exchCfg, err := b.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = b.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for BTSE
|
// SetDefaults sets the basic defaults for BTSE
|
||||||
func (b *BTSE) SetDefaults() {
|
func (b *BTSE) SetDefaults() {
|
||||||
b.Name = "BTSE"
|
b.Name = "BTSE"
|
||||||
|
|||||||
@@ -33,27 +33,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (by *Bybit) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
by.SetDefaults()
|
|
||||||
exchCfg, err := by.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = by.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if by.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err := by.UpdateTradablePairs(ctx, false)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Bybit
|
// SetDefaults sets the basic defaults for Bybit
|
||||||
func (by *Bybit) SetDefaults() {
|
func (by *Bybit) SetDefaults() {
|
||||||
by.Name = "Bybit"
|
by.Name = "Bybit"
|
||||||
|
|||||||
@@ -29,29 +29,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (c *CoinbasePro) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
c.SetDefaults()
|
|
||||||
exchCfg, err := c.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = c.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets default values for the exchange
|
// SetDefaults sets default values for the exchange
|
||||||
func (c *CoinbasePro) SetDefaults() {
|
func (c *CoinbasePro) SetDefaults() {
|
||||||
c.Name = "CoinbasePro"
|
c.Name = "CoinbasePro"
|
||||||
|
|||||||
@@ -31,29 +31,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (c *COINUT) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
c.SetDefaults()
|
|
||||||
exchCfg, err := c.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = c.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets current default values
|
// SetDefaults sets current default values
|
||||||
func (c *COINUT) SetDefaults() {
|
func (c *COINUT) SetDefaults() {
|
||||||
c.Name = "COINUT"
|
c.Name = "COINUT"
|
||||||
|
|||||||
@@ -1943,3 +1943,35 @@ func (b *Base) Bootstrap(_ context.Context) (continueBootstrap bool, err error)
|
|||||||
func (b *Base) IsVerbose() bool {
|
func (b *Base) IsVerbose() bool {
|
||||||
return b.Verbose
|
return b.Verbose
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultConfig returns a default exchange config
|
||||||
|
func GetDefaultConfig(ctx context.Context, exch IBotExchange) (*config.Exchange, error) {
|
||||||
|
if exch == nil {
|
||||||
|
return nil, errExchangeIsNil
|
||||||
|
}
|
||||||
|
|
||||||
|
if exch.GetName() == "" {
|
||||||
|
exch.SetDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
b := exch.GetBase()
|
||||||
|
|
||||||
|
exchCfg, err := b.GetStandardConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = b.SetupDefaults(exchCfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
||||||
|
err = exch.UpdateTradablePairs(ctx, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return exchCfg, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,23 +8,30 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/thrasher-corp/gocryptotrader/common"
|
"github.com/thrasher-corp/gocryptotrader/common"
|
||||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||||
"github.com/thrasher-corp/gocryptotrader/common/key"
|
"github.com/thrasher-corp/gocryptotrader/common/key"
|
||||||
"github.com/thrasher-corp/gocryptotrader/config"
|
"github.com/thrasher-corp/gocryptotrader/config"
|
||||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/collateral"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/collateral"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/exchanges/deposit"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/futures"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/futures"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/margin"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/margin"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/protocol"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/protocol"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/subscription"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/subscription"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/exchanges/trade"
|
||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -3223,25 +3230,6 @@ func TestGetOpenInterest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FakeBase is used to override functions
|
|
||||||
type FakeBase struct {
|
|
||||||
Base
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FakeBase) GetOpenInterest(context.Context, ...key.PairAsset) ([]futures.OpenInterest, error) {
|
|
||||||
return []futures.OpenInterest{
|
|
||||||
{
|
|
||||||
Key: key.ExchangePairAsset{
|
|
||||||
Exchange: f.Name,
|
|
||||||
Base: currency.BTC.Item,
|
|
||||||
Quote: currency.BONK.Item,
|
|
||||||
Asset: asset.Futures,
|
|
||||||
},
|
|
||||||
OpenInterest: 1337,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetCachedOpenInterest(t *testing.T) {
|
func TestGetCachedOpenInterest(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
var b FakeBase
|
var b FakeBase
|
||||||
@@ -3330,3 +3318,182 @@ func TestParallelChanOp(t *testing.T) {
|
|||||||
assert.EventuallyWithT(t, f, 500*time.Millisecond, 50*time.Millisecond, "ParallelChanOp should complete within 500ms not 5*300ms")
|
assert.EventuallyWithT(t, f, 500*time.Millisecond, 50*time.Millisecond, "ParallelChanOp should complete within 500ms not 5*300ms")
|
||||||
assert.Len(t, run, len(c), "Every channel was run to completion")
|
assert.Len(t, run, len(c), "Every channel was run to completion")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetDefaultConfig(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
exch := &FakeBase{}
|
||||||
|
|
||||||
|
_, err := GetDefaultConfig(context.Background(), nil)
|
||||||
|
assert.ErrorIs(t, err, errExchangeIsNil)
|
||||||
|
|
||||||
|
c, err := GetDefaultConfig(context.Background(), exch)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, "test", c.Name)
|
||||||
|
cpy := exch.Requester
|
||||||
|
|
||||||
|
// Test below demonstrates that the requester is not overwritten so that
|
||||||
|
// SetDefaults is not called twice.
|
||||||
|
c, err = GetDefaultConfig(context.Background(), exch)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, "test", c.Name)
|
||||||
|
assert.Equal(t, cpy, exch.Requester)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FakeBase is used to override functions
|
||||||
|
type FakeBase struct{ Base }
|
||||||
|
|
||||||
|
func (f *FakeBase) GetOpenInterest(context.Context, ...key.PairAsset) ([]futures.OpenInterest, error) {
|
||||||
|
return []futures.OpenInterest{
|
||||||
|
{
|
||||||
|
Key: key.ExchangePairAsset{
|
||||||
|
Exchange: f.Name,
|
||||||
|
Base: currency.BTC.Item,
|
||||||
|
Quote: currency.BONK.Item,
|
||||||
|
Asset: asset.Futures,
|
||||||
|
},
|
||||||
|
OpenInterest: 1337,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) SetDefaults() {
|
||||||
|
f.Name = "test"
|
||||||
|
f.Requester, _ = request.New("test", common.NewHTTPClientWithTimeout(time.Second))
|
||||||
|
f.Features.Supports.RESTCapabilities.AutoPairUpdates = true
|
||||||
|
}
|
||||||
|
func (f *FakeBase) UpdateTradablePairs(context.Context, bool) error { return nil }
|
||||||
|
|
||||||
|
func (f *FakeBase) Setup(*config.Exchange) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) CancelAllOrders(context.Context, *order.Cancel) (order.CancelAllResponse, error) {
|
||||||
|
return order.CancelAllResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) CancelBatchOrders(context.Context, []order.Cancel) (*order.CancelBatchResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) CancelOrder(context.Context, *order.Cancel) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) FetchAccountInfo(context.Context, asset.Item) (account.Holdings, error) {
|
||||||
|
return account.Holdings{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) FetchOrderbook(context.Context, currency.Pair, asset.Item) (*orderbook.Base, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) FetchTicker(context.Context, currency.Pair, asset.Item) (*ticker.Price, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) FetchTradablePairs(context.Context, asset.Item) (currency.Pairs, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetAccountFundingHistory(context.Context) ([]FundingHistory, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) ValidateAPICredentials(context.Context, asset.Item) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) UpdateTickers(context.Context, asset.Item) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) UpdateTicker(context.Context, currency.Pair, asset.Item) (*ticker.Price, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) UpdateOrderbook(context.Context, currency.Pair, asset.Item) (*orderbook.Base, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) UpdateAccountInfo(context.Context, asset.Item) (account.Holdings, error) {
|
||||||
|
return account.Holdings{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetRecentTrades(context.Context, currency.Pair, asset.Item) ([]trade.Data, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetHistoricTrades(context.Context, currency.Pair, asset.Item, time.Time, time.Time) ([]trade.Data, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetServerTime(context.Context, asset.Item) (time.Time, error) {
|
||||||
|
return time.Now(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetFeeByType(context.Context, *FeeBuilder) (float64, error) {
|
||||||
|
return 0.0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) SubmitOrder(context.Context, *order.Submit) (*order.SubmitResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) ModifyOrder(context.Context, *order.Modify) (*order.ModifyResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetOrderInfo(context.Context, string, currency.Pair, asset.Item) (*order.Detail, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetDepositAddress(context.Context, currency.Code, string, string) (*deposit.Address, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetOrderHistory(context.Context, *order.MultiOrderRequest) (order.FilteredOrders, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetWithdrawalsHistory(context.Context, currency.Code, asset.Item) ([]WithdrawalHistory, error) {
|
||||||
|
return []WithdrawalHistory{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetActiveOrders(context.Context, *order.MultiOrderRequest) (order.FilteredOrders, error) {
|
||||||
|
return []order.Detail{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) WithdrawCryptocurrencyFunds(context.Context, *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) WithdrawFiatFunds(context.Context, *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) WithdrawFiatFundsToInternationalBank(context.Context, *withdraw.Request) (*withdraw.ExchangeResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetHistoricCandles(context.Context, currency.Pair, asset.Item, kline.Interval, time.Time, time.Time) (*kline.Item, error) {
|
||||||
|
return &kline.Item{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetHistoricCandlesExtended(context.Context, currency.Pair, asset.Item, kline.Interval, time.Time, time.Time) (*kline.Item, error) {
|
||||||
|
return &kline.Item{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) UpdateOrderExecutionLimits(context.Context, asset.Item) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetLatestFundingRates(context.Context, *fundingrate.LatestRateRequest) ([]fundingrate.LatestRateResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FakeBase) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error) {
|
||||||
|
return nil, common.ErrFunctionNotSupported
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,29 +29,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (e *EXMO) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
e.SetDefaults()
|
|
||||||
exchCfg, err := e.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = e.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if e.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = e.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for exmo
|
// SetDefaults sets the basic defaults for exmo
|
||||||
func (e *EXMO) SetDefaults() {
|
func (e *EXMO) SetDefaults() {
|
||||||
e.Name = "EXMO"
|
e.Name = "EXMO"
|
||||||
|
|||||||
@@ -39,28 +39,6 @@ import (
|
|||||||
// this error.
|
// this error.
|
||||||
const unfundedFuturesAccount = `please transfer funds first to create futures account`
|
const unfundedFuturesAccount = `please transfer funds first to create futures account`
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (g *Gateio) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
g.SetDefaults()
|
|
||||||
exchCfg, err := g.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = g.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if g.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = g.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets default values for the exchange
|
// SetDefaults sets default values for the exchange
|
||||||
func (g *Gateio) SetDefaults() {
|
func (g *Gateio) SetDefaults() {
|
||||||
g.Name = "GateIO"
|
g.Name = "GateIO"
|
||||||
|
|||||||
@@ -31,29 +31,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (g *Gemini) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
g.SetDefaults()
|
|
||||||
exchCfg, err := g.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = g.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if g.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err := g.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets package defaults for gemini exchange
|
// SetDefaults sets package defaults for gemini exchange
|
||||||
func (g *Gemini) SetDefaults() {
|
func (g *Gemini) SetDefaults() {
|
||||||
g.Name = "Gemini"
|
g.Name = "Gemini"
|
||||||
|
|||||||
@@ -31,29 +31,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (h *HitBTC) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
h.SetDefaults()
|
|
||||||
exchCfg, err := h.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = h.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if h.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = h.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets default settings for hitbtc
|
// SetDefaults sets default settings for hitbtc
|
||||||
func (h *HitBTC) SetDefaults() {
|
func (h *HitBTC) SetDefaults() {
|
||||||
h.Name = "HitBTC"
|
h.Name = "HitBTC"
|
||||||
|
|||||||
@@ -32,29 +32,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (h *HUOBI) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
h.SetDefaults()
|
|
||||||
exchCfg, err := h.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = h.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if h.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = h.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets default values for the exchange
|
// SetDefaults sets default values for the exchange
|
||||||
func (h *HUOBI) SetDefaults() {
|
func (h *HUOBI) SetDefaults() {
|
||||||
h.Name = "Huobi"
|
h.Name = "Huobi"
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ type IBotExchange interface {
|
|||||||
SetHTTPClientUserAgent(ua string) error
|
SetHTTPClientUserAgent(ua string) error
|
||||||
GetHTTPClientUserAgent() (string, error)
|
GetHTTPClientUserAgent() (string, error)
|
||||||
SetClientProxyAddress(addr string) error
|
SetClientProxyAddress(addr string) error
|
||||||
GetDefaultConfig(ctx context.Context) (*config.Exchange, error)
|
|
||||||
GetBase() *Base
|
GetBase() *Base
|
||||||
GetHistoricCandles(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)
|
GetHistoricCandles(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)
|
||||||
GetHistoricCandlesExtended(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)
|
GetHistoricCandlesExtended(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)
|
||||||
|
|||||||
@@ -34,29 +34,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (k *Kraken) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
k.SetDefaults()
|
|
||||||
exchCfg, err := k.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = k.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if k.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = k.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets current default settings
|
// SetDefaults sets current default settings
|
||||||
func (k *Kraken) SetDefaults() {
|
func (k *Kraken) SetDefaults() {
|
||||||
k.Name = "Kraken"
|
k.Name = "Kraken"
|
||||||
|
|||||||
@@ -35,28 +35,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (ku *Kucoin) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
ku.SetDefaults()
|
|
||||||
exchCfg, err := ku.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ku.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if ku.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err := ku.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Kucoin
|
// SetDefaults sets the basic defaults for Kucoin
|
||||||
func (ku *Kucoin) SetDefaults() {
|
func (ku *Kucoin) SetDefaults() {
|
||||||
ku.Name = "Kucoin"
|
ku.Name = "Kucoin"
|
||||||
|
|||||||
@@ -28,29 +28,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (l *Lbank) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
l.SetDefaults()
|
|
||||||
exchCfg, err := l.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = l.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if l.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = l.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Lbank
|
// SetDefaults sets the basic defaults for Lbank
|
||||||
func (l *Lbank) SetDefaults() {
|
func (l *Lbank) SetDefaults() {
|
||||||
l.Name = "Lbank"
|
l.Name = "Lbank"
|
||||||
|
|||||||
@@ -28,27 +28,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (o *Okcoin) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
o.SetDefaults()
|
|
||||||
exchCfg, err := o.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = o.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if o.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = o.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults method assigns the default values for Okcoin
|
// SetDefaults method assigns the default values for Okcoin
|
||||||
func (o *Okcoin) SetDefaults() {
|
func (o *Okcoin) SetDefaults() {
|
||||||
o.SetErrorDefaults()
|
o.SetErrorDefaults()
|
||||||
|
|||||||
@@ -40,28 +40,6 @@ const (
|
|||||||
okxWebsocketResponseMaxLimit = time.Second * 3
|
okxWebsocketResponseMaxLimit = time.Second * 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (ok *Okx) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
ok.SetDefaults()
|
|
||||||
exchCfg, err := ok.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ok.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if ok.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = ok.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets the basic defaults for Okx
|
// SetDefaults sets the basic defaults for Okx
|
||||||
func (ok *Okx) SetDefaults() {
|
func (ok *Okx) SetDefaults() {
|
||||||
ok.Name = "Okx"
|
ok.Name = "Okx"
|
||||||
|
|||||||
@@ -31,29 +31,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (p *Poloniex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
p.SetDefaults()
|
|
||||||
exchCfg, err := p.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = p.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = p.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets default settings for poloniex
|
// SetDefaults sets default settings for poloniex
|
||||||
func (p *Poloniex) SetDefaults() {
|
func (p *Poloniex) SetDefaults() {
|
||||||
p.Name = "Poloniex"
|
p.Name = "Poloniex"
|
||||||
|
|||||||
@@ -266,11 +266,6 @@ func (c *CustomEx) GetSubscriptions() ([]subscription.Subscription, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultConfig is a mock method for CustomEx
|
|
||||||
func (c *CustomEx) GetDefaultConfig(_ context.Context) (*config.Exchange, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetBase is a mock method for CustomEx
|
// GetBase is a mock method for CustomEx
|
||||||
func (c *CustomEx) GetBase() *exchange.Base {
|
func (c *CustomEx) GetBase() *exchange.Base {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -29,29 +29,6 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDefaultConfig returns a default exchange config
|
|
||||||
func (y *Yobit) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
|
||||||
y.SetDefaults()
|
|
||||||
exchCfg, err := y.GetStandardConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = y.SetupDefaults(exchCfg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if y.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
|
||||||
err = y.UpdateTradablePairs(ctx, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exchCfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDefaults sets current default value for Yobit
|
// SetDefaults sets current default value for Yobit
|
||||||
func (y *Yobit) SetDefaults() {
|
func (y *Yobit) SetDefaults() {
|
||||||
y.Name = "Yobit"
|
y.Name = "Yobit"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/thrasher-corp/gocryptotrader/common"
|
"github.com/thrasher-corp/gocryptotrader/common"
|
||||||
"github.com/thrasher-corp/gocryptotrader/config"
|
"github.com/thrasher-corp/gocryptotrader/config"
|
||||||
"github.com/thrasher-corp/gocryptotrader/engine"
|
"github.com/thrasher-corp/gocryptotrader/engine"
|
||||||
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||||
"github.com/thrasher-corp/gocryptotrader/gctscript/modules"
|
"github.com/thrasher-corp/gocryptotrader/gctscript/modules"
|
||||||
"github.com/thrasher-corp/gocryptotrader/gctscript/modules/gct"
|
"github.com/thrasher-corp/gocryptotrader/gctscript/modules/gct"
|
||||||
@@ -39,8 +40,7 @@ func TestMain(m *testing.M) {
|
|||||||
log.Print(err)
|
log.Print(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
exch.SetDefaults()
|
cfg, err := exchange.GetDefaultConfig(context.Background(), exch)
|
||||||
cfg, err := exch.GetDefaultConfig(context.Background())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user