python3-krakenex | REST Exchange API for Kraken.com , Python | REST library
kandi X-RAY | python3-krakenex Summary
kandi X-RAY | python3-krakenex Summary
REST Exchange API for Kraken.com, Python 3
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Queries the API
- Make a POST request
- Create a signature for the given data
- Generate a nonce
- Query public method
- Load key from file
- Print a line of text
- Set the JSON options for this request
- Get trades
- Convert date to datetime
- Convert a nix timestamp to a string
- Return current time
- Returns the contents of a file
python3-krakenex Key Features
python3-krakenex Examples and Code Snippets
a = {x for x in assets if assets[x].get('wsname') == 'XBT/USD'}
a = []
for x in assets:
try:
if x['wsname']:
a.append(x)
except KeyError:
pass
except KeyError as error_info:
print(error_info)
import time
import krakenex
import pandas as pd
from pykrakenapi import KrakenAPI
api = krakenex.API()
k = KrakenAPI(api)
# Initial OHLC dataframe
df, last = k.get_ohlc_data("BCHUSD", ascending=True)
# Infinite loop for additional OHLC
>>> trades = api.query_public("Trades", {'pair': 'XBTUSD', 'since': 1546300800000000000, 'ascending': True})
>>> print(trades)
{'error': [], 'result': {'XXBTZUSD': [['3690.90000', '0.00400000', 1546300800.4732, 's', 'l',
import krakenex
from pprint import pprint
k = krakenex.API()
pprint(k.query_public('OHLC', {'pair':'XXBTZUSD', 'interval':1440, 'since':1214011560}))
Community Discussions
Trending Discussions on python3-krakenex
QUESTION
I tried making a simple function which makes a HTTP request to Kraken exchange API. The method is private, I am trying to fetch my account balance.
According to Kraken documentation (https://www.kraken.com/features/api#general-usage):
HTTP header:
API-Key = API key
API-Sign = Message signature using HMAC-SHA512 of (URI path + SHA256(nonce + POST data)) and base64 decoded secret API key
POST data:
nonce = always increasing unsigned 64 bit integer
otp = two-factor password (if two-factor enabled, otherwise not required)
I tried to make my signature generation similar to the "veox" Python library (available at: https://github.com/veox/python3-krakenex/blob/master/krakenex/api.py).
I am using Python 3.6.7 on Ubuntu 18.04.
2FA (otp) is turned on for my account on Kraken exchange, though I am not sure if I need to include in the request.
I searched stack overflow for the solution, but I can't seem to get anything from the posts available. (Please keep in mind I'm fairly new to Python and Stack Overflow)
I get 200 response from the server so I am pretty sure the problem is in generating the signature.
Here is my code (xxx, yyy and zzz variables are purposefully written like that):
...ANSWER
Answered 2019-Feb-25 at 23:49So I figured out why my code was not working.
Short answer:- POST data used in the Kraken API call has to be URL encoded. That means that "nonce" and "otp" have to be URL encoded for the API to work properly. I used "urllib.parse.urlencode" method from the "urllib" module to get API to work properly.
- Header values have to explicitly be called the same names as in the Kraken API manual.
- This may be because I am a beginner in coding API's, but Kraken API manual does not explicitly state that POST data has to be URL encoded. OTP (2 factor authentication) did not affect my code in this case so I got rid of that part of the POST data in the call.
In my case, the only POST data I used was the "nonce" value. So for example, if in the above code nonce was equal to
QUESTION
OS: OSX Sierra
Python: 3.5
I'm trying to import krakenex and run it with cmd + b in Sublime Text 3 on OSX.
What do I expect to happen?I expect to be able to run the example open-positions.py (or any other).
What happens instead?When pressing cmd + b, I get
"import krakenex
ImportError: No module named krakenex"
If I create a new file that just says "print 'hello world'" and then press cmd + b, it does print 'hello world'.
However, krakenex is not imported when I press cmd + b within open-positions.py.
The problem is probably very basic. I learned python the day before yesterday, installed Anaconda yesterday, and I have very little experience with APIs. Apologies for the incompetence.
I downloaded the zip file from https://github.com/veox/python3-krakenex/, extracted it, then ran
python3 setup.py install
within that extracted directory.
I then opened that whole extracted folder with Sublime Text 3.
Then, within open-positions.py, if I press cmd + b, I get said error message.
The full output is
raceback (most recent call last): File "/Users/Norbert/Downloads/python3-krakenex-master/examples/open-positions.py", line 1, in import krakenex ImportError: No module named krakenex [Finished in 0.1s with exit code 1] [shell_cmd: "python" -u "/Users/Norbert/Downloads/python3-krakenex-master/examples/open-positions.py"] [dir: /Users/Norbert/Downloads/python3-krakenex-master/examples] [path: /usr/bin:/bin:/usr/sbin:/sbin]
Much appreciated.
...ANSWER
Answered 2017-Jul-30 at 21:42If I create a new file that just says
print 'hello world'
and then press cmd + b, it does printhello world
.
Here is your problem. See, your program is written in Python 2. Had you run it in Python 3, it would say SyntaxError: Missing parentheses in call to 'print'
.
You've installed that module into your python3 and are running python2 from ST3.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python3-krakenex
You can use python3-krakenex like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page