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:
from bitmex_websocket import Instrument
import asyncio
import websocket
websocket.enableTrace(True)
XBTH17 = Instrument(symbol='XBTH17',
# subscribes to all channels by default, here we
# limit to just these two
channels=['margin', 'orderBook10'],
# you must set your environment variables to authenticate
# see .env.example
shouldAuth=True)
# Get the latest orderbook
orderBook10 = XBTH17.get_table('orderBook10')
# subscribe to all action events for this instrument
XBTH17.on('action', lambda x: print("# action message: %s" % x))
loop = asyncio.get_event_loop()
loop.run_forever()
Examples
Run example scripts:
$ RUN_ENV=test python -m examples.example-1
Tests
Testing is set up using pytest <http://pytest.org> and coverage is handled with the pytest-cov plugin.
Run your tests with py.test 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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for bitmex_websocket-0.1.14-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83bae17a8b40a5b5348e3b04e666609f409068b1aba61a63d1d068fa6195fe1b |
|
MD5 | 4c501481212aee77bc75725e269d317f |
|
BLAKE2b-256 | 34c2bb170a190701e8c56d9fa8b44b9f3eba33750af0a035f655f0543603973f |