Giter VIP home page Giter VIP logo

bitmex-websocket's Introduction

bitmex-websocket

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.

bitmex-websocket's People

Contributors

joliveros avatar hectorceti avatar atten avatar scoriiu avatar littlebro avatar woxblom avatar dependabot[bot] avatar

Stargazers

David Coriiu avatar

Forkers

even-eeek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.