def parse_and_plot(self): # Parse the text in the input box and call the plotter function. Show a # message box with errors if anything is wrong. # Get the text from the input field, and create the dataframe. stock_ids = self.stocks_input.text() stocks = pd.DataFrame() # If there's no text in the box, we shouldn't do anything. if not stock_ids: return QtGui.QMessageBox.information( self, "Loading", "The stocks are downloading, " "please wait.") # Split the text typed by the user, which will contain the stock names. # Then download these stocks, and add them to the DataFrame that will be # plotted. # Catch any exceptions raised, and show error messages accordingly. try: for id in stock_ids.split(', '): try: plotter.addStock(stocks, id) except pd.parser.CParserError: # If the stock's id is invalid, a webpage will be # downloaded (the one that is shown in case of a 404 # error), instead of the file we're trying to # download. If this happens, we'll show a message to the user. QtGui.QMessageBox.critical( self, "Error", "The stock or index %s doesn't exist, make sure " "you've correctly written its name." % id) except IOError: # The user is not connected to the Internet. QtGui.QMessageBox.critical( self, "Error", "The stocks couldn't be downloaded, make sure " "you have an Internet connection.") # If we succeeded in downloading at least one stock, we'll make a chart. if not stocks.empty: plotter.chart(stocks)
def parse_and_plot(self): # Parse the text in the input box and call the plotter function. Show a # message box with errors if anything is wrong. # Get the text from the input field, and create the dataframe. stock_ids = self.stocks_input.text() stocks = pd.DataFrame() # If there's no text in the box, we shouldn't do anything. if not stock_ids: return QtGui.QMessageBox.information(self, "Cargando", "Se estan descargando las acciones, " "por favor espere") # Split the text typed by the user, which will contain the stock names. # Then download these stocks, and add them to the DataFrame that will be # plotted. # Catch any exceptions raised, and show error messages accordingly. try: for id in stock_ids.split(', '): try: plotter.addStock(stocks, id) except pd.parser.CParserError: # If the stock's id is invalid, a webpage will be # downloaded (the one that is shown in case of a 404 # error), instead of the file we're trying to # download. If this happens, we'll show a message to the user. QtGui.QMessageBox.critical(self, "Error", "La accion o indice %s no existe, asegurese " "de haber escrito correctamente el nombre de este " "titulo." % id) except IOError: # The user is not connected to the Internet. QtGui.QMessageBox.critical(self, "Error", "No se pueden agregar las acciones, asegurese " "de estar conectado a Internet.") # If we succeeded in downloading at least one stock, we'll make a chart. if not stocks.empty: plotter.chart(stocks)
def _chart(pool_size, function_name): plotter.chart(pool_size, function_name)