def showPortfolio(portfolio): for item in portfolio: print colored(item, 'grey' ) valueList = portfolio[item] for values in valueList: current = float(trader.getCurrentPriceFromTicker(values[1])) currentTotal = float(current) * float(values[4]) print colored('\t company Name: ' , 'blue') , colored(values[0], 'green' , 'on_red') print colored('\t\t stock Ticker: ' , 'blue') , values[1] print colored('\t\t Date Purchased: ' , 'blue') , values[2] print colored('\t\t Number of Stocks ' , 'blue') , values[4] print colored('\t\t Price Paid per: ' , 'blue') , str(values[3]) + '\t' , colored('Current price: ' , 'blue') , str(current) + '\t' , colored( current - float(values[3]) ,posOrNeg(current , float(values[3])) , posOrNegHighlight(current , float(values[3]) ), attrs=['bold']) print colored('\t\t Price Paid total: ' , 'blue') , str(values[5]) + '\t' , colored('Current price total: ' , 'blue') , str(currentTotal) + '\t' , colored(currentTotal - float(values[5]) ,posOrNeg(currentTotal , float(values[5]) ), posOrNegHighlight(currentTotal , float(values[5]) ), attrs=['bold'])
def showRealTime(portfolio): while(True): print colored('PRESS CONTROL C TO EXIT' , 'red' , attrs=['bold']) for item in portfolio: answer = 0 print colored(item, 'grey' ) valueList = portfolio[item] for values in valueList: currentTotal = float(trader.getCurrentPriceFromTicker(values[1])) * float(values[4]) print '\t' , values[0] , colored(currentTotal - float(values[5]) ,posOrNeg(currentTotal , float(values[5]) ), posOrNegHighlight(currentTotal , float(values[5]) ), attrs=['bold']) answer += (currentTotal - float(values[5])) if answer > 0: print colored('\t' + item, 'blue' ) , colored(answer ,'green', 'on_grey', attrs=['bold']) else: print colored('\t' + item, 'blue' ) , colored(answer ,'red', 'on_white', attrs=['bold']) time.sleep(10) os.system('clear')
def portfolioManager(portfolio): while (True): name = raw_input("Enter Profile name: ") if name != 'quit': while(True): ticker = raw_input('enter ticker(quit to quit): ') quote = trader.getCurrentPriceFromTicker(ticker) if quote: price = enterNumber("Enter price: ") numbers = enterNumber("Enter quantity: ") date = getDate("Enter date: (YYYY-MM-DD): ") addToPortfolio(name , (trader.getCompanyName(ticker) , ticker, date, price, numbers , numbers * price) , portfolio ) elif ticker != 'quit': print 'wrong ticker try again' else: break else: saveToFile(portfolio) break