# Python Adapter for BitMEX Realtime Data
This is a reference adapter for receiving realtime data from the BitMEX API. See [the BitMEX documentation](https://testnet.bitmex.com/app/wsAPI) for more information on the websocket API.
# Installation
pip install bitmex-ws
# Quickstart
BitMEXWebsocket is the main entry point to connect to the BitMEX websocket API. The API supports both authenticated and unauthenticated clients. Some endpoints require credentials, for more info see [the documentation on authentication.](https://testnet.bitmex.com/app/wsAPI#Authentication)
To get started, instantiate a connection:
from bitmex_websocket import BitMEXWebsocket ws = BitMEXWebsocket(endpoint=”https://testnet.bitmex.com/api/v1”, symbol=”XBTUSD”, api_key=None, api_secret=None)
If you want to subscribe to authenticated data streams, [create an API key](https://testnet.bitmex.com/app/apiKeys) and supply the corresponding values in api_key and api_secret. BitMEX has two systems - testnet for simulated trading and testing, and www for live trading. API keys are specific to one system. If you created the key on testnet, make sure your connection string points to testnet as well.
Once you are connected, you can retrieve data via the connector’s methods. The latest data will be streamed to the client - no need to poll the server.
ws.get_instrument() ws.get_ticker() ws.funds() ws.market_depth() ws.open_orders() ws.recent_trades()
main.py has a full example of how to connect to BitMEX:
$ python main.py 2018-02-01 11:51:53,355 - bitmex_websocket - INFO - Connecting to wss://testnet.bitmex.com/realtime?subscribe=execution:XBTUSD,instrument: … 2018-02-01 11:51:53,356 - bitmex_websocket - INFO - Not authenticating. 2018-02-01 11:51:54,357 - bitmex_websocket - INFO - Connected to WS. 2018-02-01 11:51:54,360 - bitmex_websocket - INFO - Got all market data. Starting. 2018-02-01 11:51:54,364 - root - INFO - Ticker: {‘last’: 8947.0, ‘sell’: 8948.0, ‘buy’: 8947.0, ‘mid’: 8947.0} 2018-02-01 11:51:54,369 - root - INFO - Market Depth: [{‘id’: 15500000950, ‘side’: ‘Sell’, ‘size’: 384, ‘price’: 999990.5, ‘symbol’: ‘XBTUSD’ … 2018-02-01 11:51:54,370 - root - INFO - Recent Trades: [{‘side’: ‘Sell’, ‘size’: 29856, ‘price’: 8947, ‘symbol’: ‘XBTUSD’, ‘timestamp’: …
# Compatibility This module supports Python 3.5+.
Metadata
Release files for bitmex-ws 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bitmex-ws-0.3.1.tar.gz | 6.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bitmex_ws-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.0 kB
Release files / bitmex-ws-0.3.1.tar.gz
| Download URL | bitmex-ws-0.3.1.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39a18f521d34e8c0d5cb1ccb94b75c8147d607cb9cef5e67b5f53da374a1bd11
|
|
BLAKE2b-256 checksum How to use checksums |
f05c6ea7f43b49cf46b0d1552abd6ab89aae4f74641ebca2d836c52737300ea1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / bitmex_ws-0.3.1-py3-none-any.whl
| Download URL | bitmex_ws-0.3.1-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2db4720a34cdb42aeb1417718876816bdf8fa22fb4951bdc93fc78265cf15f9e
|
|
BLAKE2b-256 checksum How to use checksums |
58133b49c92d34248df1b93502be788401ba100e26f24c97ffa083f570ae4f4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for bitmex-ws 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.