Bitmex websocket API
Project description
Install
$ pip install bitmex-websocket
Usage
First you should set your BITMEX_API_KEY and BITMEX_API_SECRET. It can be done as follows:
$ cp .env.example .env
# edit .env to reflect your API key and secret
$ source .env
Then in your project you can consume Instrument as follows:
import websocket
from bitmex_websocket import Instrument
from bitmex_websocket.constants import InstrumentChannels
websocket.enableTrace(True)
channels = [
InstrumentChannels.quote,
InstrumentChannels.trade,
InstrumentChannels.orderBookL2
]
XBTUSD = Instrument(symbol='XBTUSD',
channels=channels)
XBTUSD.on('action', lambda msg: print(msg))
XBTUSD.run_forever()
TestNet
You may change the BASE_URL by setting the BITMEX_BASE_URL environment variable to: https://testnet.bitmex.com/api/v1/.
Examples
Run example scripts:
$ ./examples/example.py
Tests
Testing is set up using pytest <http://pytest.org> and coverage is handled with the pytest-cov plugin.
Run your tests with pytest in the root directory.
Coverage is ran by default and is set in the pytest.ini file. To see an html output of coverage open htmlcov/index.html after running the tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bitmex_websocket-0.3.5.tar.gz
.
File metadata
- Download URL: bitmex_websocket-0.3.5.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 084087671a8cc1ced7b803beae187574c391ed3eae6fa5d37db8e0cfd5066b98 |
|
MD5 | c742b8cb96c6046bf815e21bf22ab41d |
|
BLAKE2b-256 | f4101eada56be1082328a82908d930f65ea147ed053b7334162b561b0dc005e8 |
File details
Details for the file bitmex_websocket-0.3.5-py2.py3-none-any.whl
.
File metadata
- Download URL: bitmex_websocket-0.3.5-py2.py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b873e1bea31050f1d757850140173b283e9ee2101c199d91828b7bfbdcba234 |
|
MD5 | ccec7ef4a702c3866da2aadfe0026aab |
|
BLAKE2b-256 | 3ed35ba73abbc4ff306dbaef077442fd747ac89b53e41c7242931953121f5511 |