mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +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:
@@ -26,16 +26,6 @@ import (
|
||||
"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
|
||||
func (a *Alphapoint) SetDefaults() {
|
||||
a.Name = "Alphapoint"
|
||||
|
||||
@@ -36,29 +36,6 @@ import (
|
||||
"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
|
||||
func (b *Binance) SetDefaults() {
|
||||
b.Name = "Binance"
|
||||
|
||||
@@ -30,28 +30,6 @@ import (
|
||||
"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
|
||||
func (bi *Binanceus) SetDefaults() {
|
||||
bi.Name = "Binanceus"
|
||||
|
||||
@@ -33,29 +33,6 @@ import (
|
||||
"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
|
||||
func (b *Bitfinex) SetDefaults() {
|
||||
b.Name = "Bitfinex"
|
||||
|
||||
@@ -28,29 +28,6 @@ import (
|
||||
"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
|
||||
func (b *Bitflyer) SetDefaults() {
|
||||
b.Name = "Bitflyer"
|
||||
|
||||
@@ -36,29 +36,6 @@ const wsRateLimitMillisecond = 1000
|
||||
|
||||
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
|
||||
func (b *Bithumb) SetDefaults() {
|
||||
b.Name = "Bithumb"
|
||||
|
||||
@@ -34,29 +34,6 @@ import (
|
||||
"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
|
||||
func (b *Bitmex) SetDefaults() {
|
||||
b.Name = "Bitmex"
|
||||
|
||||
@@ -30,29 +30,6 @@ import (
|
||||
"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
|
||||
func (b *Bitstamp) SetDefaults() {
|
||||
b.Name = "Bitstamp"
|
||||
|
||||
@@ -34,29 +34,6 @@ import (
|
||||
|
||||
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
|
||||
func (b *BTCMarkets) SetDefaults() {
|
||||
b.Name = "BTC Markets"
|
||||
|
||||
@@ -33,29 +33,6 @@ import (
|
||||
"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
|
||||
func (b *BTSE) SetDefaults() {
|
||||
b.Name = "BTSE"
|
||||
|
||||
@@ -33,27 +33,6 @@ import (
|
||||
"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
|
||||
func (by *Bybit) SetDefaults() {
|
||||
by.Name = "Bybit"
|
||||
|
||||
@@ -29,29 +29,6 @@ import (
|
||||
"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
|
||||
func (c *CoinbasePro) SetDefaults() {
|
||||
c.Name = "CoinbasePro"
|
||||
|
||||
@@ -31,29 +31,6 @@ import (
|
||||
"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
|
||||
func (c *COINUT) SetDefaults() {
|
||||
c.Name = "COINUT"
|
||||
|
||||
@@ -1943,3 +1943,35 @@ func (b *Base) Bootstrap(_ context.Context) (continueBootstrap bool, err error)
|
||||
func (b *Base) IsVerbose() bool {
|
||||
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"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/key"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"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/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/kline"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/margin"
|
||||
"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/request"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/subscription"
|
||||
"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/withdraw"
|
||||
)
|
||||
|
||||
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) {
|
||||
t.Parallel()
|
||||
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.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"
|
||||
)
|
||||
|
||||
// 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
|
||||
func (e *EXMO) SetDefaults() {
|
||||
e.Name = "EXMO"
|
||||
|
||||
@@ -39,28 +39,6 @@ import (
|
||||
// this error.
|
||||
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
|
||||
func (g *Gateio) SetDefaults() {
|
||||
g.Name = "GateIO"
|
||||
|
||||
@@ -31,29 +31,6 @@ import (
|
||||
"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
|
||||
func (g *Gemini) SetDefaults() {
|
||||
g.Name = "Gemini"
|
||||
|
||||
@@ -31,29 +31,6 @@ import (
|
||||
"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
|
||||
func (h *HitBTC) SetDefaults() {
|
||||
h.Name = "HitBTC"
|
||||
|
||||
@@ -32,29 +32,6 @@ import (
|
||||
"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
|
||||
func (h *HUOBI) SetDefaults() {
|
||||
h.Name = "Huobi"
|
||||
|
||||
@@ -63,7 +63,6 @@ type IBotExchange interface {
|
||||
SetHTTPClientUserAgent(ua string) error
|
||||
GetHTTPClientUserAgent() (string, error)
|
||||
SetClientProxyAddress(addr string) error
|
||||
GetDefaultConfig(ctx context.Context) (*config.Exchange, error)
|
||||
GetBase() *Base
|
||||
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)
|
||||
|
||||
@@ -34,29 +34,6 @@ import (
|
||||
"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
|
||||
func (k *Kraken) SetDefaults() {
|
||||
k.Name = "Kraken"
|
||||
|
||||
@@ -35,28 +35,6 @@ import (
|
||||
"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
|
||||
func (ku *Kucoin) SetDefaults() {
|
||||
ku.Name = "Kucoin"
|
||||
|
||||
@@ -28,29 +28,6 @@ import (
|
||||
"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
|
||||
func (l *Lbank) SetDefaults() {
|
||||
l.Name = "Lbank"
|
||||
|
||||
@@ -28,27 +28,6 @@ import (
|
||||
"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
|
||||
func (o *Okcoin) SetDefaults() {
|
||||
o.SetErrorDefaults()
|
||||
|
||||
@@ -40,28 +40,6 @@ const (
|
||||
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
|
||||
func (ok *Okx) SetDefaults() {
|
||||
ok.Name = "Okx"
|
||||
|
||||
@@ -31,29 +31,6 @@ import (
|
||||
"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
|
||||
func (p *Poloniex) SetDefaults() {
|
||||
p.Name = "Poloniex"
|
||||
|
||||
@@ -266,11 +266,6 @@ func (c *CustomEx) GetSubscriptions() ([]subscription.Subscription, error) {
|
||||
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
|
||||
func (c *CustomEx) GetBase() *exchange.Base {
|
||||
return nil
|
||||
|
||||
@@ -29,29 +29,6 @@ import (
|
||||
"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
|
||||
func (y *Yobit) SetDefaults() {
|
||||
y.Name = "Yobit"
|
||||
|
||||
Reference in New Issue
Block a user