From 5a47056e0a73733df4d873450f309d8a839bf2e6 Mon Sep 17 00:00:00 2001 From: kukemuna Date: Fri, 26 Apr 2024 08:57:48 +0300 Subject: [PATCH] automated commit by check50 [check50=True] --- app.py | 12 ++++++++---- finance.db | Bin 20480 -> 20480 bytes .../16fa13c5890feb947b5d5c907cfedf5b | Bin 46 -> 46 bytes templates/history.html | 2 +- templates/home.html | 8 ++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index cd55ffa..97f6a52 100644 --- a/app.py +++ b/app.py @@ -48,21 +48,25 @@ def index(): for stock in stocks: symbol = stock["symbol"] + # Update share price stock_price = lookup(symbol.upper()) stock["shares"] = stock["sum(shares)"] stock["price"] = stock_price["price"] - stock["total"] = usd(stock_price["price"] * stock["sum(shares)"]) + # Get total value of owned stock + stock["total"] = stock_price["price"] * stock["sum(shares)"] + # Get value of all owned stocks stocks_total = stocks_total + (stock_price["price"] * stock["sum(shares)"]) - total = usd(cash[0]["cash"] + stocks_total) + # Get total value of stocks and cash + total = cash[0]["cash"] + stocks_total - return render_template("home.html", cash=usd(cash[0]["cash"]), stocks=stocks, total=total) + return render_template("home.html", cash=cash[0]["cash"], stocks=stocks, total=total) # return apology("MOFO") @app.route("/buy", methods=["GET", "POST"]) @login_required -def buy(): +def buy():# """Buy shares of stock""" if request.method == "GET": return render_template("buy.html") diff --git a/finance.db b/finance.db index 82ffe12280571445902f1e353acbde825b3c40ff..b280d4559f6b5bd112249da37aafaccbd92a1733 100644 GIT binary patch delta 101 zcmV-r0Gj`RpaFoO0gxL3V38a{0bsFUHXaAU0Z&{g^}@5A9#;_oEVK154-f+>30RW{ zKv4n-Sh0cr2q`Bl2LK5b0S7ZpQ$|z*KzQ(@*9tvxGB7eUEig1KGBzMEI65>jIxsP_ Hfk}S`CWae_2s+(a2?#<-0MW^(L@Cq&K!g3WW~!UY+%H-FXV7hu-lY@E#Q5V)~X LlXG*UXFVGLF`*My diff --git a/flask_session/16fa13c5890feb947b5d5c907cfedf5b b/flask_session/16fa13c5890feb947b5d5c907cfedf5b index 4a8ac5194f51b9b0ee348c4769349067a730ba3b..4bd85b062161b3536bfe68b253486fa3e6f3b319 100644 GIT binary patch delta 8 PcmdPXV@i^r$fN@R2M+ {{ stock.symbol }} {{ stock.shares }} - {{ stock.price }} + {{ stock.price | usd}} {{ stock.date }} {% endfor%} diff --git a/templates/home.html b/templates/home.html index e7fe1bb..d32f80e 100644 --- a/templates/home.html +++ b/templates/home.html @@ -20,8 +20,8 @@ {{ stock.symbol }} {{ stock.shares }} - {{ stock.price }} - {{ stock.total }} + {{ stock.price | usd }} + {{ stock.total | usd }} {% endfor%} @@ -29,11 +29,11 @@ Cash - {{ cash }} + {{ cash | usd }} TOTAL - {{ total }} + {{ total | usd }}