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 82ffe12..b280d45 100644 Binary files a/finance.db and b/finance.db differ diff --git a/flask_session/16fa13c5890feb947b5d5c907cfedf5b b/flask_session/16fa13c5890feb947b5d5c907cfedf5b index 4a8ac51..4bd85b0 100644 Binary files a/flask_session/16fa13c5890feb947b5d5c907cfedf5b and b/flask_session/16fa13c5890feb947b5d5c907cfedf5b differ diff --git a/templates/history.html b/templates/history.html index 7384232..c829e7b 100644 --- a/templates/history.html +++ b/templates/history.html @@ -20,7 +20,7 @@