Coder Social home page Coder Social logo

Comments (14)

kennylbj avatar kennylbj commented on June 10, 2024 1

Got it, In fact I am using the docker environment so that I am not aware of the dependencies stuff. 😊

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

For the moment - i can't reproduce this - though i'm on the very latest develop version (more relevant will be the latest ccxt version if any).

My gate spot orders does both create and cancel stoploss orders perfectly fine.
now i didn't try to fill that order - but that's not a mentioned problem, anyway.

2024-03-12 07:19:35,031 - freqtrade.exchange.exchange - INFO - API fetch_order: {'id': '683672990', 'clientOrderId': None, 'timestamp': 1710223763000, 'datetime': '2024-03-12T06:09:23.000Z', 'lastTradeTimestamp': None, 'status': 'open', 'symbol': 'METIS/USDT:USDT', 'type': 'limit', 'timeInForce': 'GTC', 'postOnly': False, 'reduceOnly': None, 'side': 'sell', 'price': 115.782, 'stopPrice': 115.897, 'triggerPrice': 115.897, 'average': None, 'amount': 0.08, 'cost': 0.0, 'filled': 0.0, 'remaining': 0.08, 'fee': None, 'fees': [], 'trades': [], 'info': {'market': 'METIS_USDT', 'user': '6266643', 'trigger': {'price': '115.897', 'rule': '<=', 'expiration': '86400'}, 'put': {'type': 'limit', 'side': 'sell', 'price': '115.782', 'amount': '0.08000000000000000000', 'account': 'normal', 'time_in_force': 'gtc', 'auto_borrow': False, 'auto_repay': False}, 'id': '683672990', 'ctime': '1710223763', 'status': 'open'}, 'lastUpdateTimestamp': None, 'takeProfitPrice': None, 'stopLossPrice': None}
2024-03-12 07:19:37,392 - freqtrade.freqtradebot - INFO - Cancelling stoploss on exchange for Trade(id=3, pair=METIS/USDT, amount=0.08000000, is_short=False, leverage=1.0, open_rate=128.77400000, open_since=2024-03-12 06:04:32) order: 683672990
2024-03-12 07:19:40,941 - freqtrade.exchange.exchange - INFO - API cancel_order: {'id': '683672990', 'clientOrderId': None, 'timestamp': 1710223763000, 'datetime': '2024-03-12T06:09:23.000Z', 'lastTradeTimestamp': None, 'status': 'canceled', 'symbol': 'METIS/USDT:USDT', 'type': 'limit', 'timeInForce': 'GTC', 'postOnly': False, 'reduceOnly': None, 'side': 'sell', 'price': 115.782, 'stopPrice': 115.897, 'triggerPrice': 115.897, 'average': None, 'amount': 0.08, 'cost': 0.0, 'filled': 0.0, 'remaining': 0.08, 'fee': None, 'fees': [], 'trades': [], 'info': {'market': 'METIS_USDT', 'user': '6266643', 'trigger': {'price': '115.897', 'rule': '<=', 'expiration': '86400'}, 'put': {'type': 'limit', 'side': 'sell', 'price': '115.782', 'amount': '0.08000000000000000000', 'account': 'normal', 'time_in_force': 'gtc', 'auto_borrow': False, 'auto_repay': False}, 'id': '683672990', 'ctime': '1710223763', 'ftime': '1710224379', 'status': 'canceled'}, 'lastUpdateTimestamp': None, 'takeProfitPrice': None, 'stopLossPrice': None}
2024-03-12 07:19:41,281 - freqtrade.exchange.exchange - INFO - API fetch_order: {'id': '683672990', 'clientOrderId': None, 'timestamp': 1710223763000, 'datetime': '2024-03-12T06:09:23.000Z', 'lastTradeTimestamp': None, 'status': 'canceled', 'symbol': 'METIS/USDT:USDT', 'type': 'limit', 'timeInForce': 'GTC', 'postOnly': False, 'reduceOnly': None, 'side': 'sell', 'price': 115.782, 'stopPrice': 115.897, 'triggerPrice': 115.897, 'average': None, 'amount': 0.08, 'cost': 0.0, 'filled': 0.0, 'remaining': 0.08, 'fee': None, 'fees': [], 'trades': [], 'info': {'market': 'METIS_USDT', 'user': '6266643', 'trigger': {'price': '115.897', 'rule': '<=', 'expiration': '86400'}, 'put': {'type': 'limit', 'side': 'sell', 'price': '115.782', 'amount': '0.08000000000000000000', 'account': 'normal', 'time_in_force': 'gtc', 'auto_borrow': False, 'auto_repay': False}, 'id': '683672990', 'ctime': '1710223763', 'ftime': '1710224379', 'status': 'canceled'}, 'lastUpdateTimestamp': None, 'takeProfitPrice': None, 'stopLossPrice': None}
2024-03-12 07:19:41,907 - freqtrade.wallets - INFO - Wallets synced.

