Ejemplo n.º 1
0
def list_proposals():
    if "auth_field" in session:
        dbcursor.execute("SELECT _id FROM deals WHERE dealer_id = %s",
                         (session['_id'], ))
        dbres = dbcursor.fetchall()
        data_list = []
        for _id in dbres:
            dbcursor.execute("SELECT * FROM proposals WHERE deal_id = %s",
                             (_id[0], ))
            dbres = dbcursor.fetchall()
            for data in dbres:
                dbcursor.execute("SELECT uname FROM users WHERE _id = %s",
                                 (data[1], ))
                dbres = dbcursor.fetchone()
                data_list.append([data, dbres[0]])
        return render_template('proposals.html', data_list=data_list)
Ejemplo n.º 2
0
def value_tracker(ticker_name):
    now = datetime.datetime.now()
    start = now.replace(hour=0, minute=0, second=0, microsecond=1)
    sum = 0
    num = 0
    avg = None
    data_tuple = (start, now, ticker_name)
    dbcursor.execute("SELECT * FROM stock_transactions WHERE date >= %s AND date <= %s AND give = %s", data_tuple)
    dbres = dbcursor.fetchall()
    if dbres:
        for res in dbres:
            if res[8] == "DEAL":
                if res[4] == "money":
                    num += res[3]
                    sum += num*res[5]
        avg = sum/num
    return avg
        
Ejemplo n.º 3
0
def transactions():
    if "auth_field" in session:
        dbcursor.execute(
            "SELECT * FROM stock_transactions WHERE taker_id = %s OR giver_id = %s",
            (session['_id'], session['_id']))
        dbres = dbcursor.fetchall()
        data_list = []
        if dbres:
            for transaction in dbres:
                dbcursor.execute("SELECT uname FROM users WHERE _id = %s",
                                 (transaction[7], ))
                dbres1 = dbcursor.fetchone()
                if transaction[8] == "IPO":
                    dbcursor.execute("SELECT name FROM company WHERE _id = %s",
                                     (transaction[6], ))
                    dbres2 = dbcursor.fetchone()
                else:
                    dbcursor.execute("SELECT uname FROM users WHERE _id = %s",
                                     (transaction[6], ))
                    dbres2 = dbcursor.fetchone()
                data_list.append([transaction, dbres1[0], dbres2[0]])
            return render_template('transactions.html', data_list=data_list)
        else:
            return render_template('transactions.html', data_list=data_list)
Ejemplo n.º 4
0
def market():
    if "auth_field" in session:
        dbcursor.execute("SELECT * FROM deals")
        dbres = dbcursor.fetchall()
        return render_template('marketplace.html', dbres=dbres)
Ejemplo n.º 5
0
def tickers():
    if "auth_field" in session:
        dbcursor.execute("SELECT * FROM company")
        dbres = dbcursor.fetchall()
        return render_template('ticker.list.html', dbres=dbres)