Exemplo n.º 1
0
    def end_snoop_generate_volatility_report(self, volatility_dict: Dict[str,
                                                                         Any],
                                             output_type: str):
        """
        End the snooping process and generate a volatility report.
        :param volatility_dict: Volatility dictionary containing snooped information.
        :param output_type: Output type in which to generate a report. (xlsx and csv supported)
        """
        self.volatilityStatus.setText(
            "Finished snooping. Generating report...")
        self.volatilityProgressBar.setValue(100)
        folder_path = create_folder("Volatility Results")
        file_name = f'Volatility_Results_{datetime.now().strftime("%m_%d_%Y_%H_%M_%S")}.{output_type.lower()}'
        file_path = os.path.join(folder_path, file_name)

        df = pd.DataFrame(list(volatility_dict.items()),
                          columns=['Ticker', 'Volatility'])
        if output_type.lower() == 'csv':
            df.to_csv(file_path, index=False)
        elif output_type.lower() == 'xlsx':
            df.to_excel(file_path, index=False)
        else:
            raise ValueError(
                f"Unknown type of output type: {output_type} provided.")

        self.volatilityStatus.setText(f"Generated report at {file_path}.")

        if open_from_msg_box(text='Do you want to open the volatility report?',
                             title='Volatility Report'):
            open_file_or_folder(file_path)
Exemplo n.º 2
0
    def end_csv_generation(self, savedPath: str):
        """
        After getting a successful end signal from thread, it modifies GUI to reflect this action. It also opens up a
        pop-up asking the user if they want to open the file right away.
        :param savedPath: Path where the file was saved.
        """
        msg = f"Successfully saved CSV data to {savedPath}."

        self.csvGenerationStatus.setText(msg)
        self.csvGenerationProgressBar.setValue(100)
        self.generateCSVButton.setEnabled(True)

        if open_from_msg_box(
                text=f"Successfully saved CSV data to {savedPath}.",
                title="Data saved successfully."):
            open_file_or_folder(savedPath)
Exemplo n.º 3
0
    def end_csv_generation(self, savedPath):
        """
        After getting a successful end signal from thread, it modifies GUI to reflect this action. It also opens up a
        pop-up asking the user if they want to open the file right away.
        :param savedPath: Path where the file was saved.
        """
        msg = f"Successfully saved CSV data to {savedPath}."

        self.csvGenerationStatus.setText(msg)
        self.csvGenerationProgressBar.setValue(100)
        self.generateCSVButton.setEnabled(True)

        msgBox = QMessageBox()
        msgBox.setIcon(QMessageBox.Information)
        msgBox.setText(f"Successfully saved CSV data to {savedPath}.")
        msgBox.setWindowTitle("Data saved successfully.")
        msgBox.setStandardButtons(QMessageBox.Open | QMessageBox.Close)
        if msgBox.exec_() == QMessageBox.Open:
            helpers.open_file_or_folder(savedPath)
Exemplo n.º 4
0
    def end_snoop_generate_volatility_report(self, volatility_dict,
                                             output_type):
        self.volatilityStatus.setText(
            "Finished snooping. Generating report...")
        self.volatilityProgressBar.setValue(100)
        folder_path = helpers.create_folder("Volatility Results")
        file_name = f'Volatility_Results_{datetime.now().strftime("%m_%d_%Y_%H_%M_%S")}.{output_type.lower()}'
        file_path = os.path.join(folder_path, file_name)

        df = pd.DataFrame(list(volatility_dict.items()),
                          columns=['Ticker', 'Volatility'])
        if output_type.lower() == 'csv':
            df.to_csv(file_path, index=False)
        elif output_type.lower() == 'xlsx':
            df.to_excel(file_path, index=False)
        else:
            raise ValueError(
                f"Unknown type of output type: {output_type} provided.")

        self.volatilityStatus.setText(f"Generated report at {file_path}.")

        if open_from_msg_box(text='Do you want to open the volatility report?',
                             title='Volatility Report'):
            helpers.open_file_or_folder(file_path)