hirokisan / bybit

Bybit client library for Go
https://pkg.go.dev/github.com/hirokisan/bybit/v2
MIT License
97 stars 61 forks source link

API V5 #74

Open rtunazzz opened 1 year ago

rtunazzz commented 1 year ago

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.

hirokisan commented 1 year ago

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. https://github.com/hirokisan/bybit/pull/75

I think we can start from here.

0cv commented 1 year ago

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 commented 1 year ago

I missed your comments, sorry.

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

nanom1t commented 1 year ago

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

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

0cv commented 1 year ago

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

hirokisan commented 1 year ago

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

nanom1t commented 1 year ago

@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 commented 1 year ago

Requests for additional features are welcome. Thank you.

nanom1t commented 1 year ago

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 commented 1 year ago

@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

hirokisan commented 1 year ago

@nanom1t I have implemented it.

nanom1t commented 1 year ago

@hirokisan Thank you!

nanom1t commented 1 year ago

@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 commented 1 year ago

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

hirokisan commented 1 year ago

@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 commented 1 year ago

https://github.com/hirokisan/bybit/issues/74#issuecomment-1497228323 @nanom1t I have implemented

nanom1t commented 1 year ago

@hirokisan Thank you very much!

nanom1t commented 1 year ago

Hi @hirokisan. Please implement the next V5 API methods:

Thanks

hirokisan commented 1 year ago

https://github.com/hirokisan/bybit/issues/74#issuecomment-1508155493 @nanom1t I have just implemented

nanom1t commented 1 year ago

@hirokisan Thanks!

josephyim224 commented 1 year ago

@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 https://github.com/hirokisan/bybit/pull/126 can you kindly approve it? thanks!

davidphay commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Ok I didn't understand... thanks !

apeman76 commented 1 year ago

Hello can you add

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

hirokisan commented 1 year ago

@apeman76 Thank you for your request!

Merged changes. https://github.com/hirokisan/bybit/pull/132

apeman76 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

Hello can you add https://bybit-exchange.github.io/docs/v5/position/set-risk-limit Thanks!

hirokisan commented 1 year ago

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

hirokisan commented 1 year ago

@apeman76 Thank you for your patience.

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

longmnguyen commented 1 year ago

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 commented 8 months ago

Hello, Unified trading account is supported with websocket ?

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

Thanks !

hirokisan commented 8 months ago

@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 commented 8 months ago

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