def get_data(self): ''' Load option-chain data: if you have it on file use that, otherwise download it from the web ''' print('from get_data', mylib.num_of_paths_to_simulate) self.statusBar().showMessage('Loading Option data.. (this might take a minute or two)') self.tick_str = self.le.text() # Check if you have it on file filenm = mylib.filename_from_ticker_sym(self.tick_str) self.spy_data = mylib.retrieve_option_chain_from_file(filenm) # Not on file? well, download it if self.spy_data.empty: self.statusBar().showMessage('Downloading Option data from the web.. (this might take a few minutes)') self.spy_data = mylib.retrieve_option_chain(self.tick_str) if self.spy_data.empty: QtGui.QMessageBox.warning(self, 'Message', 'Error while downloading option data. \nPlease double-check the ticker symbol is correct', buttons = QtGui.QMessageBox.Ok) return # Go to the next step self.check_ready_to_munch_numbers()
def load_option_chain_file(self): ''' Load option-chain data from file. This serves the case of not being able to download a fresh copy or the case of the US stock exchange being closed right now ''' self.statusBar().showMessage('Loading Option Chain file') if not self.SimulPaths.empty: self.ask_to_reset_sim_paths() csv_filename = QtGui.QFileDialog.getOpenFileName(self, 'Open csv file') try: self.spy_data = mylib.retrieve_option_chain_from_file(csv_filename) except pd.parser.CParserError: self.spy_data = pd.DataFrame() QtGui.QMessageBox.warning(self, 'Impossible to load file', 'Not able to load the selected file. \ \nFile should be one automatically created from a previous run of this App\ \n\n(It should look something like "2016-01-16_SPYoptionChain.csv")', buttons = QtGui.QMessageBox.Ok) # Go to next step self.check_ready_to_munch_numbers()