All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Enable websocket
fetch()to handle multiple position sides from linear perp symbols - Fix
fetch()for private spot websocket - Support
endpointargument formy_position(), allowing the user to call this method without supplying a symbolsymbolis not a required parameter for these endpoints, but pybit typically relies on it for deciding which endpoint to call
- See below release candidates for details.
- Alter the spot endpoint paths used for
get_active_order()andquery_active_order()
- Fixed failure to load subscriptions when provided in as JSON strings
- Fixed the spot auth websocket to ensure subscriptions are not required
- Fixed methods like
query_symbol()(which have no API parameters) not working following the spot update
- Implemented the Spot API in
HTTP - Implemented the Account Asset API in
HTTP - Implemented the Spot websocket in
WebSocket
- Removed
position_mode_switch()as the endpoint has not been released to mainnet yet
- Added new
HTTPmethods for new endpoints - Added new paths for existing methods
- Fixed some old paths
is_linearargument inget_risk_limit()
- Added some logic to decide if there is 'order_book' in order book snapshot push for websocket
- Added
ignore_codesargument toHTTPfor status codes to not raise any errors on.
- Removed extra suffix definition block in
place_conditional_order. - Changed logger functionality so that it won't overwrite user's preferred logging settings.
- Fixed wrong number of arguments error inside websocket
on_message,on_close,on_open,on_error.
- Fixed typo errors on endpoint urls.
- Added support for futures endpoints on
HTTP(usingisdigitto detect futures symbols).
- Using
getmethod fordictfor symbol check instead of calling by key. endpointonHTTPwill now default to https://api.bybit.com if no argument.retry_codesis now user-definable in theHTTParguments.- All logging is now on
DEBUGlevel—user will need to manually setlogging_leveltoDEBUG. - Added attempted request to
FailedRequestErrorandInvalidRequestErrorfor improved error logging.
- Fixed unexpected
tuplegeneration for status codes onInvalidRequestErrorandFailedRequestError. - Fixed how
Websockethandles incomingorderBookdata due to Bybit's topic naming changes.
requestswill useJSONDecodeErrorfromsimplejsonif it is available—pybitwill now do the same to prevent errors.- Fixed a bug where
HTTPretry would crash on rate limit reached due to undefined variable. - Improved
InvalidRequestErrorandFailedRequestErrorto include error codes and times.
WebSocketwill now temporarily differentiate between inverse and linear endpoints for the 'order' topic since incoming data has differing keys.
WebSocketnow haspurge_on_fetch(defaults toTrue), which allows the user to keep data between fetches.
- Fixed a bug on 'stop_order' for
WebSocketthat would prevent data from being appended due to deprecation ofstop_order_id.
- See release candidates for details.
- Rewrote if-condition on
_on_messageinWebSocketclass to check for linear or non-linear position data.
- Added ability to handle
fromusingfrom_timeandfrom_idarguments sincefromis a reserved keyword. - Removed
ignore_retries_forfromHTTP.pybitnow uses a standard list of non-critical errors that can be retried. - Added argument
retry_delayforHTTP—allows user to add a custom retry delay for each retry.
- See release candidates for details.
- Fixed raise error missing argument for
FailedRequestErrorupon max retries. - Modified API endpoints to saistfy requirements for upcoming endpoint deprecation, see the API Documentation for more info.
- Updated
WebSocketclass to properly handlecandlefrom USDT perpetual streams. - Updated
WebSocketclass to return a copy of the collected data, preventing establishing a reference. - Updated
WebSocketclass to properly handle linear (USDT) orderbook data. - Performance improvements.
- Changed
ignore_retries_fordefault argument to be empty tuple to prevent error.
- Added
ignore_retries_forargument toHTTPauthmethod, allowing the user to choose which error codes should NOT be retried.
FailedRequestErrorandInvalidRequestErrornow havemessageandstatus_codeattributes.
- Will now catch and handle
requests.exceptions.ConnectionError.
- Added
recv_windowerror handler toHTTPauthmethod. - Will now catch and handle
requests.exceptions.SSLError.
- Added
recv_windowargument toHTTPclass.
- Improved error handling.
- Added
max_retriesargument toHTTPclass.
- Added
FailedRequestErrorto differentiate between failed requests and invalid requests. - Fixed
exitmethod onWebSocketto now properly handle the closing of the socket.
- Increased expires time for WebSocket authentication to a full second.
- Add option to handle timeout on request submission.
- Fixed trailing decimal zero to prevent auth signature errors.
- New
HTTPmethods. - New argument for
HTTPclass to log each outgoing request. - New argument for
WebSocketclass to attempt restart after an error is detected.
- Mass simplification of all methods—each method now takes a series keyword arguments rather than a set number of required pre-defined arguments. This makes the library future-proof and prevents breaking on significant updates to the REST API endpoints. This, however, requires the user to study the API documentation and know which arguments are required for each endpoint.
- One new exception has been added—
InvalidRequestError. This exception will be raised if Bybit returns with an error, or ifrequestsis unable to complete the request. - Inverse and Linear endpoints are now handled accordingly by differentiating from the symbol argument.
- Updated existing
HTTPmethod names to follow the same naming procedure as listed in the Bybit API documentation. - Reformatting of code to follow PEP-8 standards.
- New docstring format.
- Various logging features added to both HTTP and WebSocket classes.
- Extensive WebSocket class updates.
- Modified the WebSocketApp to send a heartbeat packet every 30 seconds, with a timeout of 10 seconds. These settings can be modified using the 'ping_interval' and 'ping_timeout' arguments of the WebSocket constructor.
- User no longer needs to manage the incoming stream;
pybitdoes all the work (insert, update, delete). - Modified
ws.ping()for ease of use; simply use the function to send heartbeat packets. When something happens to the connection, Python will raise anExceptionwhich the end-user can catch and handle.
- Redundancy updates to the HTTP class.
- Modified the HTTP class to use an endpoint argument, allowing users to take advantage of the USDT endpoints.
- The setup.py file has been fixed to correctly install the pybit package.
- The
pybitmodule. - MANIFEST, README, LICENSE, and CHANGELOG files.