Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Kraken support #177

Closed
Alexandre-io opened this issue May 22, 2017 · 34 comments
Closed

Kraken support #177

Alexandre-io opened this issue May 22, 2017 · 34 comments

Comments

@Alexandre-io
Copy link
Contributor

Hi,

Could is it possible to re-add the support of kraken in v.4 ?

Thanks!

@nibzo1
Copy link

nibzo1 commented May 23, 2017

I would also like this, I had a go at making it work by following GADX setup but got lost with some of the underlying functions I would have to implement.

Any advice on what we could do to get this working

@DeviaVir
Copy link
Owner

@nibzo1 I think there are a lot of lessons in this PR: #162

@nibzo1
Copy link

nibzo1 commented May 23, 2017

nice one, Ill have a look at this and see what I can pull from it. Hopefully I can get some minutes to try and move forward

@Alexandre-io
Copy link
Contributor Author

@nibzo1 You can found the older version here: https://github.com/carlos8f/zenbot/tree/3.6/plugins/kraken

@royteeuwen
Copy link

Would really look forward to this too!

@Alexandre-io
Copy link
Contributor Author

I have created the extension by reading the documentation but I don't have the time to test it right now. If someone have the time to review ( @carlos8f ? ):
Alexandre-io@586bb69

@nibzo1
Copy link

nibzo1 commented May 27, 2017

@Alexandre-io the code looks sound, I've tested and It start without error but backfill appears not to work. It just resorts to the console with

Download complete

@nibzo1
Copy link

nibzo1 commented May 27, 2017

So after some further debugging I can see that about 1000 trades downloads. The getTrades() executes but no data is picked up in the mongodb or by the zenbot sim command

@nibzo1
Copy link

nibzo1 commented May 27, 2017

@Alexandre-io tested further and I fixed a variable or two for you. Alexandre-io@2a28d62

With these fixes the bot will start trading but there is some data missing in the log output. Looks like something is still missing.

@Alexandre-io
Copy link
Contributor Author

@nibzo1 thanks! My last commit fix the backfill & sim but I don't know if the "since" parameter of the kraken api is a timestamp or just an id.

@fooness
Copy link

fooness commented May 27, 2017

@Alexandre-io & @nibzo1 Thank you very much for looking into this!

@crubb
Copy link
Contributor

crubb commented May 28, 2017

@Alexandre-io according to the documentation "since" seems to be an ID: https://www.kraken.com/help/api

@nibzo1
Copy link

nibzo1 commented May 28, 2017

@Alexandre-io cool Ive taken your latest commit and sim & backfill appear to work now. I have kicked it off to trade now. Lest see what happens

So after some time of running my balance changed due to other trades outside of the zenbot trading pair. Looks like something is NULL. Ill add some debug and see it I can find out what it is,.

2017-05-28 14:58:18  147.15 XETH-ZEUR   -2.1%     4894      +      -0.2028           0.00 XETH  176.58 ZEUR   -52.2%  -51.2%
getBalance error:
undefined
Kraken API is down! unable to call getBalance, retrying in 10s

also

Kraken API is down! unable to call trade, retrying in 10s

@crubb
Copy link
Contributor

crubb commented May 28, 2017

@nibzo1: Same for me!

@Alexandre-io
Copy link
Contributor Author

@nibzo1 @crubb the kraken api is not stable, the retry should do the job.

@crubb
Copy link
Contributor

crubb commented May 28, 2017

@Alexandre-io not a single trade went through for me, though

@Alexandre-io
Copy link
Contributor Author

@crubb could you try my last commit plz ?

@crubb
Copy link
Contributor

crubb commented May 28, 2017

@Alexandre-io Argh, I sent you a PR Alexandre-io#2 just 5 minutes later ;)

@Alexandre-io
Copy link
Contributor Author

@crubb thanks! but where did you found the "trading_agreement" parameter ? I'm unable to found it in : https://www.kraken.com/help/api#add-standard-order

@crubb
Copy link
Contributor

