adampointer / go-bitmex Goto Github PK
View Code? Open in Web Editor NEWEvent driven BitMEX client library for Golang
License: MIT License
Event driven BitMEX client library for Golang
License: MIT License
The library seems to panic on occasion in:
func (w *WebsocketClient) disconnectAndRetry() {
w.log.Warn("disconnected")
w.heartbeat.Stop()
w.conMutex.Lock()
w.connected = false
w.conMutex.Unlock()
w.log.Info("retrying websocket connection in 30s")
time.Sleep(30 * time.Second)
w.Restart()
}
at the line w.heartbeat.Stop()
. Seems like w.heartbeat
can be nil
at times.
Patching so that it reads:
if w.heartbeat != nil {
w.heartbeat.Stop()
}
fixes the panic however w.heartbeat
being nil
at that time likely points to some other race condition.
Replace the current event bus library as it is having issues with message ordering guarantees. This makes creating an L2 orderbook model difficult.
I've seen that you've been looking at my project, I'm very happy that you've taken me into account.
https://github.com/Leci37/stocks-prediction-Machine-learning-RealTime-telegram
If you want to collaborate in our team, you can connect me via github, https://twitter.com/Whale__Hunters or [email protected]
Looks like this library uses WebSockets for subscriptions etc. however all the other requests are made through the JSON-RPC via HTTP. Is this correct? If so, is there a reason beyond the functions to do so being unexported?
I am able to place orders using e.rpcRequest(req)
if I patch the library and add:
func (e *Exchange) WriteReqWS(req *RPCRequest) (*RPCResponse, error) {
return e.rpcRequest(req)
}
This seems to work. Results in lower order latency and also has the benefit of not using up your "request quota".
Am I missing something here? Why was this function not exported? Is there an easier way to actually send these messages over the already alive websocket connection?
My test involves:
func (dbit *DeribitSessionContext) createRPC(method string, args map[string]string) (*deribit.RPCRequest, error) {
req := deribit.NewRPCRequest(method)
if args != nil {
for k, v := range args {
if err := req.SetQueryParam(k, v); err != nil {
return nil, err
}
}
}
return req, nil
}
func (dbit *DeribitSessionContext) LimitOrder(dir models.Direction, total uint64, price float64, postOnly bool, label *string) error {
args := map[string]string{
"instrument_name": DeribitBtcPerpInstrument,
"type": "limit",
"price": fmt.Sprintf("%.2f", price),
"amount": fmt.Sprintf("%d", total),
}
if postOnly {
args["post_only"] = "true"
}
if label != nil {
args["label"] = *label
}
req, err := dbit.createRPC(fmt.Sprintf("private/%s", dir), args)
if err != nil {
return err
}
resp, err := dbit.ctx.WriteReqWS(req)
if err != nil {
return err
}
if resp == nil {
return ErrNilResponse
}
return nil
}
This actually has significantly lower latency than the standard way of using the client (which seems to use JSON-RPC over a new HTTP request).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.