I'd suggest you try and update to that version - ccxt is improving and adapting to changing exchange API's all the time ...

from freqtrade.

Deech123 avatar Deech123 commented on June 10, 2024

would you update total FT or only the CCXT?
what is the latest version you use now?
I will update the whole FT package.
Did you try to fill an order and then let it sell online? could be that this error only triggers when an actual order is create?

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

Well i've been using the latest develop - with aligned ccxt version.

I'd not know what in freqtrade would cause this (the gate file wasn't touched in months) ... so my best bet is ccxt - though i couldn't find any "fixing" changes there, either ... but that only means i didn't look deep enough.

well without "actual" order creation, this error won't happen - so i'm not sure what you mean with that last sentence.
This was a live test - of a trade that i created (force-entry - i need it now) and then "played" with the stoploss order to test behavior, including cancellation and creation (and on exchange deletion) of stop orders.

from freqtrade.

Deech123 avatar Deech123 commented on June 10, 2024

hi @xmatthias ,
I installed this version : version='docker-2024.3-dev-93a5f290' with CCXT 4.2.67, and again I get errors.
It starts with

2024-03-15 03:50:41,926 - freqtrade.freqtradebot - INFO - Cancelling current stoploss on exchange for pair LAI/USDT (orderid:689150091) in order to add another one ...
2024-03-15 03:50:41,927 - freqtrade.freqtradebot - INFO - Cancelling stoploss on exchange for Trade(id=27, pair=LAI/USDT, amount=4248.10000000, is_short=False, leverage=1.0, open_rate=0.07796947, open_since=2024-03-15 02:41:55) order: 689150091
2024-03-15 03:50:42,779 - freqtrade.exchange.exchange - INFO - stoploss limit order added for LAI/USDT. stop price: 0.079246. limit: 0.07885
2024-03-15 03:51:12,270 - freqtrade.freqtradebot - INFO - Applying fee on amount for Trade(id=27, pair=LAI/USDT, amount=4248.10000000, is_short=False, leverage=1.0, open_rate=0.07796947, open_since=2024-03-15 02:41:55) failed: myTrade-Dict empty found

and then going again to tons of these (4 log files full in 4hours)

