Exemple #1
0
 def call_finbrain(self, other_args: List[str]):
     """Process finbrain command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="finbrain",
         description=
         """FinBrain collects the news headlines from 15+ major financial news
                     sources on a daily basis and analyzes them to generate sentiment scores
                     for more than 4500 US stocks.FinBrain Technologies develops deep learning
                     algorithms for financial analysis and prediction, which currently serves
                     traders from more than 150 countries all around the world.
                     [Source:  https://finbrain.tech]""",
     )
     parser.add_argument(
         "--export",
         choices=["csv", "json", "xlsx"],
         default="",
         type=str,
         dest="export",
         help="Export dataframe data to csv,json,xlsx file",
     )
     try:
         ns_parser = parse_known_args_and_warn(parser, other_args)
         if not ns_parser:
             return
         if self._check_ticker():
             finbrain_view.display_sentiment_analysis(
                 ticker=self.ticker, export=ns_parser.export)
     except Exception as e:
         print(e, "\n")
Exemple #2
0
 def call_headlines(self, other_args: List[str]):
     """Process finbrain command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="headlines",
         description=
         """FinBrain collects the news headlines from 15+ major financial news
                     sources on a daily basis and analyzes them to generate sentiment scores
                     for more than 4500 US stocks.FinBrain Technologies develops deep learning
                     algorithms for financial analysis and prediction, which currently serves
                     traders from more than 150 countries all around the world.
                     [Source:  https://finbrain.tech]""",
     )
     ns_parser = parse_known_args_and_warn(
         parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES)
     if ns_parser:
         if self.ticker:
             finbrain_view.display_sentiment_analysis(
                 ticker=self.ticker, export=ns_parser.export)
         else:
             print("No ticker loaded. Please load using 'load <ticker>'\n")
Exemple #3
0
def test_display_sentiment_analysis_empty_df(mocker):
    view = "gamestonk_terminal.common.behavioural_analysis.finbrain_view"

    # MOCK EXPORT_DATA
    mocker.patch(
        target=
        "gamestonk_terminal.common.behavioural_analysis.finbrain_view.export_data"
    )

    # MOCK GTFF
    mocker.patch.object(target=helper_funcs.gtff,
                        attribute="USE_ION",
                        new=True)

    # MOCK GET_SENTIMENT
    mocker.patch(
        target=f"{view}.finbrain_model.get_sentiment",
        return_value=pd.DataFrame(),
    )

    finbrain_view.display_sentiment_analysis(
        ticker="AAPL",
        export="",
    )
Exemple #4
0
def test_display_sentiment_analysis(color, mocker):
    # MOCK EXPORT_DATA
    mocker.patch(
        target=
        "gamestonk_terminal.common.behavioural_analysis.finbrain_view.export_data"
    )

    # MOCK GTFF
    mocker.patch.object(target=helper_funcs.gtff,
                        attribute="USE_ION",
                        new=True)
    mocker.patch.object(target=finbrain_view.rich_config,
                        attribute="USE_COLOR",
                        new=color)

    # MOCK VISUALIZE_OUTPUT
    mocker.patch(
        target=
        "gamestonk_terminal.helper_classes.TerminalStyle.visualize_output")

    finbrain_view.display_sentiment_analysis(
        ticker="AAPL",
        export="",
    )