-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added wss futures client and implemted 'order.place', 'order.ca… #609
Conversation
@adshao take a review this. |
Hi @xyq-c-cpp , |
|
@xyq-c-cpp |
hello, do you still work for this? @vigodsky |
Hi @xyq-c-cpp , Yes, I'm still working, almost done Thanks |
Hello @xyq-c-cpp , I also moved keep alive handler in connection state and added some mutex for fix data race in it. |
e585cb5
to
8a2cb02
Compare
…s, sync write method and support 3 sign functions
8a2cb02
to
2c5c386
Compare
v2/futures/order_place_service_ws.go
Outdated
|
||
// NewOrderPlaceWsService init OrderPlaceWsService | ||
func NewOrderPlaceWsService(apiKey, secretKey string) (*OrderPlaceWsService, error) { | ||
conn, err := newConnection() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether synchronous or asynchronous, the same connection is required, which is a long connection in WebSocket. Is this the current situation where all these similar interfaces share a common connection. is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's not. Due to limited time I created WriteSync method that using the same connection but leaved comment for this. If you propose to have separate client with it's own connection, I agree. But It will takes sometime to implement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current scheme is
service->client(sync && async write)->single connection
OrderPlaceService and OrderCancel will have different connections
I think it's ok to not have only one connection for all services,
It's easier and more fault tolerant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but the biggest advantage of WebSocket is sharing long connections. If you use a separate connection, I think it's better to use the REST interface. This is also why some people use WebSocket. Please take some time to implement this, it's almost done. @vigodsky
@vigodsky hello, take a look to the review. |
@xyq-c-cpp Hi, |
got it. @vigodsky |
Hi @xyq-c-cpp |
It means sharing one connection for all request service interfaces, is that okay? if you see this message, please leave a comment to let me know @vigodsky |
Hi @xyq-c-cpp But I'd like to explain why it was chosen that way. Your suggestion to make a single connection also has its pros and cons, but it introduces additional complexity to create routing on the library side. You will have to decide which channel to send the message to. I tried to make such an implementation, but ran into some problems: For example, simultaneous execution of This could be solved by using a composite key that we can pass to clientOrderID for Binance to give it back to us Faced with these limitations, I came to the conclusion that splitting the connets would be the simplest implementation. |
@xyq-c-cpp Hi, |
Hello,
Here is implementation of Binance Futures wss client with reconnect backoff and send/receive functions
Also two endpoints were implemented - 'order.place' and 'order.cancel'
Example of usage
Feel free to ask questions!