2024-03-15 03:51:42,506 - freqtrade.freqtradebot - ERROR - Could not cancel stoploss order 689161891 for pair LAI/USDT
Traceback (most recent call last):
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/base/exchange.py", line 630, in fetch
    response.raise_for_status()
  File "/home/ftuser/.local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.gateio.ws/api/v4/spot/price_orders/689161891

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/freqtrade/freqtrade/exchange/exchange.py", line 1355, in cancel_order
    order = self._api.cancel_order(order_id, pair, params=params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/gate.py", line 4573, in cancel_order
    response = self.privateSpotDeletePriceOrdersOrderId(self.extend(request, requestParams))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/base/types.py", line 35, in unbound_method
    return _self.request(self.path, self.api, self.method, params, config=self.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/base/exchange.py", line 3574, in request
    return self.fetch2(path, api, method, params, headers, body, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/base/exchange.py", line 3571, in fetch2
    return self.fetch(request['url'], request['method'], request['headers'], request['body'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/base/exchange.py", line 646, in fetch
    skip_further_error_handling = self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/gate.py", line 6530, in handle_errors
    self.throw_exactly_matched_exception(self.exceptions['exact'], label, feedback)
  File "/home/ftuser/.local/lib/python3.11/site-packages/ccxt/base/exchange.py", line 3948, in throw_exactly_matched_exception
    raise exact[string](message)
ccxt.base.errors.OrderNotFound: gate {"label":"ORDER_NOT_FOUND","message":"not found order info id:689161891 count:0"}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/freqtrade/freqtrade/freqtradebot.py", line 898, in cancel_stoploss_on_exchange
    co = self.exchange.cancel_stoploss_order_with_result(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/exchange/exchange.py", line 1421, in cancel_stoploss_order_with_result
    corder = self.cancel_stoploss_order(order_id, pair)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/exchange/gate.py", line 123, in cancel_stoploss_order
    return self.cancel_order(
           ^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/exchange/common.py", line 170, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/exchange/exchange.py", line 1360, in cancel_order
    raise InvalidOrderException(
freqtrade.exceptions.InvalidOrderException: Could not cancel order. Message: gate {"label":"ORDER_NOT_FOUND","message":"not found order info id:689161891 count:0"}
2024-03-15 03:51:42,780 - freqtrade.freqtradebot - ERROR - Unable to place a stoploss order on exchange. Could not create limit sell order on market LAI/USDT. Tried to sell amount 4248.1 at rate 0.078857 with stop-price 0.079253. Message: gate {"label":"INVALID_PARAM_VALUE","message":"invalid argument: Trigger.Price must < last_price"}
2024-03-15 03:51:42,781 - freqtrade.freqtradebot - WARNING - Exiting the trade forcefully

and the trade is still in FT, but it already long sold

so seems the new CCXT or dev version didn't solve this problem.

any help or idea what is causing these problems?

thx.

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

2024-03-15 03:50:41,926 - freqtrade.freqtradebot - INFO - Cancelling current stoploss on exchange for pair LAI/USDT (orderid:689150091) in order to add another one ...
(and the subsequent messages) do pretty much show that the cancellation itself works fine - at least if gate knows about the order.


best suspicion - you've got an invalid order in the database (one that gate can't find any longer).

maybe try the following query in your database - let's see what it returns ...

select *
from orders
where ft_is_open = 1

from freqtrade.

Deech123 avatar Deech123 commented on June 10, 2024

hi Matthias, I think it's different.
For what I know this is what is happening :

  1. FT makes order to Gate : works
  2. when making the order, FT also set SL on exchange : works
  3. at certain point, FT strategy give command to gate to sell order : works
  4. gate is selling the order : works
  5. gate also deletes the Sl that has been set : works
  6. and then the problem occurs., it's like FT don't get the answer from Gate or does something with it that is not correct.
    So FT wants to reset the SL, but gate say : no order , and no SL (ofcourse not, it's already sold)
    And the order is still in the FT database and visual on the gui since for FT the order is still running and open.
    And then FT is trying to reset SL etc to gate, and gets answer back : there is no order for that.. and these errors keep on going until I manual delete the order (and mess up the statistics)

So for what i'm almost 99% sure, the problem starts when an order is sold on gate and SL is also deleted by gate.

D.

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

I doubt it - and from the provided info, also see nothing that even remotely points to that (but logs are truncated and disjoint - so who knows what happens between the log entries you decide to show).

from your last comment - the order id's for stoploss were different from the one in the exception.
That means it's not the "last" stoploss order that it tries to cancel again - but a different order (where the actual order

Freqtrade won't touch orders that are not open - hence the query i asked for will provide more insights into this.

To look at this further, please provide the requested order table excerpt.
Also, you should enable "log_responses" in the exchange section of the configuration - and then provide me with (unmodified) logs of what's happening.

from freqtrade.

Deech123 avatar Deech123 commented on June 10, 2024

okey I will do that. will add :"log_responses": true,
and the moment I get the same problem, I will send you full logs from where the problem started.
do I send this private or in here as attachement? what do you prefer?

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

well the logs should not contain anything sensitive apart from the order ID's (and subsequently, trading quantities).
However, I'm happy with either (if in private, best a discord DM).

from freqtrade.

kennylbj avatar kennylbj commented on June 10, 2024

In my case (gate.io, version 2024.02, SL triggered), the freqtrade keeps generating Applying fee on amount for Trade after the SL has been triggered.

And it is wired that even if the SL was filled, the trade was not deleted from the database by freqtrade (which may cause the looping messages).

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

@kennylbj Sounds a bit like you didn't update your dependencies :)

from freqtrade.

kennylbj avatar kennylbj commented on June 10, 2024

@xmatthias If you mean I wasn't using the latest version of freqtrade, then yes, this issue was found on version 2024.02.

now I have updated the bot to 2024.03, I will check if the issue still exists on it.

from freqtrade.

xmatthias avatar xmatthias commented on June 10, 2024

well yes, that too (i didn't remember we did release 2024.3 😆 ).

what I'm actually referring to is to also update dependencies according to the updating documentation - so ccxt (and potentially other dependencies - though ccxt is the most relevant for this issue) are aligned with the expectations of freqtrade.

from freqtrade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.