-
Notifications
You must be signed in to change notification settings - Fork 8
EAPI:Invalid key #91
Comments
Hi, As for this part, it should work as this is the basic part. Can you share any code ? Thanks a lot in advance. |
I don't know what code to share. I've assembled a totally incomplete set of lines that cover the execution of a buy order. Never mind the "BTC" and "EUR" symbols; my app translates those to the actual symbols used on Kraken. Also I've tried both But actually I think that the problem can't be with What is
{
"api_key": "...",
"api_secret": "..."
} Trading: class Kraken(BaseExchange):
def __init__(self, keys=None):
self.kraky = KrakyApiClient(api_key=keys["api_key"], secret=keys["api_secret"])
def buy(self, base, quote, base_amount=True):
pair = base + quote
assert pair in self._pairs, f"pair {pair} not found"
print(f"buy {base}->{quote} ({pair})")
if base_amount == True:
base_amount = self.balance(base + ".HOLD") or self.balance(base)
# remote call here
self.kraky.add_standard_order(
pair=pair, type="buy", ordertype="market", volume=base_amount, validate=True
)
self.update_balances()
return True, {}
with open("keys_kraken_testaccount.json", "r") as f:
keys = json.load(f)
exchange = Kraken(keys)
trading = Trading(exchange)
trading.swap("BTC", "EUR") Because the question will come up, here are the permissions I've given the API key. I've even created a new key just to make sure. |
@yanone I've tested with that minimal amount of code: import json
from kraky import KrakyApiClient
with open("keys_kraken_testaccount.json", "r") as f:
keys = json.load(f)
kraky = KrakyApiClient(api_key=keys["api_key"], secret=keys["api_secret"])
print(kraky.get_web_sockets_token()) It works, I can get my websockets token which means that my apikey.secret are working. As for the permissions, it's maybe the "Export data" that needs to be checked. Finally, yes set_otp() is for 2FA which I don't use as well so I did not tested it but if you don't use it, it will not be activated. |
Thank you. Will report to Kraken and see what they say. I'll keep this issue open for now and close it once I have a response. Feel free to close it yourself any time. |
No problem, I will keep the issue open. |
The Kraken support replied:
They suggested I try their base implementation at https://github.com/veox/python3-krakenex, and lo and behold, it actually worked placing orders, using the exact same key that I was using for kraky. I know you said it worked on your side, but the evidence at hand suggests that there is indeed a problem with the signing procedure in kraky. I'll be happy to debug anything if you let me know what. |
@yanone It's strange indeed. I will send some funds to Kraken tonight and try to place an order. |
@yanone Indeed, some endpoints are working as intended like getting the balance or getting a websocket token but not the order. I need to investigate and push a fix. |
@yanone Can you see this issue ? veox/python3-krakenex#134 |
I read the issue, but I don't understand the proposed solution in veox/python3-krakenex#134 (comment), as I don't understand what he means by "can't have them as strings". A string, but not a string? Anyway, thanks for looking into this. |
As I understand, Kraken made some changes in the add_order function and it was working as well before for krakenex. |
@yanone I think this has to do with my functions allowing *args/**kwargs. I am working on fixing this as well as aligning the REST API/WS to the latest versions. It will be fixed today or tomorrow. |
@yanone I found the issue. You were indeed right about the signing issue. I took the encoding from Httpx and it's now working. You can test it in the version 2023.02.22 |
@yanone Kraken was in maintenance last night but now that it's online, I can confirm that it's working: I will therefore close this issue. Feel free to reopen if you encounter any issue on your side. |
Thank you so much. Excellent work! |
No problem, please let me know if you find others issues as I plan to push more things to align with Kraken's latest API and WS versions. |
Hi,
I'm implementing a Kraken adapter for my trading software using
kraky
. I'm new to Kraken.So I'm getting a
EAPI:Invalid key
response when I want to trade. I'm aware what that error message means from Kraken's side, and think that you probably implemented the signing correctly, but I'm not aware that I made any mistakes in handing the API key and secret over toKrakyApiClient()
.So I wanted to ask if you can remember any pitfalls when setting up a new Kraken account that could lead to this error, maybe in combination with
kraky
, before I ask at the Kraken support.Thank you.
The text was updated successfully, but these errors were encountered: