exchange

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCanRetry = errors.New("error but can retry")
)

Functions

func RegisterExchange

func RegisterExchange(name string, fn NewExchangeFn)

Types

type Exchange

type Exchange interface {
	Start() error
	Stop() error

	// KlineChan get klines
	KlineChan(start, end time.Time, symbol, bSize string) (data chan *Candle, err chan error)

	// watch kline changes
	WatchKline(symbols SymbolInfo) (datas chan *CandleInfo, stopC chan struct{}, err error)
	Watch(WatchParam) error

	// for trade
	// ProcessOrder process order
	ProcessOrder(act TradeAction) (ret *Order, err error)
	CancelAllOrders() (orders []*Order, err error)

	// GetBalanceChan
	GetDataChan() *ExchangeChan
}

func NewExchange

func NewExchange(name string, cfg *viper.Viper, cltName, symbol string) (ex Exchange, err error)

type ExchangeChan

type ExchangeChan struct {
	BalanceChan chan Balance
	PosChan     chan Position
	OrderChan   chan Order
	DepthChan   chan Depth
	TradeChan   chan Trade
}

func NewExchangeChan

func NewExchangeChan() *ExchangeChan

func (*ExchangeChan) Close

func (ec *ExchangeChan) Close()

type NewExchangeFn

type NewExchangeFn func(cfg *viper.Viper, cltName, symbol string) (t Exchange, err error)

type OrderInfo

type OrderInfo struct {
	Order
	Action TradeType
	Filled bool
}

type TradeExchange

type TradeExchange struct {
	BaseProcesser
	// contains filtered or unexported fields
}

func GetTradeExchange

func GetTradeExchange(name string, cfg *viper.Viper, cltName, symbol string) (t *TradeExchange, err error)

func NewTradeExchange

func NewTradeExchange(impl Exchange) *TradeExchange

func (*TradeExchange) Init

func (b *TradeExchange) Init(bus *Bus) (err error)

func (*TradeExchange) Start

func (b *TradeExchange) Start() (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL