Git Product home page Git Product logo

python3-krakenex's Introduction

Latest Travis continuous integration build

Read latest documentation

Latest PyPI release

Development discussion at https://gitter.im/python3-krakenex/Lobby

krakenex

Kraken.com exchange REST API, Python 3 package.

This package is intentionally as lean as possible, and only provides a minimal interface to the Kraken cryptocurrency exchange.

Intended for developers, not traders.

Software that uses krakenex

Libraries

  • pykrakenapi - nicely wraps API methods into regular Python methods, and JSON responses into Pandas dataframes (available on PyPI!)
  • CurrencyViewer - short python3 framework for data extraction, conversion, and smooth development experience (available on PyPI!)

Clients

  • clikraken - command-line client for the Kraken exchange (available on PyPI!)
  • Telegram-Kraken-Bot - Telegram bot to trade on Kraken exchange

Documentation

View the latest or stable online at ReadTheDocs.

The code is documented in docstrings, and can be viewed with a text editor.

You can also generate your own with, e.g., make html in doc. This requires sphinx and its rtd theme.

For the most up-to-date list of public/private Kraken API methods, see their API documentation.

Examples

A few package use examples are available in the examples directory.

Installation

This package requires Python 3.3 or later. The module will be called krakenex.

A PyPI package is available.

For general use, there is only one direct dependency: requests.

This requires python-virtualenv and python-pip.

In a terminal:

For more information on virtualenv, see its documentation.

For the user

Using pip:

In general, use the distribution's package manager.

If it's unavailable, one can use pip:

Attribution

"Core" code is licensed under LGPLv3. See LICENSE.txt and LICENSE-GPLv3.txt.

Examples are licensed under the Simplified BSD license. See examples/LICENSE.txt.

Payward's PHP API, Alan McIntyre's BTC-e API, and ScriptProdigy's Cryptsy Python API were used as examples when writing the original python2-krakenex package. It was then ported to Python 3.

Development notes

Do not annoy the Kraken with tests

Some tests may be making queries to the Kraken API server.

If you intend to do development on this package, and have tests enabled on Travis CI, be sure to limit concurrent jobs to 1, and enable all possible auto-cancellations.

