bybit

package
v0.0.0-...-ea1cebd Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetOrderHistoryPath = "/v5/order/history"
	BybitBaseURL        = "https://api.bybit.com"
)
View Source
const BYBIT_PREFIX = "BYBIT-"

Variables

This section is empty.

Functions

func NewBybitRestClient

func NewBybitRestClient(apiKey, secretKey string, l *zap.Logger) *bybit.Client

func NewBybitWSClient

func NewBybitWSClient(apiKey, secretKey string, l *zap.Logger) *bybit.WebSocketClient

func NewHTTPClient

func NewHTTPClient(timeout time.Duration) *http.Client

func SubscribeToOrders

func SubscribeToOrders(ctx context.Context, wsClient *bybit.WebSocketClient, lg *zap.Logger, category bybit.CategoryV5) (<-chan exchanges.OrderEvent, error)

func SubscribeToPositions

func SubscribeToPositions(ctx context.Context, wsClient *bybit.WebSocketClient, lg *zap.Logger, category bybit.CategoryV5) (<-chan exchanges.PositionEvent, error)

func SubscribeToPrices

func SubscribeToPrices(ctx context.Context, wsClient *bybit.WebSocketClient, lg *zap.Logger, symbol string) (<-chan exchanges.PriceEvent, error)

func SubscribeToPricesInverse

func SubscribeToPricesInverse(ctx context.Context, wsClient *bybit.WebSocketClient, lg *zap.Logger, symbol string) (<-chan exchanges.PriceEvent, error)

func SubscribeToPricesLinear

func SubscribeToPricesLinear(ctx context.Context, wsClient *bybit.WebSocketClient, lg *zap.Logger, symbol string) (<-chan exchanges.PriceEvent, error)

func ToBybitFullSymbol

func ToBybitFullSymbol(symbol string) string

func ToBybitSymbol

func ToBybitSymbol(symbol string) string

Types

type BybitContract

type BybitContract struct {
	// contains filtered or unexported fields
}

func NewBybitContract

func NewBybitContract(apiKey, secretKey, host string, lg *zap.Logger) *BybitContract

func (*BybitContract) CancelOrder

func (b *BybitContract) CancelOrder(ctx context.Context, symbol, id string) error

func (*BybitContract) GenerateClientOrderID

func (b *BybitContract) GenerateClientOrderID(ctx context.Context, identifierID string) (string, error)

func (*BybitContract) GetAccount

func (b *BybitContract) GetAccount(ctx context.Context) (res exchanges.Account, err error)

func (*BybitContract) GetName

func (b *BybitContract) GetName() string

func (*BybitContract) GetOpenOrders

func (b *BybitContract) GetOpenOrders(ctx context.Context) (res []exchanges.OrderDetailInfo, err error)

func (*BybitContract) GetOrderInfo

func (b *BybitContract) GetOrderInfo(ctx context.Context, symbol, id string, _ *time.Time) (exchanges.OrderInfo, error)

func (*BybitContract) GetOrderInfoByClientOrderID

func (b *BybitContract) GetOrderInfoByClientOrderID(ctx context.Context, symbol, clientOrderID string, _ *time.Time) (exchanges.OrderInfo, error)

func (*BybitContract) GetOrders

func (b *BybitContract) GetOrders(ctx context.Context, filter exchanges.OrderFilter) (res []exchanges.OrderDetailInfo, err error)

func (*BybitContract) GetPrefix

func (b *BybitContract) GetPrefix() string

func (*BybitContract) GetPrice

func (b *BybitContract) GetPrice(ctx context.Context, symbol string) (*apd.Decimal, error)

func (*BybitContract) GetTradableSymbols

func (b *BybitContract) GetTradableSymbols(ctx context.Context) ([]exchanges.SymbolInfo, error)

func (*BybitContract) PlaceBuyOrder

func (b *BybitContract) PlaceBuyOrder(ctx context.Context,
	_ bool, symbol string, price, quantity *apd.Decimal, prefferedID string,
) (id string, e error)

func (*BybitContract) PlaceBuyOrderV2

