Ejemplo n.º 1
0
def check_price(nick,ticker,default_price):
        checkprice = StockMarket()
        checkprice.open_db(file_Name)
        check = StockTrade()
        check.open_db(saved_stocks)
        try:
                curprice = checkprice.get_balance(ticker)
                checked = check.get_prices(ticker)
        except:
                
                checkprice.add_stock(ticker,default_price)
                curprice = checkprice.get_balance(ticker)
                checked = check.get_prices(ticker)
        ticker = color(bold(ticker + ":"),colors.RED)
        curprice = color(str(curprice),colors.RED)
        
        phrase = ('%s ɷ %s' %(ticker,curprice))
        runs = 0
        for x in (checked):
            if nick == checked[runs][0]:
                name = color(checked[runs][0],colors.RED)
            else:
                name = checked[runs][0][:3]
            owned = (bold(" |") + " %s %s @ %s " % (name.title(), checked[runs][2], checked[runs][1]))
            phrase += owned
            runs = runs + 1

        return phrase