3cqs-coder / SymBot

SymBot is a user friendly, self-hosted and automated DCA (Dollar Cost Averaging) cryptocurrency bot solution
https://www.3cqs.com
Other
175 stars 15 forks source link

Critical Functional Bug (Deal Duplication Upon Restart) #40

Closed REFLEXGAMING007 closed 6 months ago

REFLEXGAMING007 commented 6 months ago

Power went out in my house for few hours. When I restarted the symbot, quite a few of my deals got duplicated for some reason. Already closed most of them in a panic. This is dangerous please fix it๐Ÿ˜“ . I've sent the logs as well

Screenshot_20240214-154429929_2.jpg

2024-02-14.log (1).txt

3cqs-coder commented 6 months ago

Power or system hardware failures can definitely pose increased risks due to potential data corruption, so it is always recommended to use a trusted hosting provider to reduce those risks. However, more information is needed.

It does look like there are several hours of gap in the logs, but looking at one deal might help identify what is occurring. First, the deal id's are all unique so what is meant by duplication? Are you referring to more deals are running than should be? In that case, do your bots have anything set in "Max Pair Deals"? That will allow multiples of the same pair to run on your bots if set higher than 1.

Taking one deal from your screenshot as an example that appears to have started after the failure at 2024-02-14T06:03:55.201Z, deal id IMX_USDT-2A95M4C-1707904113 began when SymBot started again:

SymBot down 2024-02-14T06:03:55.201Z Pair: FXS/USDT Last Price: $8.882 DCA Price: $8.947 Target: $9.014 Next Order: $8.615 Profit: -0.81%

SymBot up 2024-02-14T09:47:17.696Z Starting SymBot v0.99.1000-beta.0 2024-02-14T09:47:18.229Z Database Connected 2024-02-14T09:47:18.485Z SymBot v0.99.1000-beta.0 listening on port 3000 2024-02-14T09:47:18.525Z Resuming 53 active DCA bot deals...

Deals are resuming... some deals sell successfully and IMX_USDT-2A95M4C-1707904113 starts:

2024-02-14T09:48:44.537Z KuCoin 0.35 A2: Starting new deal. Pair: IMX/USDT / Deal ID: IMX_USDT-2A95M5I-1707904124 2024-02-14T09:48:52.265Z {"date":"2024-02-14T09:48:52.265Z","success":true,"data":{"info":{"orderId":"65cc8c8697c9e30007796500"},"id":"65cc8c8697c9e30007796500","symbol":"IMX/USDT","fee":{},"trades":[],"fees":[{}]},"message":"BUY SUCCESS","deal_id":"IMX_USDT-2A95M4C-1707904113","pair":"IMX/USDT","quantity":"0.1149","price":"3.0435"}

SymBot down again 2024-02-14T10:16:57.490Z Pair: FXS/USDT Last Price: $9.077 DCA Price: $9.113 Target: $9.189 Next Order: $8.931 Profit: -0.48%

2024-02-14T10:29:45.758Z Starting SymBot v0.99.1000-beta.0 2024-02-14T10:29:46.275Z Database Connected 2024-02-14T10:29:46.553Z SymBot v0.99.1000-beta.0 listening on port 3000 2024-02-14T10:29:46.594Z Resuming 55 active DCA bot deals...

SymBot up again. Resumes deal as expected 2024-02-14T10:30:12.667Z Resuming Deal ID IMX_USDT-2A95M4C-1707904113

Each time SymBot went down, it looks like it resumed a total of 52 or 53 deals, until the very last time there were a couple additional deals that were started prior, including IMX_USDT-2A95M4C-1707904113 as others finished making 55. In this system down gap it was only about 15 minutes, but it resumes that deal as it should since it was started about an hour earlier shown above. SymBot attempts to resume all deals before allowing others to start upon reboot, but there are varying parts in logic involved in that process that maybe can be improved.