(Better yet, don't rely on public infrastructure, but run the tests locally first.)

No Python 2

This package will never support Python 2. There will be no changes made to enable compatibility with Python 2. Python 3.0 was released in 2008, before Bitcoin was.

There is no reason to support Python 2 except for compatibility with systems from the pre-blockchain era.

The fact that some GNU/Linux distributions still ship with Python 2 as the default seems unfortunate to me. However, I will not support this madness with my precious time.

If you have a valid reason to use Python 2, see python2-krakenex. Be warned, though, that it is unmaintained.

python3-krakenex's People

Contributors

austinderic avatar axelguilmin avatar endogen avatar gitter-badger avatar jona-sassenhagen avatar mallorymallory avatar moppymopperson avatar ricco386 avatar smechaab avatar tavin avatar veox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python3-krakenex's Issues

Conditional Close with different pairs

Versions

OS: Mac OSX
Python:  3
krakenex: 1.0.0

What are you trying to achieve?

Conditional close with 2 different pairs

k.query_private('AddOrder', {'pair': XXBTZUSD,
                             'type': 'buy',
                             'ordertype': 'limit',
                             'price': usdask,
                             'volume': volume[j],
                             'close[pair]': XXBTZEUR,
                             'close[type]': 'sell',
                             'close[ordertype]': 'limit',
                             'close[price]': eurask,
                             'close[volume]': volume[j] })

What do you expect to happen?

Order that buys btc in usd and sells in Euro

What happens instead?

Buys and sells both in USD

# error message
No error message

OSX: json.decoder.JSONDecodeError

Hey,

I'm new to the krakenex API, i'm trying to do the following

import krakenex
import time

class krakencom():
    def __init__(self):
        self.k = krakenex.API(key='abc',secret="def")

    def getEthEur(self):
        self.etheur = self.k.query_public('Ticker', {'pair': 'ETHEUR'})["result"]['XETHZEUR']
        return self.etheur

    def lowestPrice(self, cur):
        lowestPrice = cur['l']
        return lowestPrice

    def highestPrice(self, cur):
        highestPrice = cur['h']
        return highestPrice

    def volume24h(self, cur):
        volume24h = cur['v'][1]
        return volume24h

    def lastTrade(self, cur):
        lastTrade = cur['c']
        return lastTrade


krak = krakencom()
while True:
    eth = krak.getEthEur()
    print(krak.lastTrade(eth))
    time.sleep(0.5)

the out put is

[โ€˜RESULT', 'RESULT]

and after a while ERROR !!!?!
The error happens randomly from the second query

Traceback (most recent call last):
  File "/Users/MYUSER/MYDIR/MYPROJECT/krakapi.py", line 32, in <module>
    eth = krak.getEthEur()
  File "/Users/MYUSER/MYDIR/MYPROJECT/krakapi.py", line 10, in getEthEur
    self.etheur = self.k.query_public('Ticker', {'pair': 'ETHEUR'})["result"]['XETHZEUR']
  File "/usr/local/lib/python3.6/site-packages/krakenex/api.py", line 148, in query_public
    return self._query(urlpath, req, conn)
  File "/usr/local/lib/python3.6/site-packages/krakenex/api.py", line 131, in _query
    return json.loads(ret)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

i'm on OSX 10.11.6 python 3.6.1

many thanks

lj

Separate test(s) from examples

Currently, an example script with a query_public() is run.

The "build passing" badge is more of an integration indicator than anything else.

Test coverage badge would read ~50% ATM.

Unable to trade using a variable that contains the volume.

Versions

OS:       Windows
Python:   3
krakenex: v1.0.0a1

What are you trying to achieve?

Call the function to make an order, using a variable.

# code sample
value = .02

def single_quote(word):
    single_quote = "'" # single quote
    return single_quote + str(word) + single_quote

print (mykraken.query_private('AddOrder', {'pair': 'XETHZUSD', 'type': 'sell', 'ordertype': 'market', 'price': '20', 'volume': single_quote(value)}))

What do you expect to happen?

A market order to get placed, with parameters of a price of 20 and a volume of .02.

What happens instead?

I get an error message about the volume being an invalid argument.

# error message
{'error': ['EGeneral:Invalid arguments:volume']}

List of Commands

Could you print a list of available commands like below:

balance = k.query_private('Balance')
orders = k.query_private('OpenOrders')

specifically i'm looking for placing buys and sells

Permission denied for all private requests

Versions

OS:  Ubuntu 14.0
Python:   3.5
krakenex: latest

Hi all,
I'm not able to get my balance on Kraken. Here's how I do it.

    self.api_key = 'XXXX'
    self.api_secret = 'XXXXXX'
    conn = krakenex.Connection()
    self.api = krakenex.API(API_KEY, API_SECRET)
    orders = self.api.query_private('Balance')

I get the following: 'EGeneral:Permission denied'.

Any help would be greatly appreciated.

How to Connect ? username, password...

Hello Everyone,

Sorry to ask that, but i have a major Noob question : from a python script, using krakenex, How could you connect to your personal account?

OK there is k.load_key() but nowhere we have to input username, password etc etc.

I think this is a very dumb question but sorry, I've been searching for 1 hour and nothing...

Thanks a lot

Alex

OS:       Ubuntu 16.04 lrs
Python:   3.5
krakenex:  - 

What are you trying to achieve?

# code sample

What do you expect to happen?

What happens instead?

# error message

Take API call rate limit into account

The API docs have been updated in the last X years, now more verbosely specifying the allowed call rate.

This could be handled by krakenex, instead of off-loading to client implementations.

Not certain on exact interface to end-user yet.

Simplify connection handling (by using `requests`)

Current issues are now documented.

To "solve" them, can probably "just give up and use requests", and offload any network issues as "Not My Department".

Need answers:

  • Is having a dependency acceptable? (Yes. Otherwise, endless loop of NIH.)
    • So far, krakenex has had no dependencies other than the "standard library". requests is ubiquitous, though, and many distributions provide it as a system-level package, which handles dependencies of requests (urllib3 and chardet on my Arch system, with optional pysocks).
    • Building documentation requires sphinx, which has requests as a dependency.
  • Should a "unified" query() be introduced? (No. That can be done independently.)
    • How should it know if an API method is public or private? (See issue #40.)
      • May maintain a list for one of the two, and default to the other one if not in list; or maintain two lists, and refuse to query if in neither list.
      • Currently, the difference is that private methods need to set API-{Key,Sign} headers, and include a nonce in request data.
      • It seems that having a nonce is not enforced by Kraken for public queries.
    • What should its return format be? (JSON, as now.)
      • Whatever requests returns?
      • JSON, as currently output by query_{private,public}()?
  • Should the return format of query_{private,public}() remain the same? (Yes - for now, to remain backwards-compatible. Trivial - return request's .json() where appropriate.)
    • Maybe yes, if query() is not introduced, or to remain backwards-compatible.
    • Maybe no, if to be obsoleted or made private; then query() returns JSON, and these two a requests object, verbatim.
  • Should manual connection handling remain possible, or become hidden? (Yes. That's the whole point - give users a non-NIH way of customising the connection.)
    • requests handles Keep-Alive.
    • Allowing to set timeout (in Connection.__init__()) may become unnecessary.

Answers may depend on current/planned use cases.

How to set timeout?

Versions

OS: macOS 10.13.1
Python: 3.6.3
krakenex: 2.0.0c2

What are you trying to achieve?

Get a response from Kraken

kraken = krakenex.API()
kraken.load_key("kraken.key")

res_add_order = kraken.query_private("AddOrder", req_data)

What do you expect to happen?

Request should wait till response is returned

What happens instead?

I get no response

Connection persistence in _query function

Hi, forgive me if I'm getting this completely wrong, since I'm a novice programmer.

Within the _query function, a check is performed to see if there is a connection object available. If there isn't a new one is created.

if conn is None: if self.conn is None: conn = connection.Connection() else: conn = self.conn

The comments in the code state

If not provided, opens a new connection for this and all
subsequent queries.

However from looking at this code, it seems to me that the connection object would not be re-used for future queries, since it is being assigned to a local reference 'conn' which will be destroyed when the function exits. Therefore each time the function is called a new connection object is created?

Wouldn't the code be something like:
if conn is None: if self.conn is None: self.conn = connection.Connection() else: conn = self.conn

Problem with SSL on Mac OS X (Yosemite)

Hi,

I m trying to use the API but I got this issue when I call query public
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)

Can you help me ?

Thanks

'EAPI:Invalid nonce' when using python3-kraken concurrently (or around the same time) in different scripts

I'm starting to use python3-krakenex with a few concurrent scripts, which results in the 'EAPI:Invalid nonce' error fairly frequently, even when I made more API keypairs and implemented a supposed random fetch of one pair per invocation (so making it very unlikely the same one would be picked at the same time, although this clearly doesn't work properly).

The documentation doesn't talk about this, is there any guidance on how to 'scale up' use of python3-krakenex, perhaps somehow share the nonce state? I haven't looked into the implementation yet. Kraken threatens to ban endpoints that create a lot of invalid nonces (which hasn't happened to me yet), so I'm sheepish to fiddle around with settings on Kraken - the settings are locked currently, but I remember something about a nonce window - but I'm betting fiddling with that would not suddenly allow multiple users of a keypair like I want?

display API results and error messages

hi,
first of all thanks for the great job you did here.

Would there be a way to display the API results messages, more precisely the errors when running a script?
I have used the order-conditional-close.py with success, but some of my calls were wrong at first attempts, and it's pretty hard to debug without knowing what's wrong.

Is there a way to display what Kraken API gives as a feedback?

thanks

getaddrinfo failed

Hi,
When I run Depth.py I have this issue :
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

gaierror: [Errno 11004] getaddrinfo failed

I don't understand why....

socket.timeout Error Catching

Versions

OS: 10.12.6      
Python: 3.5
krakenex: 1.0.0a1

What are you trying to achieve?

Trying to catch a timeout error.

# code sample
except socket.timeout as e:
                print("Kraken Socket Timeout Error")
                print(e)

What do you expect to happen?

Expected error to be caught. I believe this is a naive error on my part -- just looking for the proper way to handle.

What happens instead?

I receive the below error message.

# error message
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
    except socket.timeout as e:
NameError: name 'socket' is not defined

Consider keeping built docs in `docs`

Github Pages has an option to read docs from docs dir instead of gh-pages branch.

Keeping doc skeleton in docs-src and building moving built HTML to docs would simplify updating documentation.

misc: test github's issue template

Versions

OS:       Arch Linux, last updated 2017-07-25
Python:   3.6
krakenex: 1.0.0alpha1

What are you trying to achieve?

Would like people stop treating issues like a helpdesk, where I must guess everything that's wrong for them, including system misconfiguration, networking issues, impl-n bugs...

# code sample
return False

What do you expect to happen?

People will at least start using markdown code blocks, and do report versions.

What happens instead?

Probably they'll wipe the template and do it their way.

# error message
Can't flip `table`: object immutable.

OHLC intervals

Hi,

How do I change the default interval of OHLC from 1 to 60?

thanks,

Consider packaging on PyPI

Hi,

I'm the developer of clikraken, and I depend on your library to interact with the Kraken API. However you don't provide a package on PyPI, which makes it harder to use it as a dependency in other projects such as mine.

Would you consider packaging it for PyPI? If not, I'm proposing to package it for you and upload it on PyPI myself. Just don't want to step on your toes in case you planned to do it sometime.

Thanks a lot for this library!

Depth function not returning asks or bids sometimes.

This example code you provided. Will occasionally return an object like this

{'error': [], 'result': {'XETHXXBT': {'bids': [], 'asks': [['0.090513', '0.747', 1496336370], ['0.090519', '15.146', 1496336378]]}}}

When asking for a depth of 4. In other words I am 6 orders short. I got no bids... Is there a more consistent order book function I am missing? Why might this be happening?


EDIT: link to commit where Depth.py is still present.

Review license

LGPLv3 references GPLv3, but that's not in the repo.

Provide for Mallory.

`TradesHistory` example script not working out-of-the-box

Hi,
I tried out this code as it is until line 45 as a test. Unfortunately my only output is:
{'error': [], 'result': {'trades': {}, 'count': 0}}
Same results when I am going to change the year to 2017 and the change in line 38 to:
end_date = datetime.datetime(2017, i+2, 28)
Does anyone have a solution?
Thank you a lot in advance!
Best regards.

What are the asset pair names?

Do you have a list of the asset pair names you could post in the readme?
Is there a link you could give me to find a list that already exists?
If you are wondering what I am looking for the 'pair' parameter is what I am inquiring about. As in this example:

print(k.query_public('Depth',{'pair': 'XXBTZUSD', 'count': '10'}))

I know of the following but it just gives a huge blurb.

print(k.query_public('AssetPairs'))

For instance I want to know what Litecoin to Bitcoin pair name would be.

Permission denied for all private requests with 2FA

Versions

OS:       Archlinux
Python:   3.6.2
krakenex: installed using pip

Hi all,
I'm not able to get my balance on Kraken. I think the problem is related to the 2FA. Here's how I do it.

kraken = krakenex.API(apiKey,apiPassword)
totp = pyotp.TOTP(password2FA)
r = kraken.query_private("TradeBalance",{"otp": totp.now()})

I get the following: 'EGeneral:Permission denied'.

Any help would be greatly appreciated.

Support Conda installation

Versions

OS:       
Python:   
krakenex: 0.1.4

What are you trying to achieve?

Try to perform basic balance checking in the examples
https://github.com/veox/python3-krakenex/blob/master/examples/print-account-balance.py

# code sample

import krakenex

k = krakenex.API()

# next raw comment line added by veox

What do you expect to happen?

I expect it to show the balance

What happens instead?

It doesnt run , i believe this is because of the version installed doesnt have the API yet ?

# error message
Traceback (most recent call last):
  File "krakenex.py", line 1, in <module>
    import krakenex
  File "/Users/kashingcheung/Desktop/Coursera/AnacondaProjects/Kraken/krakenex.py", line 3, in <module>
    k = krakenex.API()
AttributeError: module 'krakenex' has no attribute 'API'

Resetting krakenex connection

Versions

OS: Windows
Python: 3.6.2
krakenex: v1.0.0c1

What are you trying to achieve?

Close an open connection after timeout

# code sample
def query_order(k, txid):

		options = {'txid':''}
		options['txid'] = txid
		
		try:
			print ("querying open orders")
			values = k.query_private('QueryOrders',options)
			print ("result")
			print (values)
			return values
		except:
			print ("query_pair: Unexpected error:", sys.exc_info()[0])
			# probably a timeout, sleep 60 seconds and try again
			k.conn = None
			time.sleep(60)		
		
		return None

What do you expect to happen?

I would like to close/reset the krakenex connection. Since I am running a lot in some sort of endless loop of timeouts, which, miraculously always get resorted after I restart my code.
Now I thought the k.conn = None would sort that issue.
It does, kind of, it creates a new connection and the timeout issue disappears.
However if the bot runs long enough, which now happened after 16h, the shell had so many instances that I was getting socket errors until I closed the entire shell and started in a fresh shell.
My best attempt was k.conn.close() but the below code returns:

# code sample
k.query_public('Ticker',dict([('pair', 'XXBTZEUR')]))
print (k.conn)
k.conn.close()
print (k.conn)
k.query_public('Ticker',dict([('pair', 'XXBTZEUR')]))
print (k.conn)
# message
<krakenex.connection.Connection object at 0x036607B0>
<krakenex.connection.Connection object at 0x036607B0>
<krakenex.connection.Connection object at 0x036607B0>

I don't know, is it really creating a new connection at the next query? if I use my shitty k.conn = None method I get a new memory imprint.

No idea how to handle those infinite timeouts, or well, reset krakenex connection without creating a dead instance.

Using krakenex with a proxy/ behind a proxy

Currently krakenex will not work with a proxy/behind a proxy without code change cause it's https requests are based on http.client and urllib.

Best would be to have it based on requests. There the system/OS proxy settings are automatically used.

What I did for krakenex was to change the connection.py. With a proxy at : myserver:1111 it has to be changed from
self.conn = http.client.HTTPSConnection(uri, timeout = timeout)

to

self.conn = http.client.HTTPSConnection("myserver:1111", timeout = timeout)
self.conn.set_tunnel(uri)

Add order with leverage result in error, but order still get through.

Using query_private with leverage result in error, but somehow kraken still accept the order.

using Windows 10, with python 3.6.

The code :

## Test open long posiition
print(k.query_private('AddOrder',
                {'pair': 'USDTUSD',
                 'type': 'buy',
                 'ordertype': 'market',
                 'volume': '5',
                 'leverage': '2'}))

The order in kraken
image

Error massage :

# error message
---------------------------------------------------------------------------
timeout                                   Traceback (most recent call last)
<ipython-input-12-b2fec10e7464> in <module>()
      5                  'ordertype': 'market',
      6                  'volume': '5',
----> 7                  'leverage': '2'}))

