bybit

package
v0.0.0-...-8641eef Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WebsocketEndpoint = struct {
	Mainnet WebsocketEndpoints
	Testnet WebsocketEndpoints
}{
	Mainnet: WebsocketEndpoints{
		Public:  "wss://stream.bybit.com/realtime_public",
		Private: "wss://stream.bybit.com/realtime_private",
	},
	Testnet: WebsocketEndpoints{
		Public:  "wss://stream-testnet.bybit.com/realtime_public",
		Private: "wss://stream-testnet.bybit.com/realtime_private",
	},
}

Functions

func IsTestnet

func IsTestnet(ctx context.Context) bool

func New

func New(ctx context.Context, opts Options) context.Context

func ParseTime

func ParseTime(unixSec util.Number) (time.Time, error)

func UpdateServerTime

func UpdateServerTime(ctx context.Context, serverTime time.Time)

Types

type Base

type Base interface {
	ServerTime() util.Number
	ReturnCode() int
	ReturnMessage() string
}

type BaseResult

type BaseResult struct {
	RetCode         int         `json:"ret_code"`
	RetMsg          string      `json:"ret_msg"`
	ExtCode         string      `json:"ext_code"`
	Result          interface{} `json:"result"`
	TimeNow         util.Number `json:"time_now"`
	RateLimitStatus int         `json:"rate_limit_status"`
}

func (*BaseResult) ReturnCode

func (b *BaseResult) ReturnCode() int

func (*BaseResult) ReturnMessage

func (b *BaseResult) ReturnMessage() string

func (*BaseResult) ServerTime

func (b *BaseResult) ServerTime() util.Number

type Context

type Context struct {
	Options
	LastTimeSync     time.Time
	ServerTimeOffset time.Duration
}

func FromContext

func FromContext(ctx context.Context) *Context

type Options

type Options struct {
	APIKey, SecretKey string // Required
	Mainnet           bool   // Whether to use mainnet or testnet
	Log               util.Logger
	Client            *http.Client // for rest client
}

type Websocket

type Websocket struct {
	Options
	// contains filtered or unexported fields
}

func NewWebsocket

func NewWebsocket(opts Options, handlerFn func(*WebsocketResponse)) *Websocket

func (*Websocket) Close

func (s *Websocket) Close()

func (*Websocket) Subscribe

func (s *Websocket) Subscribe(public bool, topics ...string) error

Subscribe adds topic to subscription list.

func (*Websocket) Unsubscribe

func (s *Websocket) Unsubscribe(public bool, topics ...string) error

Unsubscribe removes topic from subscription list.

type WebsocketEndpoints

type WebsocketEndpoints struct {
	Public  string
	Private string
}

type WebsocketRequest

type WebsocketRequest struct {
	Op   string        `json:"op"`
	Args []interface{} `json:"args"`
}

type WebsocketResponse

type WebsocketResponse struct {
	Parse gjson.Result
	// contains filtered or unexported fields
}

func (*WebsocketResponse) IsStatusResponse

func (r *WebsocketResponse) IsStatusResponse() bool

func (*WebsocketResponse) IsTopicResponse

func (r *WebsocketResponse) IsTopicResponse() bool

func (*WebsocketResponse) StatusResponse

func (r *WebsocketResponse) StatusResponse() (*WebsocketStatusResponse, error)

func (*WebsocketResponse) TopicResponse

func (r *WebsocketResponse) TopicResponse() (*WebsocketTopicResponse, error)

type WebsocketStatusResponse

type WebsocketStatusResponse struct {
	Success bool             `json:"success"`
	RetMsg  string           `json:"ret_msg"`
	ConnID  string           `json:"conn_id"`
	Request WebsocketRequest `json:"request"`
}

WebsocketStatusResponse occurs on error or subscription confirmation

type WebsocketTopicResponse

type WebsocketTopicResponse struct {
	Topic string          `json:"topic"`
	Type  string          `json:"type"`
	Data  json.RawMessage `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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