There are also quite a few {"name":"InvalidOrder"} order messages long before the initial failure, without much detail of where that may be coming from. According to the logs, SymBot was restarted 7 times in less than a day. That will at some point inevitably cause some type of issues, especially when running many bots and deals.

REFLEXGAMING007 commented 6 months ago

I've kept all the max deal related settings 0 in my bots. So it shouldn't start multiple deals from same coin. Here's my settings for that๐Ÿ‘‡ Screenshot_20240214-204915761.jpg

Okay let me explain what happened soo far. It's a bit complex tbh

I was supposed to run 50 deals from 50 coins but I was running 53 deals in total because I updated & moved some of those coins to another bot but didn't manually close them so they kept running. It was xrp, fxs & one other I can't remember.

Then the power cut happened for 4 hours. (From 11:21am to 3:17pm ist to be exact as you can see in the screenshot) When I finally started symbot after that several deals closed within 1 minute & few of them got glitched & opened multiple deals for same pair even though it was set 0 in bot. So it went from 53 deals to 58 maybe 59 deals at 3:18pm ist. Check the screenshot below I colour coded them where it opened multiple deals ๐Ÿ‘‡. Screenshot_20240214-214352100_1.jpg

Eth, Uni, Skl, Snx & Hbar got glitched & opened multiple deals to be exact.

Then I panicked & manually closed few of them in this time๐Ÿ‘‡ it might help read the logs better Screenshot_20240214-220720463_1.jpg

That's all that happened.

REFLEXGAMING007 commented 6 months ago

Imx also multiplied in that time. I forgot to mark that in my telegram screenshot

3cqs-coder commented 6 months ago

Thank you for the clarification. In your bot screenshot you have Max Pairs set to 0. That means all pairs in the pair selection box will start and run continuously one after the other using ASAP start condition. If all bots have that unlimited setting, this could be part of what happened.

There are a lot of factors and logs to sift through and consider, but in one portion of your logs it does seem while deals were resuming on start up, the successful closing of others during that process may have contributed to additional deals starting. This is only an educated guess as without knowing with completely accuracy what bot pairs, settings, etc. were during all of this, it's difficult to say. SymBot does not log changes made to bots or deals, although that may be something to add in the future. But, will be looking at possibly further improving resuming deals logic if that contributed to what you experienced.

Ultimately it is extremely important that if you're running your own bot platform, the most stable environment should be used as possible including the server and internet connection.

REFLEXGAMING007 commented 6 months ago

Thanks for the response. I might get a stable server & internet in future but for now I'm poor so I'll simply have deal with it tbh.

I used to have power cuts before as well but didn't create problems in my SymBot that time.

I just updated my SymBot yesterday after 2 months now this happened so I thought it was a symbot bug ๐Ÿ˜…

3cqs-coder commented 6 months ago

Keep at it, you'll get the funds eventually :)

Anything is possible of what occurred here, but it is always appreciated when things are reported, and you always provide great detail. Please continue to do so... it is very helpful and can only serve to improve the experience for everyone.

REFLEXGAMING007 commented 6 months ago

Small update

I probably figured out why that bug happened. I remembered I moved those coins from one bot to another. From then the bug started happening.

It just happened again without any power cut or anything. STX opened twice. Screenshot_20240215-032045384_1.jpg

After that I just turned off the bot, removed stx, turned on & re added stx again. Now it's not multiplying anymore.

Also there was a coin that was trying sell the same quantity twice. Screenshot_20240215-032737557.jpg Screenshot_20240215-032751552.jpg

I had to manually buy skl in kucoin for the error to go away and after that I just removed & re added skl as well & now it's working normally again.

3cqs-coder commented 6 months ago

Thanks for the update, glad you figured it out! Something to keep in mind, when you say you moved coins from one bot to the other, that would make sense why more deals started. Once the new bot had the same pairs added as the other bot in ASAP mode, it started them. The two bots are separate so they won't be aware of each other's deals that are running and your other bot's existing deals would continue to run until they complete.