Skip to content
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

Profit/Loss percentage calculated incorrectly #270

Closed
Bajt1 opened this issue Aug 13, 2021 · 4 comments
Closed

Profit/Loss percentage calculated incorrectly #270

Bajt1 opened this issue Aug 13, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@Bajt1
Copy link

Bajt1 commented Aug 13, 2021

Version

0.0.75

Description

Profit/Loss is showning correct values in absolute numbers, but incorrect for percentage. I believe (I wasn't able to find this calculation in the code) this is due to the fact that the percentage base is calculated from the current estimated value.
If we have a profit, the bigger profit we have, the bigger is the base => percentage shown is smaller than it should be
If we have a loss, the bigger loss we have, the smaller is the base => negative percentage shown is bigger than it should be

Screenshots

obrazek

Profit/Loss is showing 12.51% profit, but in reality, the profit is 14.30%.
Calculating the Profit/Loss percentage from current and last buy price should give the correct values ((current / lastBuy -1)*100)

@Bajt1 Bajt1 added the bug Something isn't working label Aug 13, 2021
@habibalkhabbaz
Copy link
Contributor

It makes sense!
I see that the profit percentage is calculated like below:
(1 - lastBuyPrice / currentPrice) * 100

I don't know if there is a reason behind this. Maybe @chrisleekr can explain this.

@chrisleekr
Copy link
Owner

chrisleekr commented Aug 14, 2021

@Bajt1

Oh yeah, you are right. I have to calculate (Current price/Last Buy Price - 1)*100

I will fix up later.

Price Qty Total
Current price 3.749 91.459 342.879791
Last buy price 3.28 91.459 299.98552
Profit     42.894271
“(D1/D2-1)*100”     14.2987804878049
“(D3/D2)*100”     14.2987804878049

@chrisleekr
Copy link
Owner

Fixed. Not released yet. I will release later with other changes.

@Bajt1
Copy link
Author

Bajt1 commented Aug 14, 2021

Cool, that was quick!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants