-
-
Notifications
You must be signed in to change notification settings - Fork 691
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(bybit): Add spot support and migrate to API V5 #1017
feat(bybit): Add spot support and migrate to API V5 #1017
Conversation
@classmethod | ||
def timestamp_normalize(cls, ts: Union[int, dt]) -> float: | ||
if isinstance(ts, int): | ||
return ts / 1000.0 | ||
else: | ||
return ts.timestamp() | ||
|
||
@staticmethod | ||
def convert_to_spot_name(cls, pair): | ||
# Bybit spot and USDT perps use the same symbol name. To distinguish them, use a slash to separate the base and quote. |
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'm confused by this comment - does this mean if I want to subscribe I'd need to do something like BTC|USDT?
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.
Here it adds a slash to spot pairs in order to build proper normalized dict (as linear and spot symbols are identical)
Then in message_handler
it gets the market (spot | perp) from url
line and then passes market
parameter to a functions _candle, _trade and _book. These functions receive spot and perp pair information from the websocket, where both are formatted as 'BTCUSDT'
Then convert_to_spot_name
function adds slash in order to properly use normalized dict later in the code for spot pairs.
This approach may seem complex, but I haven't found a clearer way to implement it.
Short answer on your question - no, no needs to add anything special to subscribe.
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 left a comment about part of the code I'm unsure about. Other than that, looks ready to merge once thats resolved
@kosmodromov - thanks for the PR - just one question for you, then we can merge this. |
This PR adds support for the spot market on Bybit exchange and migrate to V5 API.
Updated market data endpoints:
Only linear futures is supported. No inverse futures support.
Private endpoints remain unmodified.
Fixes: #1010 #1012