D:\Anaconda3\lib\site-packages\krakenex\api.py in query_private(self, method, req, conn)
    180         }
    181 
--> 182         return self._query(urlpath, req, conn, headers)

D:\Anaconda3\lib\site-packages\krakenex\api.py in _query(self, urlpath, req, conn, headers)
    128                 conn = self.conn
    129 
--> 130         ret = conn._request(url, req, headers)
    131         return json.loads(ret)
    132 

D:\Anaconda3\lib\site-packages\krakenex\connection.py in _request(self, url, req, headers)
     77 
     78         self.conn.request('POST', url, data, headers)
---> 79         response = self.conn.getresponse()
     80 
     81         return response.read().decode()

D:\Anaconda3\lib\http\client.py in getresponse(self)
   1329         try:
   1330             try:
-> 1331                 response.begin()
   1332             except ConnectionError:
   1333                 self.close()

D:\Anaconda3\lib\http\client.py in begin(self)
    295         # read until we get a non-100 response
    296         while True:
--> 297             version, status, reason = self._read_status()
    298             if status != CONTINUE:
    299                 break

D:\Anaconda3\lib\http\client.py in _read_status(self)
    256 
    257     def _read_status(self):
--> 258         line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    259         if len(line) > _MAXLINE:
    260             raise LineTooLong("status line")

