hirokisan / bybit

Bybit client library for Go

Home Page:https://pkg.go.dev/github.com/hirokisan/bybit/v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API V5

rtunazzz opened this issue · comments

commented

Hey there,

Are there any plans to support V5?

https://bybit-exchange.github.io/docs/v5/upgrade-guide

Would love to contribute, just wanted to ask if there were any expectations, preferred way of doing things, e.g.

  • 1 Interface for V5?
  • 1 Interface for each segment of V5 (market, order, position etc.)?

Hi, thanks for your commit again.

I would like to support V5.

Interface for V5?

I would like to prepare interface for V5 and providing an interface for each segment to implement.

Here, I have prepared the foundation to proceed with the implementation.
#75

I think we can start from here.

Quite excited to see V5 getting implemented. Question on private websockets: do you want to keep just one file v5_ws_private.go or split it by category? We have Position, Execution, Order, Wallet, Greek and that might be a bit too much for just one file?

I missed your comments, sorry.

We've already communicated with it via pull request, files are separated by category.

Hi. I don't see the method GetOpenOrders for V5.

I've made go get -u github.com/hirokisan/bybit/v2

@nanom1t grab the main branch instead go get github.com/hirokisan/bybit/v2@main

By the way, anyone's commitment is welcome, thanks.

@hirokisan Could you please implement Amend Order and Set trading stop methods for API v5?
https://bybit-exchange.github.io/docs/v5/order/amend-order
https://bybit-exchange.github.io/docs/v5/position/trading-stop

Thanks

Requests for additional features are welcome. Thank you.

Thank you. Also please add Switch Position Mode and Cancel All Orders methods for API v5:
https://bybit-exchange.github.io/docs/v5/position/position-mode
https://bybit-exchange.github.io/docs/v5/order/cancel-all

@hirokisan Thanks for 113. Please also implement Switch Position Mode and Set TP/SL Mode methods for positions:
https://bybit-exchange.github.io/docs/v5/position/position-mode
https://bybit-exchange.github.io/docs/v5/position/tpsl-mode

@nanom1t I have implemented it.

@hirokisan Thank you!

Is it possible to set custom HTTP header for API v5 requests? Thanks

@nanom1t

Is it possible to set custom HTTP header

This is possible by using the http.Client you have defined.

You can prepare http.RoundTripper and set custom HTTP header on the request.

e.g.

type customTransport struct {
  transport http.RoundTripper
}

func (t *customTransport) RoundTrip(req *http.Request) (*http.Response, error) {
  req.Header.Set("name", "value")
  return t.transport.RoundTrip(req)
}

client := bybit.NewClient().WithHTTPClient(&http.Client{
  Transport: &customTransport{
    transport: http.DefaultTransport,
  },
})

#74 (comment)
@nanom1t I have implemented

@hirokisan Thank you very much!

#74 (comment)
@nanom1t I have just implemented

@hirokisan Thanks!

@hirokisan just found that the heartbeat message in v5 wss public is not what Bybit expects and different with the one in v5 wss private, so I created a small PR to fix it #126
can you kindly approve it? thanks!

Hello, do you think it's possible to have the function Get Close Pnl as subscription ? I tried to do it myself without success... !

Thanks !

the function Get Close Pnl

https://bybit-exchange.github.io/docs/v5/position/close-pnl

you mean this, right?

as subscription

I don't understand what you mean.

You want to get Close Pnl with Websocket Private Position?

If so, the documentation does not seem to indicate that it can be done.

Ok I didn't understand... thanks !

@apeman76 Thank you for your request!

Merged changes.
#132

commented

@apeman76 Thank you for your request!

Merged changes. #132

Thank you for implementing it. I'm pretty new to golang but I cant seem to use it yet, I think I need a new release for it to work since updating the package will still give me 2.18.1.
I might be completely wrong though!

//fixed with go get -u github.com/hirokisan/bybit/v2@main

@apeman76

Sorry for the inconvenience.
I usually release them on Fridays, but just released it because it seems to be urgent.

https://github.com/hirokisan/bybit/releases/tag/v2.19.0

@apeman76
Sorry for the late reply.
I'm a little busy and will find time to add it!

@apeman76 Thank you for your patience.

Merged changes.
https://github.com/hirokisan/bybit/releases/tag/v2.22.0

Hi @hirokisan could you assist in adding methods to access the client and connection? I want to further extend some functionalities of V5WebsocketPublicService and V5WebsocketPrivateService.
E.g
`
func (s *V5WebsocketPrivateService) GetClient() *WebSocketClient {
return s.client
}

func (s *V5WebsocketPrivateService) GetConnection() *websocket.Conn {
return s.connection
}
`
Thanks

Hello, Unified trading account is supported with websocket ?

Since I update my account it doesn't work anymore.

Thanks !

@davidphay

I update my account it doesn't work anymore.

I don't understand your situation in detail, but it should work.

As far as the link below,

https://bybit-exchange.github.io/docs/v5/websocket/private/wallet

it will work because of the description of unified account.

@davidphay

I update my account it doesn't work anymore.

I don't understand your situation in detail, but it should work.

As far as the link below,

https://bybit-exchange.github.io/docs/v5/websocket/private/wallet

it will work because of the description of unified account.

Yes you're right, I tested again and I just use the wrong API key...