Skip to main content

Bitmex websocket API

Project description

bitmex-websocket
==========================

[![Build Status](https://travis-ci.org/joliveros/bitmex-websocket.svg?branch=master)](https://travis-ci.org/joliveros/bitmex-websocket)
[![Requires.io](https://requires.io/github/joliveros/bitmex-websocket/requirements.svg?branch=master)](https://requires.io/github/joliveros/bitmex-websocket/requirements?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/joliveros/bitmex-websocket/badge.svg?branch=master)](https://coveralls.io/github/joliveros/bitmex-websocket?branch=master)

Bitmex Websocket API Wrapper

## Install

```bash
pip install bitmex-websocket
```



## Usage

1. First you should set your `BITMEX_API_KEY` and `BITMEX_API_SECRET`. It can
be done as follows:
```bash
$ cp .env.example .env
# edit .env to reflect your API key and secret
$ source .env
```

1. Then in your project you can consume `Instrument` as follows:
```python
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:
```bash
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 Distributions

bitmex_websocket-0.1.0-py3.6.egg (1.6 kB view hashes)

Uploaded Source

bitmex_websocket-0.1.0-py2.py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page