huobi

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Huobi = "huobi"

	StatusOK = "ok"
	CodeOK   = 200
)
View Source
const (
	MethodPing        = "ping"
	MethodPong        = "pong"
	MethodSubscibe    = "sub"
	MethodUnSubscribe = "unsub"
)

Variables

View Source
var (
	//SkipError means the response can not be handled directly by Parse method
	SkipError = errors.New("skip error")
)

Functions

func NewError

func NewError(msg string) error

func ParseTS added in v0.5.0

func ParseTS(ts int64) time.Time

ParseTS parse huobi timestmp microsecond

func ParseTSStr added in v0.5.4

func ParseTSStr(str string) (ret time.Time, err error)

func Signature added in v0.5.0

func Signature(secret, method, host, path, query string) string

Types

type CallParam added in v0.5.0

type CallParam struct {
	Pong  int    `json:"pong,omitempty"`
	Sub   string `json:"sub,omitempty"`
	UnSub string `json:"unsub,omitempty"`
	ID    string `json:"id,omitempty"`
}

CallParam carry params which used by huobi websocket sub and pong

type CodeC

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

func NewCodeC

func NewCodeC() *CodeC

func (*CodeC) Decompress

func (cc *CodeC) Decompress(raw []byte) ([]byte, error)

func (CodeC) Encode

func (CodeC) Encode(req rpc.Request) ([]byte, error)

type Error

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

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target interface{}) bool

type NotifyTrade

type NotifyTrade struct {
	Trades []Trade
	Chan   string
}

type Response

type Response struct {
	Ping    int             `json:"ping,omitempty"`
	Ch      string          `json:"ch,omitempty"`
	TS      int64           `json:"ts,omitempty"`
	Tick    json.RawMessage `json:"tick,omitempty"`
	ID      string          `json:"id,omitempty"`
	Status  string          `json:"status,omitempty"`
	Subbed  string          `json:"subbed,omitempty"`
	ErrCode string          `json:"err-code,omitempty"`
	ErrMsg  string          `json:"err-msg,omitempty"`
}

func (*Response) Parse

func (r *Response) Parse(raw []byte) (rpc.Response, error)

type RestClient

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

func NewRestClient

func NewRestClient(key, secret, host string) *RestClient

func (*RestClient) Property added in v0.3.0

func (rc *RestClient) Property() exchange.Property

func (*RestClient) Request

func (rc *RestClient) Request(ctx context.Context, method string, endPoint string, param url.Values, body io.Reader, sign bool, dst interface{}) error

func (*RestClient) RequestWithRawResp added in v0.5.0

func (rc *RestClient) RequestWithRawResp(ctx context.Context, method string, endPoint string, param url.Values, body io.Reader, sign bool, dst interface{}) error

type RestResponse added in v0.3.0

type RestResponse struct {
	Status string      `json:"status"`
	Code   int         `json:"code"`
	Data   interface{} `json:"data"`
}

type Tick

type Tick struct {
	ID   int64   `json:"id"`
	TS   int64   `json:"ts"`
	Data []Trade `json:"data"`
}

type Trade

type Trade struct {
	Amount    float64 `json:"amount"`
	TS        int64   `json:"ts"`
	ID        int64   `json:"id"`
	TradeID   int64   `json:"tradeId"`
	Price     float64 `json:"price"`
	Direction string  `json:"direction"`
}

func ParseTrades

func ParseTrades(raw json.RawMessage) ([]Trade, error)

type WSClient added in v0.5.0

type WSClient struct {
	*exchange.WSClient
	// contains filtered or unexported fields
}

WSClient with auto response ping support

func NewWSClient added in v0.5.0

func NewWSClient(addr string, codec rpc.Codec, data chan interface{}) *WSClient

func (*WSClient) Handle added in v0.5.0

func (ws *WSClient) Handle(ctx context.Context, notify *rpc.Notify)

func (*WSClient) Subscribe added in v0.5.8

func (ws *WSClient) Subscribe(ctx context.Context, channels ...exchange.Channel) error

func (*WSClient) UnSubscribe added in v0.5.8

func (ws *WSClient) UnSubscribe(ctx context.Context, channels ...exchange.Channel) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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