Code Monkey home page Code Monkey logo

kraken's Introduction

Crypto Trading Bot

Using Kraken REST API

Usage

Create environment with (requires python3.8 and python3.8-venv):

python3.8 -m venv env
./env/bin/pip install --upgrade pip
./env/bin/pip install -r requrements.in

Define API_KEY and SECRET_API_KEY variables in src/local_settings.py.

Run with

./env/bin/python src/main.py

API documentation

Request Headers and Responses

Always set User-Agent and Content-Type: application/x-www-form-urlencoded.

Response examples:

{
  "error": [],
  "result": {
    "status": "online",
    "timestamp": "2021-03-22T17:18:03Z"
  }
}
{
  "error": [
    "EGeneral:Invalid arguments:ordertype"
  ]
}

Status codes are always 200, unless there was a client or server error.

Authenticated requests must include both API-Key and API-Sign HTTP headers, and nonce in the request payload. nonce is an always increasing integer for each request made with a specific API key, e.g. unix timestamp. API-Sign should be:

HMAC-SHA512 of (URI path + SHA256(nonce + POST data)) and base64 decoded secret API key

For example:

def get_kraken_signature(urlpath, data, secret):

    postdata = urllib.parse.urlencode(data)
    encoded = (str(data['nonce']) + postdata).encode()
    message = urlpath.encode() + hashlib.sha256(encoded).digest()

    mac = hmac.new(base64.b64decode(secret), message, hashlib.sha512)
    sigdigest = base64.b64encode(mac.digest())
    return sigdigest.decode()

Rate Limits

Every user gets an API Counter that increases by 2 every history call and by 1 every other call. It decreases by 0.5 every second, and the limit is 20.

That translates roughly to 20 call warm up and then 0.5 call/second or 30 calls/minute.

There are different, more complicated rules for the number of open orders on each asset at a time.

kraken's People

Watchers

 avatar

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.