Documentation ¶
Index ¶
- Variables
- func CandleFromKline(pair string, k binance.Kline) model.Candle
- func CandleFromWsKline(pair string, k binance.WsKline) model.Candle
- func FutureCandleFromKline(pair string, k futures.Kline) model.Candle
- func FutureCandleFromWsKline(pair string, k futures.WsKline) model.Candle
- func SplitAssetQuote(pair string) (asset string, quote string)
- type AssetQuote
- type AssetValue
- type Binance
- func (b *Binance) Account() (model.Account, error)
- func (b *Binance) AccountSubscription(ctx context.Context) (chan model.Order, chan error)
- func (b *Binance) AssetsInfo(pair string) model.AssetInfo
- func (b *Binance) Cancel(order model.Order) error
- func (b *Binance) CancelOpenOrders(pair string) error
- func (b *Binance) CandlesByLimit(ctx context.Context, pair, period string, limit int) ([]model.Candle, error)
- func (b *Binance) CandlesByPeriod(ctx context.Context, pair, period string, start, end time.Time) ([]model.Candle, error)
- func (b *Binance) CandlesSubscription(ctx context.Context, pair, period string) (chan model.Candle, chan error)
- func (b *Binance) CreateOrderLimit(side model.SideType, pair string, quantity float64, limit float64) (model.Order, error)
- func (b *Binance) CreateOrderMarket(side model.SideType, pair string, quantity float64, reduceOnly bool) (model.Order, error)
- func (b *Binance) CreateOrderMarketQuote(side model.SideType, pair string, quantity float64) (model.Order, error)
- func (b *Binance) CreateOrderOCO(side model.SideType, pair string, quantity, price, stop, stopLimit float64) ([]model.Order, error)
- func (b *Binance) CreateOrderStop(pair string, quantity float64, limit float64) (model.Order, error)
- func (b *Binance) CreateOrderTrailingStop(pair string, side model.SideType, limit float64, quantity float64, ...) (model.Order, error)
- func (b *Binance) LastQuote(ctx context.Context, pair string) (float64, error)
- func (b *Binance) OpenOrders(pair string) ([]model.Order, error)
- func (b *Binance) Order(pair string, id int64) (model.Order, error)
- func (b *Binance) Orders(pair string, limit int) ([]model.Order, error)
- func (b *Binance) Position(pair string) (asset, quote float64, err error)
- func (b *Binance) TakeProfit(side model.SideType, pair string, quantity float64, limit float64) (model.Order, error)
- type BinanceFuture
- func (b *BinanceFuture) Account() (model.Account, error)
- func (b *BinanceFuture) AccountSubscription(ctx context.Context) (chan model.Order, chan error)
- func (b *BinanceFuture) AssetsInfo(pair string) model.AssetInfo
- func (b *BinanceFuture) Cancel(order model.Order) error
- func (b *BinanceFuture) CancelOpenOrders(pair string) error
- func (b *BinanceFuture) CandlesByLimit(ctx context.Context, pair, period string, limit int) ([]model.Candle, error)
- func (b *BinanceFuture) CandlesByPeriod(ctx context.Context, pair, period string, start, end time.Time) ([]model.Candle, error)
- func (b *BinanceFuture) CandlesSubscription(ctx context.Context, pair, period string) (chan model.Candle, chan error)
- func (b *BinanceFuture) Client() *futures.Client
- func (b *BinanceFuture) CreateOrderLimit(side model.SideType, pair string, quantity float64, limit float64) (model.Order, error)
- func (b *BinanceFuture) CreateOrderMarket(side model.SideType, pair string, quantity float64, reduceOnly bool) (model.Order, error)
- func (b *BinanceFuture) CreateOrderMarketQuote(_ model.SideType, _ string, _ float64) (model.Order, error)
- func (b *BinanceFuture) CreateOrderOCO(_ model.SideType, _ string, _, _, _, _ float64) ([]model.Order, error)
- func (b *BinanceFuture) CreateOrderStop(pair string, quantity float64, limit float64) (model.Order, error)
- func (b *BinanceFuture) CreateOrderTrailingStop(pair string, side model.SideType, limit float64, quantity float64, ...) (model.Order, error)
- func (b *BinanceFuture) LastQuote(ctx context.Context, pair string) (float64, error)
- func (b *BinanceFuture) OpenOrders(pair string) ([]model.Order, error)
- func (b *BinanceFuture) Order(pair string, id int64) (model.Order, error)
- func (b *BinanceFuture) Orders(pair string, limit int) ([]model.Order, error)
- func (b *BinanceFuture) Position(pair string) (asset, quote float64, err error)
- func (b *BinanceFuture) TakeProfit(side model.SideType, pair string, quantity float64, limit float64) (model.Order, error)
- type BinanceFutureOption
- type BinanceOption
- func WithBinanceCredentials(key, secret string) BinanceOption
- func WithBinanceHeikinAshiCandle() BinanceOption
- func WithCustomMainAPIEndpoint(apiURL, wsURL, combinedURL string) BinanceOption
- func WithCustomTestnetAPIEndpoint(apiURL, wsURL, combinedURL string) BinanceOption
- func WithMetadataFetcher(fetcher MetadataFetchers) BinanceOption
- func WithTestNet() BinanceOption
- type CSVFeed
- func (c CSVFeed) AccountSubscription(ctx context.Context) (chan model.Order, chan error)
- func (c CSVFeed) AssetsInfo(pair string) model.AssetInfo
- func (c *CSVFeed) CandlesByLimit(_ context.Context, pair, timeframe string, limit int) ([]model.Candle, error)
- func (c CSVFeed) CandlesByPeriod(_ context.Context, pair, timeframe string, start, end time.Time) ([]model.Candle, error)
- func (c CSVFeed) CandlesSubscription(_ context.Context, pair, timeframe string) (chan model.Candle, chan error)
- func (c CSVFeed) LastQuote(_ context.Context, _ string) (float64, error)
- func (c *CSVFeed) Limit(duration time.Duration) *CSVFeed
- type DataFeed
- type DataFeedConsumer
- type DataFeedSubscription
- type MarginType
- type MetadataFetchers
- type OrderError
- type PairFeed
- type PairOption
- type PaperWallet
- func (p *PaperWallet) Account() (model.Account, error)
- func (p *PaperWallet) AccountSubscription(ctx context.Context) (chan model.Order, chan error)
- func (p *PaperWallet) AssetValues(pair string) []AssetValue
- func (p *PaperWallet) AssetsInfo(pair string) model.AssetInfo
- func (p *PaperWallet) Cancel(order model.Order) error
- func (p *PaperWallet) CancelOpenOrders(pair string) error
- func (p *PaperWallet) CandlesByLimit(ctx context.Context, pair, period string, limit int) ([]model.Candle, error)
- func (p *PaperWallet) CandlesByPeriod(ctx context.Context, pair, period string, start, end time.Time) ([]model.Candle, error)
- func (p *PaperWallet) CandlesSubscription(ctx context.Context, pair, timeframe string) (chan model.Candle, chan error)
- func (p *PaperWallet) CreateOrderLimit(side model.SideType, pair string, size float64, limit float64) (model.Order, error)
- func (p *PaperWallet) CreateOrderMarket(side model.SideType, pair string, size float64, reduceOnly bool) (model.Order, error)
- func (p *PaperWallet) CreateOrderMarketQuote(side model.SideType, pair string, quoteQuantity float64) (model.Order, error)
- func (p *PaperWallet) CreateOrderOCO(side model.SideType, pair string, size, price, stop, stopLimit float64) ([]model.Order, error)
- func (p *PaperWallet) CreateOrderStop(pair string, size float64, limit float64) (model.Order, error)
- func (p *PaperWallet) CreateOrderTrailingStop(pair string, side model.SideType, limit float64, quantity float64, ...) (model.Order, error)
- func (p *PaperWallet) EquityValues() []AssetValue
- func (p *PaperWallet) ID() int64
- func (p *PaperWallet) LastQuote(ctx context.Context, pair string) (float64, error)
- func (p *PaperWallet) MaxDrawdown() (float64, time.Time, time.Time)
- func (p *PaperWallet) OnCandle(candle model.Candle)
- func (p *PaperWallet) OpenOrders(pair string) ([]model.Order, error)
- func (p *PaperWallet) Order(_ string, id int64) (model.Order, error)
- func (p *PaperWallet) Pairs() []string
- func (p *PaperWallet) Position(pair string) (asset, quote float64, err error)
- func (p *PaperWallet) Summary()
- func (p *PaperWallet) TakeProfit(side model.SideType, pair string, quantity float64, limit float64) (model.Order, error)
- type PaperWalletOption
- type Subscription
Constants ¶
This section is empty.
Variables ¶
var ( MarginTypeIsolated MarginType = "ISOLATED" MarginTypeCrossed MarginType = "CROSSED" ErrNoNeedChangeMarginType int64 = -4046 )
var ( ErrInvalidQuantity = errors.New("invalid quantity") ErrInsufficientFunds = errors.New("insufficient funds or locked") ErrInvalidAsset = errors.New("invalid asset") )
var ErrInsufficientData = errors.New("insufficient data")
Functions ¶
func CandleFromKline ¶
func CandleFromWsKline ¶
func FutureCandleFromWsKline ¶
func SplitAssetQuote ¶
Types ¶
type AssetQuote ¶
type AssetValue ¶
type Binance ¶
type Binance struct { HeikinAshi bool Testnet bool APIKey string APISecret string MetadataFetchers []MetadataFetchers // contains filtered or unexported fields }
func NewBinance ¶
func NewBinance(ctx context.Context, options ...BinanceOption) (*Binance, error)
NewBinance create a new Binance exchange instance
func (*Binance) AccountSubscription ¶ added in v0.3.9
func (*Binance) CancelOpenOrders ¶ added in v0.1.9
func (*Binance) CandlesByLimit ¶
func (*Binance) CandlesByPeriod ¶
func (*Binance) CandlesSubscription ¶
func (*Binance) CreateOrderLimit ¶
func (*Binance) CreateOrderMarket ¶
func (*Binance) CreateOrderMarketQuote ¶
func (*Binance) CreateOrderOCO ¶
func (*Binance) CreateOrderStop ¶
func (*Binance) CreateOrderTrailingStop ¶ added in v0.3.6
func (*Binance) OpenOrders ¶ added in v0.2.3
type BinanceFuture ¶
type BinanceFuture struct { HeikinAshi bool Testnet bool APIKey string APISecret string MetadataFetchers []MetadataFetchers PairOptions []PairOption // contains filtered or unexported fields }
func NewBinanceFuture ¶
func NewBinanceFuture(ctx context.Context, options ...BinanceFutureOption) (*BinanceFuture, error)
NewBinanceFuture will create a new BinanceFuture instance
func (*BinanceFuture) AccountSubscription ¶ added in v0.3.9
func (*BinanceFuture) AssetsInfo ¶
func (b *BinanceFuture) AssetsInfo(pair string) model.AssetInfo
func (*BinanceFuture) CancelOpenOrders ¶ added in v0.1.9
func (b *BinanceFuture) CancelOpenOrders(pair string) error
func (*BinanceFuture) CandlesByLimit ¶
func (*BinanceFuture) CandlesByPeriod ¶
func (*BinanceFuture) CandlesSubscription ¶
func (*BinanceFuture) Client ¶ added in v0.2.4
func (b *BinanceFuture) Client() *futures.Client
func (*BinanceFuture) CreateOrderLimit ¶
func (*BinanceFuture) CreateOrderMarket ¶
func (*BinanceFuture) CreateOrderMarketQuote ¶
func (*BinanceFuture) CreateOrderOCO ¶
func (*BinanceFuture) CreateOrderStop ¶
func (*BinanceFuture) CreateOrderTrailingStop ¶ added in v0.3.6
func (*BinanceFuture) OpenOrders ¶ added in v0.2.3
func (b *BinanceFuture) OpenOrders(pair string) ([]model.Order, error)
type BinanceFutureOption ¶
type BinanceFutureOption func(*BinanceFuture)
func WithBinanceFutureCredentials ¶
func WithBinanceFutureCredentials(key, secret string) BinanceFutureOption
WithBinanceFutureCredentials will set the credentials for Binance Futures
func WithBinanceFutureLeverage ¶
func WithBinanceFutureLeverage(pair string, leverage int, marginType MarginType) BinanceFutureOption
WithBinanceFutureLeverage will set the leverage for a pair
func WithBinanceFuturesHeikinAshiCandle ¶
func WithBinanceFuturesHeikinAshiCandle() BinanceFutureOption
WithBinanceFuturesHeikinAshiCandle will use Heikin Ashi candle instead of regular candle
type BinanceOption ¶
type BinanceOption func(*Binance)
func WithBinanceCredentials ¶
func WithBinanceCredentials(key, secret string) BinanceOption
WithBinanceCredentials will set Binance credentials
func WithBinanceHeikinAshiCandle ¶
func WithBinanceHeikinAshiCandle() BinanceOption
WithBinanceHeikinAshiCandle will convert candle to Heikin Ashi
func WithCustomMainAPIEndpoint ¶ added in v0.3.8
func WithCustomMainAPIEndpoint(apiURL, wsURL, combinedURL string) BinanceOption
WithCustomMainAPIEndpoint will set custom endpoints for the Binance Main API
func WithCustomTestnetAPIEndpoint ¶ added in v0.3.8
func WithCustomTestnetAPIEndpoint(apiURL, wsURL, combinedURL string) BinanceOption
WithCustomTestnetAPIEndpoint will set custom endpoints for the Binance Testnet API
func WithMetadataFetcher ¶
func WithMetadataFetcher(fetcher MetadataFetchers) BinanceOption
WithMetadataFetcher will execute a function after receive a new candle and include additional information to candle's metadata
type CSVFeed ¶
func NewCSVFeed ¶
NewCSVFeed creates a new data feed from CSV files and resample
func (CSVFeed) AccountSubscription ¶ added in v0.3.9
func (*CSVFeed) CandlesByLimit ¶
func (CSVFeed) CandlesByPeriod ¶
func (CSVFeed) CandlesSubscription ¶
type DataFeedConsumer ¶
type DataFeedSubscription ¶
type DataFeedSubscription struct { Feeds *set.LinkedHashSetString DataFeeds map[string]*DataFeed SubscriptionsByDataFeed map[string][]Subscription // contains filtered or unexported fields }
func NewDataFeed ¶
func NewDataFeed(exchange service.Exchange) *DataFeedSubscription
func (*DataFeedSubscription) Connect ¶
func (d *DataFeedSubscription) Connect()
func (*DataFeedSubscription) Preload ¶
func (d *DataFeedSubscription) Preload(pair, timeframe string, candles []model.Candle)
func (*DataFeedSubscription) Start ¶
func (d *DataFeedSubscription) Start(loadSync bool)
func (*DataFeedSubscription) Subscribe ¶
func (d *DataFeedSubscription) Subscribe(pair, timeframe string, consumer DataFeedConsumer, onCandleClose bool)
type MarginType ¶
type MarginType = futures.MarginType
type OrderError ¶
func (*OrderError) Error ¶
func (o *OrderError) Error() string
type PairOption ¶
type PairOption struct { Pair string Leverage int MarginType futures.MarginType }
type PaperWallet ¶
func NewPaperWallet ¶
func NewPaperWallet(ctx context.Context, baseCoin string, options ...PaperWalletOption) *PaperWallet
func (*PaperWallet) AccountSubscription ¶ added in v0.3.9
func (*PaperWallet) AssetValues ¶
func (p *PaperWallet) AssetValues(pair string) []AssetValue
func (*PaperWallet) AssetsInfo ¶
func (p *PaperWallet) AssetsInfo(pair string) model.AssetInfo
func (*PaperWallet) CancelOpenOrders ¶ added in v0.1.9
func (p *PaperWallet) CancelOpenOrders(pair string) error
func (*PaperWallet) CandlesByLimit ¶
func (*PaperWallet) CandlesByPeriod ¶
func (*PaperWallet) CandlesSubscription ¶
func (*PaperWallet) CreateOrderLimit ¶
func (*PaperWallet) CreateOrderMarket ¶
func (*PaperWallet) CreateOrderMarketQuote ¶
func (*PaperWallet) CreateOrderOCO ¶
func (*PaperWallet) CreateOrderStop ¶
func (*PaperWallet) CreateOrderTrailingStop ¶ added in v0.3.6
func (*PaperWallet) EquityValues ¶
func (p *PaperWallet) EquityValues() []AssetValue
func (*PaperWallet) ID ¶
func (p *PaperWallet) ID() int64
func (*PaperWallet) MaxDrawdown ¶
func (*PaperWallet) OnCandle ¶
func (p *PaperWallet) OnCandle(candle model.Candle)
func (*PaperWallet) OpenOrders ¶ added in v0.2.3
func (p *PaperWallet) OpenOrders(pair string) ([]model.Order, error)
func (*PaperWallet) Pairs ¶
func (p *PaperWallet) Pairs() []string
func (*PaperWallet) Position ¶
func (p *PaperWallet) Position(pair string) (asset, quote float64, err error)
func (*PaperWallet) Summary ¶
func (p *PaperWallet) Summary()
type PaperWalletOption ¶
type PaperWalletOption func(*PaperWallet)
func WithDataFeed ¶
func WithDataFeed(feeder service.Feeder) PaperWalletOption
func WithPaperAsset ¶
func WithPaperAsset(pair string, amount float64) PaperWalletOption
func WithPaperFee ¶
func WithPaperFee(maker, taker float64) PaperWalletOption
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}