Use ISIN numbers instead of share symbols and add comment field to database.
Fixes #65
This commit is contained in:
@@ -2,7 +2,7 @@ __author__ = "Florian Kaiser"
|
||||
__copyright__ = "Copyright 2022, Project Aktienbot"
|
||||
__credits__ = ["Florian Kaiser", "Florian Kellermann", "Linus Eickhof", "Kevin Pauer"]
|
||||
__license__ = "GPL 3.0"
|
||||
__version__ = "1.0.0"
|
||||
__version__ = "1.0.1"
|
||||
|
||||
import os
|
||||
|
||||
@@ -27,22 +27,23 @@ def get_portfolio():
|
||||
return_portfolio = []
|
||||
|
||||
# Get all transactions of current user
|
||||
transactions = db.session.execute("SELECT symbol, SUM(count), SUM(price), MAX(time) FROM `transactions` WHERE email = '" + email + "' GROUP BY symbol;").all()
|
||||
transactions = db.session.execute("SELECT isin, comment, SUM(count), SUM(price), MAX(time) FROM `transactions` WHERE email = '" + email + "' GROUP BY isin, comment;").all()
|
||||
|
||||
# If there are no transactions, return empty portfolio
|
||||
# Otherwise calculate portfolio
|
||||
if transactions is not None:
|
||||
for row in transactions:
|
||||
data = {
|
||||
"symbol": row[0],
|
||||
"count": row[1],
|
||||
# "calculated_price": row[2],
|
||||
"last_transaction": row[3],
|
||||
"isin": row[0],
|
||||
"comment": row[1],
|
||||
"count": row[2],
|
||||
# "calculated_price": row[3],
|
||||
"last_transaction": row[4],
|
||||
'current_price': 0
|
||||
}
|
||||
|
||||
# Add current share value to portfolio
|
||||
query_share_price = db.session.query(SharePrice).filter_by(symbol=row[0]).order_by(SharePrice.date.desc()).first()
|
||||
query_share_price = db.session.query(SharePrice).filter_by(isin=row[0]).order_by(SharePrice.date.desc()).first()
|
||||
if query_share_price is not None:
|
||||
data['current_price'] = query_share_price.as_dict()['price']
|
||||
|
||||
|
Reference in New Issue
Block a user