Skip to content
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

API V5 #74

Open
rtunazzz opened this issue Feb 16, 2023 · 35 comments
Open

API V5 #74

rtunazzz opened this issue Feb 16, 2023 · 35 comments

Comments

@rtunazzz
Copy link
Contributor

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.)?
@hirokisan
Copy link
Owner

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.

@0cv
Copy link
Contributor

0cv commented Feb 23, 2023

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?

@hirokisan
Copy link
Owner

I missed your comments, sorry.

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

@nanom1t
Copy link

nanom1t commented Mar 15, 2023

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

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

@0cv
Copy link
Contributor

0cv commented Mar 15, 2023

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

@hirokisan
Copy link
Owner

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

@nanom1t
Copy link

nanom1t commented Mar 28, 2023

@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

@hirokisan
Copy link
Owner

Requests for additional features are welcome. Thank you.

This was referenced Mar 29, 2023
@nanom1t
Copy link

nanom1t commented Mar 29, 2023

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

@nanom1t
Copy link

nanom1t commented Mar 31, 2023

@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

This was referenced Apr 3, 2023
@hirokisan
Copy link
Owner

@nanom1t I have implemented it.

@nanom1t
Copy link

nanom1t commented Apr 4, 2023

@hirokisan Thank you!

@nanom1t
Copy link

nanom1t commented Apr 5, 2023

@hirokisan Hi. Please also add the next API V5 methods:
https://bybit-exchange.github.io/docs/v5/position/close-pnl
https://bybit-exchange.github.io/docs/v5/asset/inter-transfer-list

@nanom1t
Copy link

nanom1t commented Apr 6, 2023

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

@hirokisan
Copy link
Owner

@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,
  },
})

@hirokisan
Copy link
Owner

#74 (comment)
@nanom1t I have implemented

@nanom1t
Copy link

nanom1t commented Apr 11, 2023

@hirokisan Thank you very much!

@hirokisan
Copy link
Owner

#74 (comment)
@nanom1t I have just implemented

@nanom1t
Copy link

nanom1t commented Apr 24, 2023

@hirokisan Thanks!

@josephyim224
Copy link
Contributor

@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!

@davidphay
Copy link
Contributor

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 !

@hirokisan
Copy link
Owner

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.

@davidphay
Copy link
Contributor

Ok I didn't understand... thanks !

@apeman76
Copy link

Hello can you add

https://bybit-exchange.github.io/docs/v5/market/risk-limit

@hirokisan
Copy link
Owner

@apeman76 Thank you for your request!

Merged changes.
#132

@apeman76
Copy link

apeman76 commented Jun 28, 2023

@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

@hirokisan
Copy link
Owner

@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
Copy link

@hirokisan
Copy link
Owner

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

@hirokisan
Copy link
Owner

@apeman76 Thank you for your patience.

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

@longmnguyen
Copy link

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

@davidphay
Copy link
Contributor

Hello, Unified trading account is supported with websocket ?

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

Thanks !

@hirokisan
Copy link
Owner

@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
Copy link
Contributor

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants