Try using the Kraken API in Python

Background

When I was trading levers on BitFlyer Lightning, someone else's automated trading program wiped out my buy orders. (It seems that there was a bug in the API) The market price of Bitcoin in Forex dropped from 46000 to 30000 at a stretch, and I was also lost. I'm scared, so let's distribute it to other places for the time being! So, I started to touch Kraken, which is rumored to have a business alliance with Money Partners, so I decided to touch the API as well.

API documentation

API specifications API Documentation

Kraken introduces implementation examples in each language API client example

Try using

Since I am using Python 2.7.11, there is a link in the API client example python2-krakenex It was used.

Setup is

git clone https://github.com/veox/python2-krakenex.git
cd python2-krakenex
python ./setup.py install

with this,

import krakenex

Can be called.

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import krakenex

k = krakenex.API('key','secret')

total_balance = k.query_private('TradeBalance', {'asset': 'ZJPY'})['result']['tb']
print total_balance

ticks = k.query_public('Ticker',{'pair':'XXBTZJPY,ETHXBT,ETHJPY'})['result']
print ticks

With this, you can get the Japanese Yen equivalent deposit amount, BTC / JPY, ETH / BTC, and ETH / JPY tickers.

The response is JSON.

If you look at the official kraken documentation, there are Public API and Private API, so use query_public and query_private properly accordingly. Where the list of pairs is specified

'XXBTZJPY,ETHXBT,ETHJPY'

Treat as one character string like.

that's all

Recommended Posts

Try using the Kraken API in Python
Try using the Wunderlist API in Python
Try using the BitFlyer Ligntning API in Python
Try using the DropBox Core API in Python
Tweet using the Twitter API in Python
Try hitting the YouTube API in Python
Try using the Twitter API
Try using the Twitter API
Try using the PeeringDB 2.0 API
Try using ChatWork API and Qiita API in Python
Initial settings when using the foursquare API in python
Using the National Diet Library Search API in Python
Getting the arXiv API in Python
Hit the Sesami API in Python
Try using Pleasant's API (python / FastAPI)
Try using LevelDB in Python (plyvel)
Hit the web API in Python
Try using Python argparse's action API
Try using the Python Cmd module
Access the Twitter API in Python
Try using Leap Motion in Python
Mouse operation using Windows API in Python
Try using the HL band in order
Get Youtube data in Python using Youtube Data API
Quickly try Microsoft's Face API in Python
Try hitting the Spotify API in Django.
Regularly upload files to Google Drive using the Google Drive API in Python
Try using FireBase Cloud Firestore in Python for the time being
Evernote API in Python
Try gRPC in Python
C API in Python 3
Try 9 slices in Python
Try using Tweepy [Python2.7]
[Cloudian # 7] Try deleting the bucket in Python (boto3)
Python: Try using the UI on Pythonista 3 on iPad
Get image URL using Flickr API in Python
Try using the Python web framework Tornado Part 1
Tips for hitting the ATND API in Python
Let's judge emotions using Emotion API in Python
Pre-process the index in Python using Solr's ScriptUpdateProcessor
Try using the collections module (ChainMap) of python3
Try using the Python web framework Tornado Part 2
Try implementing the Monte Carlo method in Python
Hit the Firebase Dynamic Links API in Python
Try accessing the YQL API directly from Python 3
Hit Mastodon's API in Python
Upload JPG file using Google Drive API in Python
Download the file in Python
[Unity (C #), Python] Try running Python code in Unity using IronPython
Find the difference in Python
[AWS IoT] Register things in AWS IoT using the AWS IoT Python SDK
Try using Kubernetes Client -Python-
Determine the threshold using the P tile method in python
Get LEAD data using Marketo's REST API in Python
Try LINE Notify in Python
Send and receive Gmail via the Gmail API using Python
Try to delete tweets in bulk using Twitter API
OpenVINO using Inference Engine Python API in PC environment
Try implementing Yubaba in Python 3
Blender Python API in Houdini (Python 3)
Call the API with python3.