Skip to main content

Bitmex websocket API

Project description

Install

$ pip install bitmex-websocket

Usage

  1. 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
  1. 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

bitmex_websocket-0.3.5.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

bitmex_websocket-0.3.5-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2 Python 3

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

Hashes for bitmex_websocket-0.3.5.tar.gz
Algorithm Hash digest
SHA256 084087671a8cc1ced7b803beae187574c391ed3eae6fa5d37db8e0cfd5066b98
MD5 c742b8cb96c6046bf815e21bf22ab41d
BLAKE2b-256 f4101eada56be1082328a82908d930f65ea147ed053b7334162b561b0dc005e8

See more details on using hashes here.

File details

Details for the file bitmex_websocket-0.3.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bitmex_websocket-0.3.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b873e1bea31050f1d757850140173b283e9ee2101c199d91828b7bfbdcba234
MD5 ccec7ef4a702c3866da2aadfe0026aab
BLAKE2b-256 3ed35ba73abbc4ff306dbaef077442fd747ac89b53e41c7242931953121f5511

See more details on using hashes here.

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