crubb commented May 28, 2017 via email

@nibzo1
Copy link

nibzo1 commented May 28, 2017

@Alexandre-io @crubb just seeing the changes you guys have added good job 👍

I have pulled and kicked the bot off again. Will report back

@crubb
Copy link
Contributor

crubb commented May 28, 2017

@nibzo1: There are problems on getOrder as well, live trading won't work, yet

@nibzo1
Copy link

nibzo1 commented May 28, 2017

Thanks for the heads up

My bot had also hit the Kraken rate limit, not sure what API calls were triggering this because there is generally a good bit of head room.

@crubb
Copy link
Contributor

crubb commented May 28, 2017

Currently the client is just retrying the API call, when it fails and then hitting the rate limit. It is assuming that the API was not reachable. But actually the Kraken API is reporting proper real errors, which the client is so far ignoring. I just removed all retries in my local code and I'm debugging further.

@nibzo1
Copy link

nibzo1 commented May 28, 2017

Appreciate the update thanks, I wont get a chance to look at this until tomorrow now

@crubb
Copy link
Contributor

crubb commented May 29, 2017

Yo, buying and selling now works with the latest PR Alexandre-io#4. Now the problem is, that when an order is not filled quickly enough, checkOrder is getting called so often, that I frequently run into the Kraken API rate limit.

From https://github.com/carlos8f/zenbot/blob/2444a9e6c77eb78f2d640d41efbfd23522116e7f/lib/engine.js I gather that checkOrder should only be called every order_poll_time (which I left at the default of 5000 ms), but it is getting called way more often.

Any ideas?

@Alexandre-io
Copy link
Contributor Author

Here is the PR for kraken :)

@crubb
Copy link
Contributor

crubb commented May 31, 2017

Yeah!

I just found another small problem with orders, which are rejected by Kraken as Post only order. Polo and GDax reject them instantly on AddOrder (that's where the engine.js logic catches them). Kraken accepts them and then instantly cancels them. I added some logic (no PR, yet), but so far I was not successful on forcing a 'post only' reject to happen. Any suggestions?

@royteeuwen
Copy link

How can this be solved if the kraken api error still occurs?
Kraken API error - unable to call getTrades (Error: Kraken API returned error: API:Rate limit exceeded), retrying in 10s

@DeviaVir
Copy link
Owner

DeviaVir commented Jun 3, 2017

@royteeuwen probably not the answer you want to hear, but there's a pretty clever retry logic that tries to deal with this in the way that it's supposed to be dealt with.

That is the retrying in 10s that you see there. Technically there is nothing else we can do about that right now. If I'm wrong, please PR a fix- be happy to merge it.

@royteeuwen
Copy link

Well no for me thats fine, the only thing I would change then is the actual output that it doesn't log it as an error? Now it looks to be broken when using it, while you state it's made like that by design

screen shot 2017-06-03 at 12 49 55

Also the output of the sim seems to gotten messed up, see second screenshot

screen shot 2017-06-03 at 12 50 36

@DeviaVir
Copy link
Owner

DeviaVir commented Jun 3, 2017

@royteeuwen heh. that does end up a bit of a mess.

@crubb @Alexandre-io @nibzo1 any thoughts on how to resolve this, should we add a verbose option and hide this kind of information underneath that?

@crubb
Copy link
Contributor

crubb commented Jun 3, 2017

Hey

a) there seems to be a rate limit on the public API for backfilling, which is not documented. I will push a Pull Request with a "quick & dirty" rate limiting for backfilling. --> #217
b) Are the line breaks that ugly with sim of e.g. GDax as well, or only Kraken? Is that a docker issue? I mean the sim is not printing any error and that's the only place where the Kraken extension is writing something to the console itself.

@tuxitor
Copy link
Contributor

tuxitor commented Jun 3, 2017

Unix line termination is an LF, while Windows uses CRLF. That means line output from a NIX program could on certain occations could be shown like the example in a windows environment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants