split exchange interface into ExchangeMarketDataService, ExchangeTradingService

This commit is contained in:
c9s 2021-03-15 10:06:02 +08:00
parent c788601856
commit b7da47411e

View File

@ -61,20 +61,17 @@ type Exchange interface {
PlatformFeeCurrency() string PlatformFeeCurrency() string
NewStream() Stream // required implementation
ExchangeMarketDataService
QueryMarkets(ctx context.Context) (MarketMap, error) ExchangeTradingService
}
type ExchangeTradingService interface {
QueryAccount(ctx context.Context) (*Account, error) QueryAccount(ctx context.Context) (*Account, error)
QueryAccountBalances(ctx context.Context) (BalanceMap, 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) QueryTrades(ctx context.Context, symbol string, options *TradeQueryOptions) ([]Trade, error)
SubmitOrders(ctx context.Context, orders ...SubmitOrder) (createdOrders OrderSlice, err 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 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 { type ExchangeTransferService interface {
QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []Deposit, err error) 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) QueryWithdrawHistory(ctx context.Context, asset string, since, until time.Time) (allWithdraws []Withdraw, err error)