######################################
BitEx Kraken - Plugin for Kraken's API
######################################
.. image:: https://circleci.com/gh/deepbrook/bitex-kraken.svg?style=svg
    :target: https://app.circleci.com/pipelines/github/deepbrook/bitex-kraken
    :alt: CI Status
.. image:: https://readthedocs.org/projects/bitex-kraken/badge/?version=latest
    :target: https://bitex-kraken.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status
Installation
============
Installation is simple, as it should be::
    pip install bitex-kraken
Qickstart
=========
After installing, requesting data is easy::
    >>>from bitex import BitexSession
    >>>session = BitexSession()
    # bitex.BitexSession provides a set of methods to execute the most common queries
    >>>r = session.ticker("kraken", "XBTUSD")
    # The response objects returned are bitex.BitexResponses, which behave like regular requests.Response objects.
    >>>r
    <KrakenResponse [200]>
    >>>r.json()
    {
        "error":[],
        "result": {
            "XXBTZUSD":{
                "a":["3809.10000","1","1.000"],
                "b":["3809.00000","1","1.000"],
                "c":["3809.60000","0.11007700"],
                "v":["1378.29558699","4120.69226171"],
                "p":["3798.72908","3797.90051"],
                "t":[1960,5958],
                "l":["3776.90000","3775.80000"],
                "h":["3817.60000","3819.30000"],
                "o":"3796.20000"
            }
        }
    }
    # bitex-kraken also provides convenience methods for data piping
    >>>r.key_value_dict()
    {
      "uid": "<uid>",
      "received": "<ts>",
      "ask_price": "52131.00000",
      "ask_size": "1.000",
      "ask_size": "52130.10000",
      "bid_size": "2.000",
      "last_price": "52130.20000",
      "last_size": "0.04000000",
      "vol": "1231.07009049",
      "vol_24h": "6124.65870266",
      "vwap": "52031.82478",
      "vwap_24h": "51669.15093",
      "trades": "14674",
      "trades_24h": "59777",
      "high": "52555.10000",
      "high_24h": "52779.60000",
      "low": "51370.00000",
      "low_24h": "50519.00000",
      "open": "52130.00000"
    }
    # Or for storing them as uid-label-value triples
    >>>r.triples()
    [
      ["<uid>", "ask_price", "52131.00000"],
      ["<uid>", "ask_size", "1.000"],
      ["<uid>", "ask_size", "52130.10000"],
      ["<uid>", "bid_size", "2.000"],
      ["<uid>", "last_price", "52130.20000"],
      ["<uid>", "last_size", "0.04000000"],
      ["<uid>", "vol", "1231.07009049"],
      ["<uid>", "vol_24h", "6124.65870266"],
      ["<uid>", "vwap", "52031.82478"],
      ["<uid>", "vwap_24h", "51669.15093"],
      ["<uid>", "trades", "14674"],
      ["<uid>", "trades_24h", "59777"],
      ["<uid>", "high", "52555.10000"],
      ["<uid>", "high_24h", "52779.60000"],
      ["<uid>", "low", "51370.00000"],
      ["<uid>", "low_24h", "50519.00000"],
      ["<uid>", "open", "52130.00000"],
      ["<uid>", "received", "<ts>"]
    ]
.. note:: On the `uid` value
    In the above example, "<uid>" is a string generated by `uuid.uuid4` and is used to identify separate objects
    within a request. It's generated by us, **not** Kraken and is **NOT** tracked between requests.
    i.e. the same order has a different uid across requests. Keep this in mind when piping data into your backend systems.
Development
===========
If you're looking to work on or with `bitex-framework`, you'll want the development
environment setup. We've supplied a few `make` targets to make your life easier::
    # Install bitex and its development requirements
    make development
We also supply targets to run code formatters, linters and tests::
    # Run code formatters
    make pretty
    # Verify code style
    make style-check
    # Run tests via tox
    tox -e testenv
If you'd like to contribute to the project, please have a look at `CONTRIBUTING.rst`
on some general pointers about how development takes place, what the expected
steps of you are and what requirements we have to merge a PR.