Documentation ¶
Index ¶
- Constants
- func GetEventByParam(param map[string]string) (evtId Event)
- func GetInfoFromErrCode(data ErrData) Event
- func GetInfoFromErrMsg(raw string) (channel string)
- type Decorator
- type Msg
- type ProcessDetail
- type ReceivedDataCallback
- type ReceivedDepthDataCallback
- type ReceivedMsgDataCallback
- type ReqFunc
- type WsClient
- func (a *WsClient) AddBookMsgHook(fn ReceivedMsgDataCallback) error
- func (a *WsClient) AddDepthHook(fn ReceivedDepthDataCallback) error
- func (a *WsClient) AddErrMsgHook(fn ReceivedDataCallback) error
- func (a *WsClient) AddMessageHook(fn ReceivedDataCallback) error
- func (a *WsClient) AmendOrder(id string, param map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) BatchAmendOrders(id string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) BatchCancelOrders(id string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) BatchPlaceOrders(id string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) CancelOrder(id string, param map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) EnableAutoDepthMgr(b bool) error
- func (a *WsClient) GetSnapshotByChannel(data DepthData) (snapshot *DepthDetail, err error)
- func (a *WsClient) IsAlive() bool
- func (a *WsClient) IsQuit() <-chan struct{}
- func (a *WsClient) Jrpc(id, op string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) Login(apiKey, secKey, passPhrase string, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) MergeDepth(depData DepthData) (err error)
- func (a *WsClient) Ping(timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) PlaceOrder(id string, param map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) PrivAccout(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PrivBalAndPos(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PrivBookAlgoOrder(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PrivBookOrder(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PrivPostion(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubChannel(evtId Event, op string, params []map[string]string, pd Period, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubEstDePrice(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubFundRate(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubIndexTickers(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubInstruemnts(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubKLine(op string, period Period, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubKLineIndex(op string, pd Period, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubLimitPrice(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubMarkPrice(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubMarkPriceCandle(op string, pd Period, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubOpenInsterest(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubOptionSummary(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubOrderBooks(op string, channel string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubStatus(op string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubTickers(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) PubTrade(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
- func (a *WsClient) Send(ctx context.Context, op WSReqData) (err error)
- func (a *WsClient) SetDailTimeout(tm time.Duration)
- func (a *WsClient) Start() error
- func (a *WsClient) Stop() error
- func (a *WsClient) Subscribe(param map[string]string, timeOut ...int) (res bool, detail *ProcessDetail, err error)
- func (a *WsClient) UnSubscribe(param map[string]string, timeOut ...int) (res bool, detail *ProcessDetail, err error)
Constants ¶
const ( OP_LOGIN = "login" OP_ERROR = "error" OP_SUBSCRIBE = "subscribe" OP_UNSUBSCRIBE = "unsubscribe" )
操作符
const ( SPOT = "SPOT" SWAP = "SWAP" FUTURES = "FUTURES" OPTION = "OPTION" ANY = "ANY" )
instrument Type
Variables ¶
This section is empty.
Functions ¶
func GetEventByParam ¶
根据args请求参数判断请求类型 如:{"channel": "account","ccy": "BTC"} 类型为 EVENT_BOOK_ACCOUNT
func GetInfoFromErrMsg ¶
从error返回中解析出对应的channel error信息样例
{"event":"error","msg":"channel:index-tickers,instId:BTC-USDT1 doesn't exist","code":"60018"}
Types ¶
type ProcessDetail ¶
type ProcessDetail struct { EndPoint string `json:"endPoint"` ReqInfo string `json:"ReqInfo"` //订阅请求 SendTime time.Time `json:"sendTime"` //发送订阅请求的时间 RecvTime time.Time `json:"recvTime"` //接受到订阅结果的时间 UsedTime time.Duration `json:"UsedTime"` //耗时 Data []*Msg `json:"data"` //订阅结果数据 }
订阅结果封装后的消息结构体
func (*ProcessDetail) String ¶
func (p *ProcessDetail) String() string
type ReceivedDepthDataCallback ¶
深度订阅推送数据回调函数
type ReceivedMsgDataCallback ¶
普通订阅推送数据回调函数
type WsClient ¶
type WsClient struct { WsEndPoint string WsApi *ApiInfo OnErrorHook ReceivedDataCallback //错误处理回调函数 // 记录深度信息 DepthDataList map[string]DepthDetail DepthDataLock sync.RWMutex // contains filtered or unexported fields }
websocket
func (*WsClient) AddBookMsgHook ¶
func (a *WsClient) AddBookMsgHook(fn ReceivedMsgDataCallback) error
添加订阅消息处理的回调函数
func (*WsClient) AddDepthHook ¶
func (a *WsClient) AddDepthHook(fn ReceivedDepthDataCallback) error
添加深度消息处理的回调函数 例如: cli.AddDepthHook(func(ts time.Time, data DepthData) error { return nil })
func (*WsClient) AddErrMsgHook ¶
func (a *WsClient) AddErrMsgHook(fn ReceivedDataCallback) error
添加错误类型消息处理的回调函数
func (*WsClient) AddMessageHook ¶
func (a *WsClient) AddMessageHook(fn ReceivedDataCallback) error
添加全局消息处理的回调函数
func (*WsClient) AmendOrder ¶
func (a *WsClient) AmendOrder(id string, param map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
单个改单 参数说明:
id: 请求ID params: 请求参数 timeOut: 超时时间
func (*WsClient) BatchAmendOrders ¶
func (a *WsClient) BatchAmendOrders(id string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
批量改单 参数说明:
id: 请求ID params: 请求参数 timeOut: 超时时间
func (*WsClient) BatchCancelOrders ¶
func (a *WsClient) BatchCancelOrders(id string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
批量撤单 参数说明:
id: 请求ID params: 请求参数 timeOut: 超时时间
func (*WsClient) BatchPlaceOrders ¶
func (a *WsClient) BatchPlaceOrders(id string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
批量下单 参数说明:
id: 请求ID params: 请求参数 timeOut: 超时时间
func (*WsClient) CancelOrder ¶
func (a *WsClient) CancelOrder(id string, param map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
单个撤单 参数说明:
id: 请求ID params: 请求参数 timeOut: 超时时间
func (*WsClient) EnableAutoDepthMgr ¶
设置是否自动深度管理,开启 true,关闭 false
func (*WsClient) GetSnapshotByChannel ¶
获取当前的深度快照信息(合并后的)
func (*WsClient) Jrpc ¶
func (a *WsClient) Jrpc(id, op string, params []map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
jrpc请求
func (*WsClient) Login ¶
func (a *WsClient) Login(apiKey, secKey, passPhrase string, timeOut ...int) (res bool, detail *ProcessDetail, err error)
登录私有频道
func (*WsClient) MergeDepth ¶
开启了深度数据管理功能后,系统会自动合并深度信息
func (*WsClient) Ping ¶
func (a *WsClient) Ping(timeOut ...int) (res bool, detail *ProcessDetail, err error)
Ping服务端保持心跳。 timeOut:超时时间(毫秒),如果不填默认为5000ms
func (*WsClient) PlaceOrder ¶
func (a *WsClient) PlaceOrder(id string, param map[string]interface{}, timeOut ...int) (res bool, detail *ProcessDetail, err error)
单个下单 参数说明:
id: 请求ID params: 请求参数 timeOut: 超时时间
func (*WsClient) PrivAccout ¶
func (a *WsClient) PrivAccout(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
订阅账户频道
func (*WsClient) PrivBalAndPos ¶
func (a *WsClient) PrivBalAndPos(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
订阅账户余额和持仓频道
func (*WsClient) PrivBookAlgoOrder ¶
func (a *WsClient) PrivBookAlgoOrder(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
订阅策略委托订单频道
func (*WsClient) PrivBookOrder ¶
func (a *WsClient) PrivBookOrder(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
订阅订单频道
func (*WsClient) PrivPostion ¶
func (a *WsClient) PrivPostion(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
订阅持仓频道
func (*WsClient) PubChannel ¶
func (*WsClient) PubEstDePrice ¶
func (a *WsClient) PubEstDePrice(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
预估交割/行权价格频道
func (*WsClient) PubFundRate ¶
func (a *WsClient) PubFundRate(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
资金费率频道
func (*WsClient) PubIndexTickers ¶
func (a *WsClient) PubIndexTickers(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
指数行情频道
func (*WsClient) PubInstruemnts ¶
func (a *WsClient) PubInstruemnts(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
产品频道
func (*WsClient) PubKLine ¶
func (a *WsClient) PubKLine(op string, period Period, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
K线频道
func (*WsClient) PubKLineIndex ¶
func (a *WsClient) PubKLineIndex(op string, pd Period, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
指数K线频道
func (*WsClient) PubLimitPrice ¶
func (a *WsClient) PubLimitPrice(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
限价频道
func (*WsClient) PubMarkPrice ¶
func (a *WsClient) PubMarkPrice(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
标记价格频道
func (*WsClient) PubMarkPriceCandle ¶
func (a *WsClient) PubMarkPriceCandle(op string, pd Period, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
标记价格K线频道
func (*WsClient) PubOpenInsterest ¶
func (a *WsClient) PubOpenInsterest(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
持仓总量频道
func (*WsClient) PubOptionSummary ¶
func (a *WsClient) PubOptionSummary(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
期权定价频道
func (*WsClient) PubOrderBooks ¶
func (a *WsClient) PubOrderBooks(op string, channel string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
深度频道
func (*WsClient) PubTickers ¶
func (a *WsClient) PubTickers(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
行情频道
func (*WsClient) PubTrade ¶
func (a *WsClient) PubTrade(op string, params []map[string]string, timeOut ...int) (res bool, msg []*Msg, err error)
交易频道
func (*WsClient) Subscribe ¶
func (a *WsClient) Subscribe(param map[string]string, timeOut ...int) (res bool, detail *ProcessDetail, err error)
订阅频道。 req:请求json字符串
func (*WsClient) UnSubscribe ¶
func (a *WsClient) UnSubscribe(param map[string]string, timeOut ...int) (res bool, detail *ProcessDetail, err error)
取消订阅频道。 req:请求json字符串