D:\Anaconda3\lib\socket.py in readinto(self, b)
    584         while True:
    585             try:
--> 586                 return self._sock.recv_into(b)
    587             except timeout:
    588                 self._timeout_occurred = True

D:\Anaconda3\lib\ssl.py in recv_into(self, buffer, nbytes, flags)
   1000                   "non-zero flags not allowed in calls to recv_into() on %s" %
   1001                   self.__class__)
-> 1002             return self.read(nbytes, buffer)
   1003         else:
   1004             return socket.recv_into(self, buffer, nbytes, flags)

D:\Anaconda3\lib\ssl.py in read(self, len, buffer)
    863             raise ValueError("Read on closed or unwrapped SSL socket.")
    864         try:
--> 865             return self._sslobj.read(len, buffer)
    866         except SSLError as x:
    867             if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:

D:\Anaconda3\lib\ssl.py in read(self, len, buffer)
    623         """
    624         if buffer is not None:
--> 625             v = self._sslobj.read(len, buffer)
    626         else:
    627             v = self._sslobj.read(len)

timeout: The read operation timed out

Here the python notebook attached
https://drive.google.com/file/d/0BxSBFRJpBUpYX0MyNG51TGpLVzg/view?usp=sharing

import krakenex ImportError: No module named krakenex

Versions

OS:       OSX Sierra
Python:   3.5
krakenex: 

What are you trying to achieve?

I'm trying to import krakenex and run it with cmd + b in Sublime Text on OSX.

# code sample

What do you expect to happen?

I expect to be able to run the example open-positions.py

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 yesterday, installed Anaconda today, and I have very little experience with APIs.

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]

Help much appreciated.

# error message

Unable to retrieve private information

Hi All,

Hope you are doing great. I was able to use query_private to retrieve 'Balance', and 'Add Orders'.

And for some reason, it wouldn't work anymore. Although I make sure all my keys are right, the system return {'error': ['EAPI:Invalid key']}, or {'error': ['EGeneral:Temporary Lockout']} after like 3 attempts. It was working in the morning and it doesn't anymore. It will be very much appreciated if anyone could spare a hand.

Thank you

Best,
Wolf

api return "Request-sent" after a "read operation timed out"

Hello,
When i cancel an order then there are a read operation timed out api not return result or error but the message "Request-sent" when i try to cancel again the order :(
Does it s normal ?
How can i know my order has been cancelled or if it s in pending ?
I m using python3 and the pip version of krakenex.
Thanks for your answer.

Exception Request-sent after 504

Hello, I handle the exception when a 504 error occur.

But I cannot make any request after a 504 error.
I have a "Request-sent" exception ? Where did this come from ?

Thanks !

Adding the 'since: 0' parameter to the `query_public` function doesn't give any additional data

Versions

OS:  Mac OS 10.12.6 Sierra
Python:   3.6.2
krakenex: 0.1.4

What are you trying to achieve?

I am trying to pull the entire historic data of all OHCL using the query_public keyword, to get all the trades from the beginning of time:

# code sample
tmp = self.apiKraken.query_public("OHLC", 
			{
			    "pair": "XETHXXBT",
			    "since": "100"
			})

What do you expect to happen?

I expect to get the entire OHCL data from the beginning of time.

What happens instead?

I get the same OHCL data as if I would not try to add the 'since' parameter. In short, the result is equivalent to

tmp = self.apiKraken.query_public("OHLC", 
			{
			    "pair": "XETHXXBT",
			})

such that only a frame of the newest 700 samples is returned

# error message
I don't get an error message - This is a semantic error; From kraken's side, this should usually work.

Don't use mutables as argument defaults in functions

https://github.com/veox/python3-krakenex/blob/master/krakenex/api.py#L151
When defining functions like this def query_private(self, method, req={}, conn = None): you share a single instance of the req dictionary for every call that uses the default of req.

def fn(x={}):
    return x

call1 = fn()
print(call1)
call1["a"] = "A"
call2 = fn()
print(call2)
print (call1 == call2)

If you want a fresh instance of an dictionary on every call of the function I suggest something like this.

def fn(x=None):
    if x is None:
        x = {}

Nevertheless I don't see a concrete problem raised by this in your code.

Implement a recovery mechanism for failed http requests

krakenex: 2.0.0rc2

What are you trying to achieve?

During peak times large amount of http requests are failing without a specific response from Kraken server. These are intermittent problems with CloudFlare/Kraken and for some of returned http codes it should be safe to retry an operation. As each request has a unique nonce which is checked on a server, it should prevent execution of several identical requests if they get to a server despite a failed status_code.

Max number of retries should be configurable


EDITed by @veox:

Pull requests with the suggested change: #65 #99 #100

pip3 for python3?

Hi, I'm new to python and struggled following the installations. I figured out though, that using pip3 install krakenex instead of pip ... worked out. Is this normal? Has the readme to be edited?
Thanks :-)

Order book data on all currencies in one query

Versions

OS: Windows 7       
Python:  3.1
krakenex: 3

What are you trying to achieve?

Get order book information for ALL coins.

k.query_public('Depth', {'pair': ','.join(coin_order_list)})

What do you expect to happen?

To get order book information for ALL coins.

What happens instead?

I get an error message.

{u'error': [u'EQuery:Unknown asset pair']}

Could you please let me know if there is a way to get order book data on all currencies using one query.
Thank you in advance!

Loop issues

I run this code in a loop to constantly scan for opportunities with my bot. 90% of the time after 5 min my code ends in an error like this:

File "tradeKraken.py", line 34, in
balances = k.query_private('Balance')
File "/usr/local/var/pyenv/versions/3.4.3/bin/krakenex/api.py", line 122, in query_private
return self._query(urlpath, req, conn, headers)
File "/usr/local/var/pyenv/versions/3.4.3/bin/krakenex/api.py", line 83, in _query
return json.loads(ret)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

any ideas?

Needs more examples

Has been brought up on Twitter. Requester failed to follow up with examples of what needs examples.

If you think something would make a good example, drop a comment (or PR).

Help Getting History Data

Versions

OS:       
Python: 3.6
krakenex: 0.1.4

What are you trying to achieve?

I want to create a function returning a dataframe with all prices history for a list of pairs,
For example all closing prices between 2015 and 2017 for BTCUSD and ETHEUR.

1st Step is to know how to download history with dates. as parameters.

# code sample
k = krakenex.API()
k.load_key('kraken.key.txt')
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'}) #here I want to add parameters to ask for a #specific dates or period. 
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )

What do you expect to happen?

#I have found this : 
th = k.query_private('TradesHistory', req(start_date, end_date, 1))
#I would like to transpose it not with tradeshistory but just ticker and dates but doing this : 
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )
# does not work

What happens instead?

ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )
error: AttributeError: 'dict' object has no attribute '_request'

# Output of the line : 
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'})
# Am I supposed to get this : 'error': [],
# Output : 
{'error': [],
 'result': {'XXBTZUSD': {'a': ['4307.30000', '1', '1.000'],
   'b': ['4305.60000', '3', '3.000'],
   'c': ['4305.50000', '0.03977220'],
   'h': ['4399.00000', '4399.00000'],
   'l': ['4211.10000', '4180.10000'],
   'o': '4226.20000',
   'p': ['4306.30564', '4281.68920'],
   't': [8134, 13490],
   'v': ['2470.05812705', '3969.08612297']}}}

Python methods for corresponding Kraken API methods

I think it would make things a lot easier if one could call API methods directly from an API() instance in Python rather than putting out using query_public() or query_private() each time. Having python methods would also help with code completion.

Has there been a decision to not include individual python methods for each API method?
If this is not the case, are there any plans to implement corresponding python methods anytime soon?

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.