Esempio n. 1
0
def getStockPriceOverTimeDateFilter(symbol, dateRange):
    if "net worth" in symbol.lower():
        userId = symbol[symbol.index(" ") + 1:symbol.index("'")]
        return DbHelper.select(
            "select net_worth from users.net_worth where user_id = " + userId +
            " and net_worth_ts > '" + dateRange +
            "'ORDER BY net_worth_ts DESC")
    return DbHelper.select("select price from stocks.price where symbol = '" +
                           symbol + "' and price_ts > '" + dateRange +
                           "'ORDER BY price_ts DESC")
Esempio n. 2
0
def getUserInfo(userId):
    try:
        value = DbHelper.select("Select * from users.user where user_id = " +
                                str(userId))
    except Exception as e:
        value = "ERROR! -> " + str(e)
    return value
Esempio n. 3
0
def getUserNetWorth(userId):
    try:
        value = DbHelper.select(
            "select net_worth from users.net_worth where user_id = " +
            str(userId) + "ORDER BY net_worth_ts DESC LIMIT 1")
    except Exception as e:
        value = "ERROR! -> " + str(e)
    return float(value)
Esempio n. 4
0
def getNetWorthForUser(userId):
    records = DbHelper.select(
        "SELECT symbol,quantity from Users.portfolio where user_id = " +
        str(userId))
    total = 0.0
    for record in records:
        myList = record.split(",")
        price = DbStockPriceHelper.getMostRecentPrice(myList[0])[0]
        value = float(price) * float(myList[1])
        total += value
    return round(total, 2)
Esempio n. 5
0
def getPortfolioStockListForUser(userId):
    return DbHelper.select(
        "SELECT DISTINCT(symbol) from users.portfolio where user_id = " +
        userId)
Esempio n. 6
0
def getPortfolioStockList():
    return DbHelper.select("SELECT DISTINCT(symbol) from users.portfolio")
Esempio n. 7
0
def getNetWorthTsForUser(userId):
    symbolList = DbPortfolioHelper.getPortfolioStockListForUser(userId)
    return DbHelper.select(
        "select price_ts from stocks.price where symbol in(" +
        str(symbolList).replace("[", "").replace("]", "") +
        ") ORDER BY price_ts desc LIMIT 1")[0]
Esempio n. 8
0
def getMostRecentPrice(symbol):
    return DbHelper.select("SELECT price from Stocks.price where symbol = '" +
                           symbol + "' ORDER BY price_ts DESC LIMIT 1")
Esempio n. 9
0
def getAllUserIds():
    return DbHelper.select(
        "SELECT user_id from users.user ORDER BY user_id ASC")