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

Add Stock Portfolio Pie Chart #14 #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion application.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ def after_request(response):
response.headers["Pragma"] = "no-cache"
return response

def history_view(request):
bought_stocks = ... # Logic to fetch bought stocks
sold_stocks = ... # Logic to fetch sold stocks

bought_value = sum([stock.shares_bought for stock in bought_stocks])
sold_value = sum([stock.shares_sold for stock in sold_stocks])

# Pass the data to the template
return render(request, 'your_template.html', {
'bought_value': bought_value,
'sold_value': sold_value,
})


# Custom filter
application.jinja_env.filters["usd"] = usd

Expand Down Expand Up @@ -535,4 +549,4 @@ def page_not_found(e):
# Run Server
# Run the following in the command line: python application.py
if __name__ == '__main__':
application.run(host='0.0.0.0')
application.run(host='0.0.0.0')