websocket

package
v0.0.0-...-cb51c14 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACCESS_KEY string = "*"
	SECRET_KEY string = "*"

	// API请求地址, 不要带最后的/
	MARKET_URL string = "https://api.hbdm.com"
	TRADE_URL  string = "https://api.hbdm.com"

	WS_STOCK_URL        string = "wss://api.huobi.pro/ws"
	WS_FUTURE_URL       string = "wss://www.hbdm.com/ws"
	WS_FUTURE_ORDER_URL string = "ws://api.hbdm.com/notification"

	Local_IP string = "*.*.*.*" //Your Local IP

	//replace with real URLs and HostName
	HOST_NAME string = "api.hbdm.com"
)

Variables

This section is empty.

Functions

func AddClientNum

func AddClientNum()

func NowSec

func NowSec() int

func SubClientNum

func SubClientNum()

Types

type Client

type Client struct {
	Name   string
	Params *ClientParameters
	Ws     *websocket.Conn
	// contains filtered or unexported fields
}

func NewHuobiWSClient

func NewHuobiWSClient(params *ClientParameters) *Client

func (*Client) Listen

func (cli *Client) Listen() <-chan interface{}

func (*Client) Subscribe

func (cli *Client) Subscribe(requests []Request)

func (*Client) SubscribeFutureMarketTrade

func (cli *Client) SubscribeFutureMarketTrade(symbols []string)

func (*Client) SubscribeSpotMarketTrade

func (cli *Client) SubscribeSpotMarketTrade(symbols []string)

type ClientParameters

type ClientParameters struct {
	URL               string
	LocalIP           string
	ReconnectTimeout  time.Duration
	PangTickerTimeout time.Duration
	WSDialerTimeout   time.Duration
	WSDialerKeepAlive time.Duration
	WSMessageTimeout  time.Duration
	ReConnect         bool
}

func NewDefaultParameters

func NewDefaultParameters() *ClientParameters

type Data

type Data struct {
	Ts        int64   `json:"ts"`
	Price     float64 `json:"price"`
	Direction string  `json:"direction"`
}

type Moniter

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

ws-client的监控对象

type Request

type Request struct {
	Id  string `json:"id"`
	Req string `json:"req"`
	Sub string `json:"sub"`
}

* 订阅websocket的请求格式

{
	"sub": "market.$symbol.kline.$period",
	"id": "id generate by client"
}

type Tick

type Tick struct {
	Id   int    `json:"id"`
	Ts   int64  `json:"ts"`
	Data []Data `json:"data"`
}

type TradeDetail

type TradeDetail struct {
	Ts   int64  `json:"ts"`
	Ch   string `json:"ch"`
	Tick Tick   `json:"tick"`
}

Jump to

Keyboard shortcuts

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