huobi

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Huobi = "huobi"

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

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 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"`
	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"`
}

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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