Skip to content

Commit

Permalink
Refactor ExchangeFactory to Interface for Flexible Exchange Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
romanornr committed Dec 26, 2023
1 parent c131c69 commit ddefe0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dealer/dealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (bot *Dealer) getExchange(x interface{}) exchange.IBotExchange {
// +----------------------+

// GetActiveOrders function is a wrapper around the GetActiveOrders function in the exchange package.
func (bot *Dealer) GetActiveOrders(ctx context.Context, exchangeOrName interface{}, request order.GetOrdersRequest) ([]order.Detail, error) {
func (bot *Dealer) GetActiveOrders(ctx context.Context, exchangeOrName interface{}, request order.MultiOrderRequest) ([]order.Detail, error) {
e := bot.getExchange(exchangeOrName)

timer := time.Now()
Expand Down
15 changes: 4 additions & 11 deletions dealer/exchange_factory.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package dealer

import (
"errors"

exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
)

var ErrCreatorNotRegistered = errors.New("exchange creator not registered")

type (
ExchangeFactory func(name string) (exchange.IBotExchange, error)
)

// NewExchangeByName implements gocryptotrader/engine.CustomExchangeBuilder.
func (e ExchangeFactory) NewExchangeByName(name string) (exchange.IBotExchange, error) {
return e(name)
// ExchangeFactory defines an interface for creating exchange instances.
// It abstracts the instantiation process, allowing for flexible and dynamic creation of different exchanges based on a given name.
type ExchangeFactory interface {
NewExchangeByName(name string) (exchange.IBotExchange, error)
}

0 comments on commit ddefe0e

Please sign in to comment.