Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

fix for not lowering portfolio value #166

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

ppeczek
Copy link
Contributor

@ppeczek ppeczek commented May 8, 2016

not RTM

events/models.py Outdated
bet.user.save()
# This cause display event in "latest outcome"
bet.is_new_resolved = True
bet.save()
# always -- portfolio_value
for transaction in Transaction.objects.filter(event=self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be for user in UsersPortfolio loop, it will be more efficient. And I'm not sure is this correct calculation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True story. Going to check it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean this:

        for transaction in Transaction.objects.filter(event=self).values('user'):
            user = UserProfile.objects.get(pk=transaction['user'])
            user.portfolio_value = user.current_portfolio_value
            user.save()

???

# always -- portfolio_value
from accounts.models import UserProfile
for user in UserProfile.objects.filter(transaction__event=self):
user.portfolio_value = user.current_portfolio_value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In worst case scenario it's bet.has * bet.bought_avg_price ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants