freqtrade / freqtrade

Free, open source crypto trading bot
https://www.freqtrade.io
GNU General Public License v3.0
28.13k stars 6.03k forks source link

Order {trade.open_order_id} for {trade.pair} not cancelled, as the filled amount of {filled_val} would result in an unexitable trade. #8229

Closed huytrvan closed 1 year ago

huytrvan commented 1 year ago

Describe your environment

Describe the problem:

Steps to reproduce:

  1. Load any one of the strategies I am using:
  2. Load the config I am using

Observed Results:

What happened?

What did you expect to happen?

  1. I expected there was problem with my config (as mentioned). However, using the same config in dry-run: strategy-A will produce error but strategy-B (with trailing stoploss turn off) will work as expected.
  2. So I suspected the problem to be strategy-A itself. However, when I turned on trailing stoploss for strategy-B (which normally works), the error happened again.

Relevant code exceptions or logs

Sample of the logs I got:

2023-02-26 09:44:09,749 - freqtrade.freqtradebot - INFO - Found open order for Trade(id=2, pair=YFDAI/USDT, amount=0.59450000, is_short=False, leverage=1.0, open_rate=102.08684272, open_since=2023-02-26 06:30:59)
2023-02-26 09:44:09,771 - freqtrade.freqtradebot - WARNING - Order dry_run_sell_1677404478.863213 for YFDAI/USDT not cancelled, as the filled amount of 0.5945 would result in an unexitable trade.
2023-02-26 09:44:09,927 - freqtrade.strategy.interface - WARNING - Outdated history for pair ASTRA/USDT. Last tick is 74 minutes old

Additional Info:

The problem seemed to be with minstake (as seen in freqtradebot.py). I have tried to fix with different settings and looked at Freqtrade source code but no clue. Thanks if you have any input.

xmatthias commented 1 year ago

depending on the selected pricing - orders may fill, or may fill partially, or may not fill. A quick fix is usually to use "pricing=other" - which will place the order at a spot that's more likely to be filled. Especially on low volume markets - that's usually a good idea to prevent unfilled orders.

seems like you're experiencing partial fills - which, in combination of timeout settings, will produce this message. it simply means "your order was filled for X% - would this order be canceled, then the remaining amount is too small to be placed as new order".

This is not a problem - but a protection. trying to circumvent this will result in "stuck" trades, which will fail with "order amount is too small".

xmatthias commented 1 year ago

Just noticed it's dry-run on kucoin - which (due to some "oddity" in the kucoin API) - has a fix forcing create-order to return "status=open". Now on dry-run - that's not necessarily correct behavior - and (for market orders) will cause wrong behavior.

will be fixed in a few minutes on develop.

huytrvan commented 1 year ago

Thanks alot @xmatthias. Yes, I was thought it was a bug because I tried your suggestion but didn't work. Glad you found the bug!