Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to exit trade [pair here], kucoin Order size exceeded the limit #7924

Closed
hippocritical opened this issue Dec 20, 2022 · 6 comments
Closed
Labels
Triage Needed Issues yet to verify

Comments

@hippocritical
Copy link
Contributor

Describe your environment

Docker, 2022.11

Describe the problem:

Kucoin only accepts a certain value for its' orders and blocks everything that is above that arbitrary order volume limit.

Steps to reproduce:

  1. go live with way too much money for this market and DCA
  2. exceed the quantity of a single order inside a certain pair on kucoin
  3. try to exit with one chunk
  4. get error messages of the exchange while freqtrade hammers the exit request again and again.
  5. pray to the gods that the market doesnt crash in the meantime.

Observed Results:

  • What happened?
    the bot bought deep into its' DCA stack and had a "relatively" giant order (nothing outworldly, seriously...) but kucoin still denied the exit order. as seen in the provided logs.
  • What did you expect to happen?
    if the exchange does not allow a big order in one piece, make smaller chunks (so the error does not deny the order anymore).
    Solution1:
    Do n parallel exit orders, lower the order size incrementally until one order works. Then repeat until all money is caught up in a limit or market order. (we already can do partial exits so this "might" be possible?)
    Solution2:
    Put up a smaller exit order that does not error out and then instantly fire the next one if this is no partial exit originally.

Relevant code exceptions or logs

These lines repeat over and over:
2022-12-20 21:23:26 - freqtrade.freqtradebot - WARNING - Unable to exit trade SOS/USDT: Could not place sell order due to BadRequest. Message: kucoin Order size exceeded the limit.
2022-12-20 21:23:29 - freqtrade.freqtradebot - INFO - Exit for SOS/USDT detected. Reason: roi
2022-12-20 21:23:29 - freqtrade.wallets - INFO - Wallets synced.

@hippocritical hippocritical added the Triage Needed Issues yet to verify label Dec 20, 2022
@xmatthias
Copy link
Member

at first glance - the strategy did scale in - why not scale out?


If you're not allowed to exit a trade in one go - then this will mess up the whole risk management completely.

It'll mean that a stoploss is effectively meaningless - if we need to retry exiting over and over until it works, price could've dropped from the intended 10% stoploss to 50% loss or more (especially considering that such orders may or may not fill, depending on their size) - and this is a problem you'll almost exclusively encounter on shit-coin markets.

The right approach in my opinion is therefore be to reject further DCA entries if the maximum has been reached.

based on the numbers, the maximum exit allowed at once is around ~2500$ (10_000_000_000 SOS) for this pair (a little less depending on price) - so i think we would have the correct numbers available (unless you tell me the actual numbers were different / a lot lower) - they're just not checked when doing further entries.

@hippocritical
Copy link
Contributor Author

hippocritical commented Dec 21, 2022

at first glance - the strategy did scale in - why not scale out?
yes you are right, it has no scaling out since this is the config I ran for 8 months dry already to test out. Partial exits did not exit back then.
I rather have continuous data than quick fixes, so this strat is gonna stay a while like that.

If you're not allowed to exit a trade in one go - then this will mess up the whole risk management completely.
yes that s why I would prefer parallel exit orders if the singular one does not work. But I don't know if this is even possible.
if you can't sell with a size of x then you have to do x/2 until the order

based on the numbers, the maximum exit allowed at once is around ~2500$ (10_000_000_000 SOS) for this pair (a little less depending on price)
Yes it was slightly over 2.5k$

The right approach in my opinion is therefore be to reject further DCA entries if the maximum has been reached.
no this would be the wrong approach since only if the exchange doesn't allow it that doesn't mean anyone would ever use any entry or exit size beyond their (Exchange, Kucoin in this case) arbitrary limits.
The only solution would be to either make parallel exits or sequential ones (based on if you were to limit-order enter / exit)
Your solution would block anyone with more than play size of money which is kinda not a solution.

Imagine a world in that SOS drops to 10% once again and kucoin does not react rising their transaction limits.
If that happens then freqtrade would refuse to trade anything above 250$

edit: why not exit order pyramiding? i.e. shoving multiple exit orders down the exchanges' throat at the same time

@xmatthias
Copy link
Member

xmatthias commented Dec 22, 2022

If we're realistic - then the only reliable information we get from the exchange is "can't create order" (not why).

The reason is nested in text / response (which can change with API updates, and will be different by exchange).
So the error "Order size exceeded" will look just the same than "Order size too small" and "not enough to sell" (all just raise the same exception type). The text within the exception (Order size exceeded the limit) is something the exchange responds with - and i therefore see as not reliable.

this makes your proposed solution near impossible to maintain reliably - and even if we'd be going down that route - it'd be for supported exchanges with reliable API's - which Kucoin is (as sorry as i am about this) not one of (due to their api instability).

On top of that, we're currently only keeping track of 1 order (and an additional stoploss order).
so even if we'd see this as something that we'd want (i don't think we do based on current info) - it's something that won't be happening anytime soon (it falls roughly into the same category as #7499).
We'd however not want it to cause "can't exit" - therefore at least short term - the solution will be the limit of further entries.

Please provide me with the full exception logs (before the above method there should be stacktraces - or at least other errors / messages which identify where the error actually came from (this will not be the only/first message about this).

@xmatthias
Copy link
Member

xmatthias commented Dec 22, 2022

Imagine a world in that SOS drops to 10% once again and kucoin does not react rising their transaction limits.
If that happens then freqtrade would refuse to trade anything above 250$

the same is true in the opposite direction - if you're on a low end trade (15$ or so) - and the minimum limit get's raised as the coin had a huge run - then it's the same exact situation - and can't (automatically) sell the position anymore.

limit changes is something that's out of our control - and we don't WANT to make the decision for the user to "buy more to sell all" - as depending on the market conditions - this can lead to unexpected losses (the same is true in your sample, just in the other direction).

You can also still get out of such a position by manually selling parts of the trade first - but it's not something that can be relied on automatically - as it may or may not reflect the actual user desire (which will be different based on the situation - you'll want to scale out as you're in profit - but the next trade is at a loss - though you belive it to recover so don't want to get out).

@hippocritical
Copy link
Contributor Author

hippocritical commented Dec 22, 2022

well just gonna filter out low $ value coins per pair for that reason then, sadge...
pricefilter for such coins it is
opened a kucoin support ticket in addition but the hope that they do anything is diminishingly low, so ... yeah whatever.

and btw by sequential I did not mean "fire one for half the volume and then let the bot decide after it s done" but to remember the n'th task you have to exit again.
Asuming this is a limit order (but the logic would apply to market too):
Limit exit 1st part, wait for it to be filled (or receive a timeout) then limit exit with the same rate again for n+1'th part... until n
Essentially by that you artificially make one big order that is fired as soon as the 1st one is done. To not break the logic it should be then all be on one overarching timeout, not a new one each time but ... that might then again cause internal drastic changes so ... meh once again

That all assumed that your statement of the "volume to big" would be something you could go by and rely on.

@xmatthias
Copy link
Member

xmatthias commented Dec 23, 2022

Well nothing in this regards will change the fact that you have an order that's > the allowed size.

this means in case of a "must" exit (stoploss) - you cannot get out fast (you need to do multiple orders).

as said above - even IF we were supporting that (irrelevant if easy/simple to do or not) - it'd make stoploss meaningless - as you could exit at -10% for the first order, and seconds later at -20% with the 2nd order (these are low value coins - so they tend to do huge moves).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage Needed Issues yet to verify
Projects
None yet
Development

No branches or pull requests

2 participants