Closed DecisiveDesignDE closed 1 year ago
Hi @DecisiveDesignDE After carefully reviewing your log, I found some odd.
The log recorded at "2022-11-29T12:23:05.446Z" with the message "Placed new stop loss limit order for buying of grid trade #2.".
At that point, grid trade 1 is recorded as FILLED with 1801.62000000
quantity.
However, in your account, FLOW balance is only 249.05000000
.
It means you were manually trading FLOW outside of the bot. So the bot does not know what is going on.
Were you buying/selling manually?
Thanks for the speedy response! I did not touch the bot or trade manually at all during this time. I was simply observing my settings. I feel like you described the issue correctly though - the bot thought it bought 1801 quantity but did not.
I have also seen this happen the other way around, resulting in the bot buying a certain amount of currency but then completely forgetting it did while the currency just sits in my wallet unmonitored. It is very odd that only I seem to be having this issue.
If it helps I'm running everything with docker on an ubuntu server close to japan. Is there any data I can provide you that would help with this issue?
Right, so you are not doing manually.
It's like you have another bot running. Are you sure you are not running another bot?
I am not running another bot, nor am I trading manually. I am just using your bot.
I have uploade another log for you which might help, this time from the Coin "ZRX"
https://drive.google.com/file/d/10pd4IEzC9ceCfVGkBAo4mYacKHJQlXwT/view?usp=sharing
If you look at timestamps around 14:45 - 14:47 the Bot bought ZRX, but then immediately deleted the last buy price, acted like it never bought it and then tried to buy it again. This time interfere: I cancelled the second order and entered the last buy price manually. But the issue happened before that.
I wish I could help you more, but it might just be an issue with either the server I'm running everything on or even the amounts of coins I'm trying to sell/buy? Because nobody else had this issue so far.
@DecisiveDesignDE
I am not running another bot, nor am I trading manually. I am just using your bot.
Noted.
Let me see the log. And get back to you.
Ok, I found an issue.
If you see the log, when there was a FILLED order, ensure-grid-trade-order-executed
was triggered 3 times.
It is not an expected behaviour because 1st ensure-grid-trade-order-executed
is still running until 2022-12-01T14:47:18.263Z
.
2nd/3rd ensure-grid-trade-order-executed
were triggered while 1st ensure-grid-trade-order-executed
is running.
Firstly, the quantity is calculated wrong. It ended up 15561 quantity, which is incorrect.
Secondly, after the grid trade is updated at 2022-12-01T14:47:17.977Z
, the last buy is removed because the base quantity is not updated. This is also not expected as ensure-grid-trade-order-executed
is still running.
So long story short, this is a bug. I will find a way to fix it.
Hello @chrisleekr @DecisiveDesignDE
May I know on which version you are running the bot @DecisiveDesignDE ?
@DecisiveDesignDE Hey just to make sure, are you running 3 bot instances by any chance? Probably not.
@habibalkhabbaz I am using the most recent version of the bot on master @chrisleekr nope, just the one! I'm glad you found something. It is in my opinion not a massive issue as you shouldn't leave a bot unattended anyways but definitely worth fixing
Hello @DecisiveDesignDE,
I reached the same conclusion as @chrisleekr
The log recorded at "2022-11-29T12:23:05.446Z" with the message "Placed new stop loss limit order for buying of grid trade https://github.com/chrisleekr/binance-trading-bot/issues/2.". At that point, grid trade 1 is recorded as FILLED with 1801.62000000 quantity. However, in your account, FLOW balance is only 249.05000000.
And based on what you explained here:
If you look at timestamps around 14:45 - 14:47 the Bot bought ZRX, but then immediately deleted the last buy price, acted like it never bought it and then tried to buy it again. This time interfere: I cancelled the second order and entered the last buy price manually. But the issue happened before that.
I will assume that the main issue is last buy price gets removed for ZRX and FLOW.
So what's your last buy price remove threshold
setting?
@habibalkhabbaz
I was able to replicate the issue in my local.
Steps:
However, I don't expect the bot placing the sell order twice. 2nd determine-action
is triggered while 1st job is running.
We do have concurrent 1 for the process, which supposes to prevent this kind of concurrency issue. I am still digging.
@chrisleekr
Ops, I see.
So the issue might be with the concurrency.
The strange thing is that there are around 0.5 seconds between the 1st determine-action
and the 2nd determine-action
which is enough I think to not trigger two sell orders.
I will look into it while you are already checking.
@habibalkhabbaz
Yeah, please take a look. You may find something I miss. Thanks @habibalkhabbaz !!
@DecisiveDesignDE
Hi,
I have a fix for you.
It has many changes, but the main change is just setting the limiter for the queue.
Could you read what's changed, and if you are comfortable, could you test it, please?
https://github.com/chrisleekr/binance-trading-bot/pull/551
I've written the steps to get the test version.
I have read through it and have been using the new version for around 16 hours. So far the issue is gone!
However idk if it's related to the test-version, but I am now gettng the "failed to load account information" screen after like 16 hours. The bot is still trading and I see all the bubbles popping up, but I see the new "Failed to load your account information." screen.
This issue appears to be fixed though. Thanks a lot.
@DecisiveDesignDE
Interesting. That error message is #544 changes, which is unrelated to this PR.
@habibalkhabbaz
Yeah, please take a look. You may find something I miss. Thanks @habibalkhabbaz !!
Sorry for the late reply @chrisleekr I did another scenario to replicate the issue but no luck. My queue only processes 1 job concurrently.
I am running Docker on Windows 11.
Here is what I did:
executeFor
function I intentionally added two calls for queue.add
which will add 2 jobs for a symbol at the same time.trailingTrade
so that I can see if the jobs waiting for each other or not.I am just curious how can the queue process two jobs at the same time. Maybe the environment causes this?
@habibalkhabbaz Yeah, it’s not happening every time. After I took the screenshot, I also could not replicate.
I think with my change, it gives more confident it won’t have multiple jobs running.
@DecisiveDesignDE Can you confirm the fix is working?
@chrisleekr Yes, ever since switching branches the issue has not occured again. Thanks a lot!
Hello there, first off thank you for providing your bot and code. I have been testing it for months now and am very happy with the web UI and all the possible customizations.
I have found a big Issue that seems to happen multiple times per day. The Bot buys a specific Coin, but then immediately forgets/deletes the last buy price, then immediately sells 100% of the coin and marks it down as a 100% loss. It thinks it bought the coin normally but sold it for 0 USD which simply isn't possible.
Here is an example of what this looks like in the Web UI:
To compare, here is what it looks like in Binance:
As you can see the bot bought FLOW at 1.107 but immediately sold it again 4 minutes after for 1.108 which I assume was the curent price. My profit margin is set to 0.3% so this sell was not triggered by a sell order.
I have seen this happen multiple times in both directions, it happens with profits too:
Sadly I couldn't grab the logs for these TRX and BTC trades. I do however have the logs for the FLOW trade listed above, attached:
https://drive.google.com/file/d/1uAUHsDuO_xWfJ-p4L0zQhQ0-qOOVOrDA/view?usp=sharing
Issue should've occured around 12:47 time in the log
I have just one theory on why this happens:
It seems to only happen once I raise the purchase amount above 1000USD or so. It seems like when buy or sell orders get stuck because they only get 5-10% partially filled, this issue is more likely to happen
UPDATE: The bot has now bought FLOW again, sold it and added the missing amount to the profit:
I have uploaded the new log for this as well, tis occured at 13:07 in the log https://drive.google.com/file/d/12mfMIVvkD7fsy1aMmYtm7TwCApj0w3b8/view?usp=sharing