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 specifications API Documentation
Kraken introduces implementation examples in each language API client example
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