dashed-slug.net › Forums › Exchange extension support › Available balance calculations out of whack
Tagged: available balance, order, placement
- This topic has 8 replies, 2 voices, and was last updated 5 years, 9 months ago by megeanwasson.
-
AuthorPosts
-
January 31, 2019 at 9:54 am #5697megeanwassonParticipant
Hi Alex,
I think there is something not quite right with the available balance calculations and how it works and affects the exchange.
I have started off with blank exchange with no trades on and then proceeded to add some trades.BTC Balance shows correctly then I add a buy order, all good so far.
Now I place that order and this is the result, all good so far.
Now I place another order on the same pair, all still ok here.
Now I go to another coin to place a new order.
On submitting this order everything starts to go wrong from here, the btc amount deducted from available balance is off by a zero, it is deducting 0.0002003 instead of 0.002003 and shows no errors.
Now I go to another coin to place another buy order.
After completing this last order I end up with B-1.86108917 ($-6416.77)
Please let me know if you need more info to help find the problem?
Kind Regards
MeganJanuary 31, 2019 at 12:40 pm #5708alexgKeymasterHello Megan,
Thank you for reporting this. And I appreciate the detailed screenshots.
I will investigate immediately, as I believe that this is one of the last significant errors with the exchange.
Hopefully I will have a better reply soon.
In the meantime, could you please confirm that you are using
4.0.x
of wallets and0.6.0-beta
of the Exchange?thanks
January 31, 2019 at 12:58 pm #5709megeanwassonParticipantHi Alex,
All latest plugins.
I also thought maybe it was becuase i was cross trading coins with each other, but then changed to only have the coins against BTC but resulted same errors.Alt Coins Adapter: by Alex Georgiou – 0.1.0 Bitcoin and Altcoin Wallets: Exchange extension by dashed-slug – 0.6.0-beta Bitcoin and Altcoin Wallets: Full Node Multi Coin Adapter extension by dashed-slug – 1.0.5 Bitcoin and Altcoin Wallets: WooCommerce Cryptocurrency Payment Gateway by dashed-slug – 2.0.0 Bitcoin and Altcoin Wallets: by dashed-slug – 4.0.0
Let me know if you need anything else.
Just a note I also tried with all plugins disabled and on default wp template and still got the same issue.Regards
MeganJanuary 31, 2019 at 7:04 pm #5722alexgKeymasterHello Megan,
(I would have liked to reply to you sooner but I spent all day assisting people who faced memory issues with the latest update, causing the cron jobs to not run in some cases. Version
4.0.1
solves most of these issues but in certain server configurations with multiple external wallets there can be problems. Fortunately there is now a way to debug these issues. I noticed that you have enabled a few coins yourslef, so if you detect any such problems, let me know.)As for your issue with the exchange, the error is mine. I have made a mistake that I will correct in the next patch. I am a bit surprised that I never saw any error message, but somehow this went undetected.
Perhaps you could apply the fix to your code directly, and tell me if this is enough to solve the problem you encountered:
In file
includes/php-api.php
, line1357
, it now reads:SUM( amount - filled ) * rate AS a
This is obviously a mistake that can cause a MySQL error 1140, and can therefore cause the available balance calculation to be wrong.
The correct expression would be:
SUM( ( amount - filled ) * rate ) AS a
If you can, please edit your code and see if the problem is resolved.
As always I appreciate very much your help in spotting this.
with regards
January 31, 2019 at 7:06 pm #5723megeanwassonParticipantHi Alex,
I will apply patch and see it it resolves the issue 🙂
I will feedback as soon as tested.
Regards
MeganJanuary 31, 2019 at 7:33 pm #5724megeanwassonParticipantOk, I have tested all coins against BTC and available BTC balances calculated correctly 🙂
I will now go setup everything again and try trades across the coins to see if they also work and balance correclty.
Will let you know as soon as tested.January 31, 2019 at 8:44 pm #5725megeanwassonParticipantHi Alex,
Your patch seems to have worked.
I have now tested across all coin pairs and all the balances look to be calculating correctly now 🙂
If I do find any further issues with the balances I will revert back 🙂Regards
MeganFebruary 1, 2019 at 8:14 am #5729alexgKeymasterHelo Megan, that’s great news! I will release a patch for the exchange extension with only this fix for now.
with regards
February 1, 2019 at 8:36 am #5731megeanwassonParticipantAwesome 🙂
I have maybe found another small glitch with prices of one coin on the exchange rates shortcodes, not sure if it’s related, will open new thread shortly.
Regards
Megan -
AuthorPosts
- You must be logged in to reply to this topic.