-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Doubled or missing sell orders since websocket implemented #451
Comments
Hello @uhliksk WebSocket is fast and we are calling
My suggested solutionUse queue for each symbol to queue the calls of This is the same for #450 I will try to work on this when I have time |
Hello @habibalkhabbaz That's great you found a possible vector of fail. Do you think it will solve also the missing sell orders problem? I didn't catched a log for both incidents as they happend more than 30 minutes ago but I'll try to monitor the bot more frequently to catch how exactly it's been processed. |
I think that's another issue. I have two question:
|
Today I even found tripple buy order in Order History executed by bot: I'll try today to migrate the bot to another server with higher performance to see if cpu bottleneck is the issue. Right now it's using 80% of single core. |
I have seen double orders in 0.0.85 before. It usually happened when the bot was trying to cancel an already placed order because its price had changed. |
@Rayn0r This is something else as those duplicate orders are created at once. |
@habibalkhabbaz I implemented |
Hey @uhliksk That's great. The new suggested solution
Sample code
I can create PR to implement this if you like or you can do it as well. Or if you like we may include the fixes in my last PR which is related. |
@uhliksk |
@habibalkhabbaz Great. But I think it'll be even better to not just |
@uhliksk WebSocket send updates every 1 second for a symbol. That means the What do you think? |
@habibalkhabbaz From what I've seen if there is no change in a symbol then |
@habibalkhabbaz Right now I have UNIBUSD not updated for 29 seconds. If there was skipped call with your solution then it will be not processed for those full 29 seconds (and maybe longer). |
@habibalkhabbaz Bad news. Missing sell order bug is still not fixed. Unfortunately I had logging turned off as I thought the problem is finally solved. |
I understood! |
Ohh. |
I am sure that the duplicated orders are solved now and it needs only minor improvement as per your feedback. However, the lost sell order as I said it's another issue. So, let me debug this. I remember I have had the same problem when I bought a symbol outside the bot and the bot is not running. Then I use the bot only for sell (set last buy price). Like this will result in a lost sell order. So, I would like to know if DOTBUSD bought using the bot or outside (from Binance directly). If this is your case, I know the problem and I have a solution for it. |
@habibalkhabbaz I'm not doing manual orders. Everything, buy or sell, is made by the bot automatically. |
@habibalkhabbaz The NEARBUSD I posted in screenshots section of this issue had also canceled sell orders. I think this bug is related to bot automatically cancelling sell orders when the price is raising. |
@habibalkhabbaz Is this normal behavior to wait 20 seconds between the sell order is executed and the grid trade is removed? |
Yes, this is the default setting value. binance-trading-bot/config/default.json Line 149 in 70b8d0c
You can change it by using your
I am still trying to know what is the actual issue. |
@uhliksk |
@habibalkhabbaz I reverted my changes and merged with your PR and also changed |
@uhliksk |
@habibalkhabbaz Something wrong has happened since I started the code with your PR merged. Some symbols just stopped updating. When I reverted the code it catched the current values immediatelly. |
@chrisleekr I'm sorry but I don't have full log again. I'm saving log over samba to another machine as the log generated by the bot is massive in my instance and I didn't noticed it filled dedicated partition. Last 50 MB stored locally are just a few last seconds of log which is not helpful. I think the bot received the sell order cancellation over websocket but as there was no price change, it was not processed by Checking orderId will also be fine to prevent removing wrong order by delayed sell order cancellation report. I'll try to run with your branch to see it the issue will occur again in next few days. Thank you. |
Yap, that is what I think as well.
Yap, I just tested in my RPi with the test server. It started logging the order update as well. Btw, when you open the log for the symbol, you can view the data on the right column. And when you encounter the same issue, export the log immediately. |
Ok, I forgot about that option. Thank you. |
You are right @chrisleekr on both scenarios. |
@chrisleekr
I can provide the changes as txt if you like since the changes applied on 2 files only: |
@chrisleekr Not a sell order bug yet, but just an interesting "double" execution logged. |
@uhliksk That is interesting. So there was New/Filled order update almost the same time and it triggered two executeTrailingTrade. |
One thing I just noticed is, that the locking symbol didn't work properly. I may have a workaround, but this workaround is very dodge. Let me update workaround first. |
Good catch! @uhliksk @chrisleekr However, I think we still need to check for the Moreover, I was thinking about the queue implementation last few days and I found that the ideal solution is to implement a queue for each symbol so that each symbol will not be waiting for other symbols to complete their job but I think this is not good for the performance. Let me know if you have any idea about this @chrisleekr when you have time. |
I agree. The current code - https://github.com/chrisleekr/binance-trading-bot/blob/master/app/cronjob/trailingTrade.js#L39 - only lock the symbol 5 seconds. My plan is to mimic the queue system. If the symbol is locked, I force it to execute the trailing trade 10 seconds later. I will use As mentioned, this is a workaround. This workaround should be updated when we have a queue.
Agree. Trailing Trade can be executed simultaneously for other symbols. It should just FIFO execution for the same symbol. So for example, if there is an order update event, then put the job into the queue. If there is the following order update event, then it put the job into the queue again. But it does not execute until finishing the running trailing trade job. |
I have updated trailingTrade to be executed 10 secs later when the symbol is locked. With this code, double execution should be fixed. See the commit: c05c46c I've also updated the log UI to be more descriptive.
With this, just a screenshot may help to understand what is going on. |
Nice update @chrisleekr I have a great news also regarding the queue. |
@chrisleekr I tried to export log but it crashed my browser as I had 480 minutes limit and it was just too big to process I think. I set back to default 30 minutes and I'll try to catch the problem in real time. I like the changes in log visuals as I prefer to make screenshots which are simple and reliable everytime. I'll merge the commit, thank you. @habibalkhabbaz I prefer parallel processing of queue because using single queue for all symbols will be pretty narrow bottleneck in rush hours I think. |
Totally agree @uhliksk |
Once @uhliksk say, there is no more issue, then I will merge in. |
@chrisleekr I've made a comment in #461, not important issue. |
@uhliksk Answered on the PR. So did you encounter any issues so far? |
Accidentally I ran a massive test for sell orders recently. :) I had to do some maintenance on my VM when this happened on almost every pair. I started VM immediatelly which caused a massive sell-out. There were 19 sell orders placed and executed in just a few seconds and I can confirm all of them were processed without an issue. |
Oh, nice. Very good. Ok, I will merge in. |
@chrisleekr Again another batch of 14 sell orders has been closed. I'll check logs for all the sell orders executed recently to see if there are any potential anomalies recorded. I saved whole |
Strange thing. There are no new buy orders placed since this 'nuclear meltdown' happend. In docker log there is a bunch of lines like this:
|
@chrisleekr I can create another issue as I think this is something not related to problem discussed in this issue. |
@uhliksk When your order's stop price is higher than the last coin price, the order will not be accepted because it would execute immediately. |
I can confirm that I have the same issue. Also sometimes my stop loss sell orders double up. Here are some logs: And then suddenly the quantity doubles: As you can see it jumps from 3.29 to 6.58 faling to sell. |
Version
v0.0.88 (9c2e4f5)
Description
In radnom appearance there are single sell orders counted as two sell orders at once. There is single sell order executed on Binance side resulted into two closed trade records on bot side. This is doubling calculated profitability.
In random appearance there are closed trades executed on Binance side triggering removing last buy price without accounting last sell order thus removing trade grid with calculated 100% loss. This is worsening calculated profitability.
To Reproduce
There are no actual steps to reproduce as the bug is appearing randomly.
Expected Behaviours
Single sell order should be counted as single transaction in closed trades history.
Screenshots
Doubled sell order:
Missing sell order:
Additional context
The text was updated successfully, but these errors were encountered: