From a42eec11cd8be09f6f6d3f78c3d27b91091a95bf Mon Sep 17 00:00:00 2001 From: 2004-19 <127276464+2004-19@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:11:38 +0530 Subject: [PATCH] Update application.py adding portfolio pie chart --- application.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/application.py b/application.py index e6e80fb..4410d0d 100644 --- a/application.py +++ b/application.py @@ -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 @@ -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') \ No newline at end of file + application.run(host='0.0.0.0')