automated commit by check50 [check50=True]

This commit is contained in:
kukemuna 2024-04-26 08:57:48 +03:00
parent 8b9c1adadc
commit 5a47056e0a
5 changed files with 13 additions and 9 deletions

12
app.py
View File

@ -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")

Binary file not shown.

View File

@ -20,7 +20,7 @@
<tr>
<td class="text-start">{{ stock.symbol }}</td>
<td class="text-end">{{ stock.shares }}</td>
<td class="text-end">{{ stock.price }}</td>
<td class="text-end">{{ stock.price | usd}}</td>
<td class="text-end">{{ stock.date }}</td>
</tr>
{% endfor%}

View File

@ -20,8 +20,8 @@
<tr>
<td class="text-start">{{ stock.symbol }}</td>
<td class="text-end">{{ stock.shares }}</td>
<td class="text-end">{{ stock.price }}</td>
<td class="text-end">{{ stock.total }}</td>
<td class="text-end">{{ stock.price | usd }}</td>
<td class="text-end">{{ stock.total | usd }}</td>
</tr>
{% endfor%}
</tbody>
@ -29,11 +29,11 @@
<tfoot>
<tr>
<td class="border-0 fw-bold text-end" colspan="3">Cash</td>
<td class="border-0 text-end" colspan="3">{{ cash }}</td>
<td class="border-0 text-end" colspan="3">{{ cash | usd }}</td>
</tr>
<tr>
<td class="border-0 fw-bold text-end" colspan="3">TOTAL</td>
<td class="border-0 fw- bold text-end" colspan="3">{{ total }}</td>
<td class="border-0 fw- bold text-end" colspan="3">{{ total | usd }}</td>
</tr>
</tfoot>
</table>