From b7da47411e6406f5103bd8fb9192ea3b7cbad2ee Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 15 Mar 2021 10:06:02 +0800 Subject: [PATCH] split exchange interface into ExchangeMarketDataService, ExchangeTradingService --- pkg/types/exchange.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/types/exchange.go b/pkg/types/exchange.go index 018f66484..4e3121765 100644 --- a/pkg/types/exchange.go +++ b/pkg/types/exchange.go @@ -61,20 +61,17 @@ type Exchange interface { PlatformFeeCurrency() string - NewStream() Stream + // required implementation + ExchangeMarketDataService - QueryMarkets(ctx context.Context) (MarketMap, error) + ExchangeTradingService +} +type ExchangeTradingService interface { QueryAccount(ctx context.Context) (*Account, error) QueryAccountBalances(ctx context.Context) (BalanceMap, error) - QueryTicker(ctx context.Context, symbol string) (*Ticker, error) - - QueryTickers(ctx context.Context, symbol ...string) (map[string]Ticker, error) - - QueryKLines(ctx context.Context, symbol string, interval Interval, options KLineQueryOptions) ([]KLine, error) - QueryTrades(ctx context.Context, symbol string, options *TradeQueryOptions) ([]Trade, error) SubmitOrders(ctx context.Context, orders ...SubmitOrder) (createdOrders OrderSlice, err error) @@ -86,6 +83,18 @@ type Exchange interface { CancelOrders(ctx context.Context, orders ...Order) error } +type ExchangeMarketDataService interface { + NewStream() Stream + + QueryMarkets(ctx context.Context) (MarketMap, error) + + QueryTicker(ctx context.Context, symbol string) (*Ticker, error) + + QueryTickers(ctx context.Context, symbol ...string) (map[string]Ticker, error) + + QueryKLines(ctx context.Context, symbol string, interval Interval, options KLineQueryOptions) ([]KLine, error) +} + type ExchangeTransferService interface { QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []Deposit, err error) QueryWithdrawHistory(ctx context.Context, asset string, since, until time.Time) (allWithdraws []Withdraw, err error)