func (b *BybitContract) PlaceBuyOrderV2(ctx context.Context, _ bool, symbol string, price, qty *apd.Decimal, preferredID string, orderType string) (id string, e error)

PlaceBuyOrderV2 Place Buy Order with OrderType param

func (*BybitContract) PlaceSellOrder

func (b *BybitContract) PlaceSellOrder(ctx context.Context,
	_ bool, symbol string, price, quantity *apd.Decimal, prefferedID string,
) (id string, e error)

func (*BybitContract) PlaceSellOrderV2

func (b *BybitContract) PlaceSellOrderV2(ctx context.Context, _ bool, symbol string, price, qty *apd.Decimal, preferredID string, orderType string) (id string, e error)

PlaceSellOrderV2 Place Sell Order with OrderType param

func (*BybitContract) ReleaseOrder

func (b *BybitContract) ReleaseOrder(_ context.Context, symbol, id string) error

func (*BybitContract) RoundPrice

func (b *BybitContract) RoundPrice(_ context.Context, symbol string, price *apd.Decimal, tickSize *string) (*apd.Decimal, error)

func (*BybitContract) RoundQuantity

func (b *BybitContract) RoundQuantity(_ context.Context, symbol string, qty *apd.Decimal) (*apd.Decimal, error)

func (*BybitContract) WatchAccountPositions

func (b *BybitContract) WatchAccountPositions(ctx context.Context) (<-chan exchanges.PositionEvent, error)

func (*BybitContract) WatchOrdersStatuses

func (b *BybitContract) WatchOrdersStatuses(ctx context.Context) (<-chan exchanges.OrderEvent, error)

WatchOrdersStatuses Returns control immediately

func (*BybitContract) WatchSymbolPrice

func (b *BybitContract) WatchSymbolPrice(ctx context.Context, symbol string) (<-chan exchanges.PriceEvent, error)

WatchSymbolPrice

type BybitInverse

type BybitInverse struct {
	// contains filtered or unexported fields
}

func NewBybitInverse

func NewBybitInverse(apiKey, secretKey, host string, lg *zap.Logger) *BybitInverse

func (*BybitInverse) CancelOrder

func (b *BybitInverse) CancelOrder(ctx context.Context, symbol, id string) error

func (*BybitInverse) GenerateClientOrderID

func (b *BybitInverse) GenerateClientOrderID(ctx context.Context, identifierID string) (string, error)

func (*BybitInverse) GetAccount

func (b *BybitInverse) GetAccount(ctx context.Context) (res exchanges.Account, err error)

func (*BybitInverse) GetName

func (b *BybitInverse) GetName() string

func (*BybitInverse) GetOpenOrders

func (b *BybitInverse) GetOpenOrders(ctx context.Context) (res []exchanges.OrderDetailInfo, err error)

func (*BybitInverse) GetOrderInfo

func (b *BybitInverse) GetOrderInfo(ctx context.Context, symbol, id string, _ *time.Time) (exchanges.OrderInfo, error)

func (*BybitInverse) GetOrderInfoByClientOrderID

func (b *BybitInverse) GetOrderInfoByClientOrderID(ctx context.Context, symbol, clientOrderID string, _ *time.Time) (exchanges.OrderInfo, error)

func (*BybitInverse) GetOrders

func (b *BybitInverse) GetOrders(ctx context.Context, filter exchanges.OrderFilter) (res []exchanges.OrderDetailInfo, err error)

func (*BybitInverse) GetPrefix

func (b *BybitInverse) GetPrefix() string

func (*BybitInverse) GetPrice

func (b *BybitInverse) GetPrice(ctx context.Context, symbol string) (*apd.Decimal, error)

func (*BybitInverse) GetTradableSymbols

func (b *BybitInverse) GetTradableSymbols(ctx context.Context) ([]exchanges.SymbolInfo, error)

func (*BybitInverse) PlaceBuyOrder

func (b *BybitInverse) PlaceBuyOrder(ctx context.Context,
	_ bool, symbol string, price, quantity *apd.Decimal, prefferedID string,
) (id string, e error)

func (*BybitInverse) PlaceBuyOrderV2

func (b *BybitInverse) PlaceBuyOrderV2(ctx context.Context, _ bool, symbol string, price, qty *apd.Decimal, preferredID string, orderType string) (id string, e error)

PlaceBuyOrderV2 Place Buy Order with OrderType param

func (*BybitInverse) PlaceSellOrder

func (b *BybitInverse) PlaceSellOrder(ctx context.Context,
	_ bool, symbol string, price, quantity *apd.Decimal, prefferedID string,
) (id string, e error)

func (*BybitInverse) PlaceSellOrderV2

func (b *BybitInverse) PlaceSellOrderV2(ctx context.Context, _ bool, symbol string, price, qty *apd.Decimal, preferredID string, orderType string) (id string, e error)

PlaceSellOrderV2 Place Sell Order with OrderType param

func (*BybitInverse) ReleaseOrder

func (b *BybitInverse) ReleaseOrder(_ context.Context, symbol, id string) error

func (*BybitInverse) RoundPrice

func (b *BybitInverse) RoundPrice(_ context.Context, symbol string, price *apd.Decimal, tickSize *string) (*apd.Decimal, error)

func (*BybitInverse) RoundQuantity

func (b *BybitInverse) RoundQuantity(_ context.Context, symbol string, qty *apd.Decimal) (*apd.Decimal, error)

func (*BybitInverse) WatchAccountPositions

func (b *BybitInverse) WatchAccountPositions(ctx context.Context) (<-chan exchanges.PositionEvent, error)

func (*BybitInverse) WatchOrdersStatuses

func (b *BybitInverse) WatchOrdersStatuses(ctx context.Context) (<-chan exchanges.OrderEvent, error)

WatchOrdersStatuses Returns control immediately

func (*BybitInverse) WatchSymbolPrice

func (b *BybitInverse) WatchSymbolPrice(ctx context.Context, symbol string) (<-chan exchanges.PriceEvent, error)

WatchSymbolPrice

type BybitLinear

type BybitLinear struct {
	// contains filtered or unexported fields
}

func NewBybitLinear

func NewBybitLinear(apiKey, secretKey, host string, lg *zap.Logger) *BybitLinear

func (*BybitLinear) CancelOrder

func (b *BybitLinear) CancelOrder(ctx context.Context, symbol, id string) error

func (*BybitLinear) GenerateClientOrderID

func (b *BybitLinear) GenerateClientOrderID(ctx context.Context, identifierID string) (string, error)

func (*BybitLinear) GetAccount

func (b *BybitLinear) GetAccount(ctx context.Context) (res exchanges.Account, err error)

func (*BybitLinear) GetName

func (b *BybitLinear) GetName() string

func (*BybitLinear) GetOpenOrders

func (b *BybitLinear) GetOpenOrders(ctx context.Context) (res []exchanges.OrderDetailInfo, err error)

func (*BybitLinear) GetOrderInfo

func (b *BybitLinear) GetOrderInfo(ctx context.Context, symbol, id string, _ *time.Time) (exchanges.OrderInfo, error)

func (*BybitLinear) GetOrderInfoByClientOrderID

func (b *BybitLinear) GetOrderInfoByClientOrderID(ctx context.Context, symbol, clientOrderID string, _ *time.Time) (exchanges.OrderInfo, error)

func (*BybitLinear) GetOrders

func (b *BybitLinear) GetOrders(ctx context.Context, filter exchanges.OrderFilter) (res []exchanges.OrderDetailInfo, err error)

func (*BybitLinear) GetPrefix

func (b *BybitLinear) GetPrefix() string

func (*BybitLinear) GetPrice

func (b *BybitLinear) GetPrice(ctx context.Context, symbol string) (*apd.Decimal, error)

func (*BybitLinear) GetTradableSymbols

func (b *BybitLinear) GetTradableSymbols(ctx context.Context) ([]exchanges.SymbolInfo, error)

func (*BybitLinear) PlaceBuyOrder

func (b *BybitLinear) PlaceBuyOrder(ctx context.Context,
	_ bool, symbol string, price, quantity *apd.Decimal, prefferedID string,
) (id string, e error)

func (*BybitLinear) PlaceBuyOrderV2

func (b *BybitLinear) PlaceBuyOrderV2(ctx context.Context, _ bool, symbol string, price, qty *apd.Decimal, preferredID string, orderType string) (id string, e error)

PlaceBuyOrderV2 Place Buy Order with OrderType param

func (*BybitLinear) PlaceSellOrder

func (b *BybitLinear) PlaceSellOrder(ctx context.Context,
	_ bool, symbol string, price, quantity *apd.Decimal, prefferedID string,
) (id string, e error)

func (*BybitLinear) PlaceSellOrderV2

func (b *BybitLinear) PlaceSellOrderV2(ctx context.Context, _ bool, symbol string, price, qty *apd.Decimal, preferredID string, orderType string) (id string, e error)

PlaceSellOrderV2 Place Sell Order with OrderType param

func (*BybitLinear) ReleaseOrder

func (b *BybitLinear) ReleaseOrder(_ context.Context, symbol, id string) error

func (*BybitLinear) RoundPrice

func (b *BybitLinear) RoundPrice(_ context.Context, symbol string, price *apd.Decimal, tickSize *string) (*apd.Decimal, error)

func (*BybitLinear) RoundQuantity

func (b *BybitLinear) RoundQuantity(_ context.Context, symbol string, qty *apd.Decimal) (*apd.Decimal, error)

func (*BybitLinear) WatchAccountPositions

func (b *BybitLinear) WatchAccountPositions(ctx context.Context) (<-chan exchanges.PositionEvent, error)

func (*BybitLinear) WatchOrdersStatuses

func (b *BybitLinear) WatchOrdersStatuses(ctx context.Context) (<-chan exchanges.OrderEvent, error)

WatchOrdersStatuses Returns control immediately

func (*BybitLinear) WatchSymbolPrice

func (b *BybitLinear) WatchSymbolPrice(ctx context.Context, symbol string) (<-chan exchanges.PriceEvent, error)

WatchSymbolPrice

type BybitResponse

type BybitResponse struct {
	RetCode int            `json:"retCode"`
	RetMsg  string         `json:"retMsg"`
	Result  ResultResponse `json:"result"`
}

type OrderHistoryResponse

type OrderHistoryResponse struct {
	OrderId     string `json:"orderId"`
	OrderLinkId string `json:"orderLinkId"`
	Symbol      string `json:"symbol"`
	Side        string `json:"side"`
	OrderStatus string `json:"orderStatus"`
	CreatedTime string `json:"createdTime"`
	UpdatedTime string `json:"updatedTime"`
}

type ResultResponse

type ResultResponse struct {
	NextPageCursor string                 `json:"nextPageCursor"`
	Category       string                 `json:"category"`
	List           []OrderHistoryResponse `json:"list"`
}

type Server

type Server struct {
	Name        string
	ID          int
	Enabled     bool
	http.Server // embedded
}

type SymbolFilter

type SymbolFilter struct {
	LotSizeFilter struct {
		BasePrecision  string `json:"basePrecision"`
		QuotePrecision string `json:"quotePrecision"`
		MaxOrderQty    string `json:"maxOrderQty"`
		MinOrderQty    string `json:"minOrderQty"`
		MinOrderAmt    string `json:"minOrderAmt"`
		MaxOrderAmt    string `json:"maxOrderAmt"`
	} `json:"lotSizeFilter"`
	PriceFilter struct {
		TickSize string `json:"tickSize"`
	} `json:"priceFilter"`
}

type SymbolInverseFilter

type SymbolInverseFilter struct {
	LotSizeFilter struct {
		MaxOrderQty         string `json:"maxOrderQty"`
		MinOrderQty         string `json:"minOrderQty"`
		QtyStep             string `json:"qtyStep"`
		PostOnlyMaxOrderQty string `json:"postOnlyMaxOrderQty"`
	} `json:"lotSizeFilter"`
	PriceFilter struct {
		MinPrice string `json:"minPrice"`
		MaxPrice string `json:"maxPrice"`
		TickSize string `json:"tickSize"`
	} `json:"priceFilter"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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