LabZoneSK / stop-loss-bot

Trading bot to place order when price is bellow target for Kraken exchange.
MIT License
24 stars 6 forks source link

Better error handling #4

Closed martin-starosta closed 7 years ago

martin-starosta commented 7 years ago

Kraken respond many times with "TIMEOUT" error. Need to handle better.

hariseldon78 commented 7 years ago

I am thinking about a process like this (for market orders, not limit): 1) insert the order, with a user reference id 2) wait 5 or 10 seconds, to give time to fill the order 3) download closed orders: if it's present and closed without error -> resolve() 4) wait a second 5) download open orders: if it's present and without errors just go back to point 2 6) the order has not been received from kraken, so we need to reinsert it. go back to point 1, (strange, but i think it could happen) maybe using the same user reference id and i hope this prevents duplication (this need to be tested)

hariseldon78 commented 7 years ago

to solve the timeout problem i've found this: https://github.com/nothingisdead/npm-kraken-api/pull/28/commits/ca939e6dd6c6cd9d3ca9a6ee52dc2170a8d25978 the KrakenClient can be created with an options parameter to configure the maximum timeout. The default is 5 seconds, maybe raising it to 30 or even more should solve the problem. When the library gives timeout the request still could be received from kraken, leading to the risk of placing duplicate orders.

martin-starosta commented 7 years ago

Thank you! I will try to increase timeout and we will see what will happen.

martin-starosta commented 7 years ago

Timeout can be configured with .env