Exemple #1
0
def test_historical_no_d_signals(mocker):
    # FORCE SINGLE THREADING
    yf_download = yahoofinance_view.yf.download

    def mock_yf_download(*args, **kwargs):
        kwargs["threads"] = False
        return yf_download(*args, **kwargs)

    mocker.patch(
        "gamestonk_terminal.stocks.screener.yahoofinance_view.yf.download",
        side_effect=mock_yf_download,
    )

    # MOCK CHARTS
    mocker.patch.object(target=yahoofinance_view.gtff,
                        attribute="USE_ION",
                        new=True)
    mocker.patch(
        target="gamestonk_terminal.stocks.screener.yahoofinance_view.plt.ion")
    mocker.patch(
        target="gamestonk_terminal.stocks.screener.yahoofinance_view.plt.show")

    # MOCK EXPORT_DATA
    mocker.patch(
        target="gamestonk_terminal.stocks.screener.finviz_view.export_data", )

    # MOCK PROGRESS_BAR
    mocker.patch(target="finvizfinance.screener.overview.progressBar", )

    # MOCK EXPORT_DATA
    mocker.patch(target="random.shuffle", )

    # MOCK D_SIGNALS
    mocker.patch.object(
        target=yahoofinance_view.finviz_model,
        attribute="d_signals",
        new=[],
    )

    yahoofinance_view.historical(
        preset_loaded="oversold",
        limit=2,
        start=datetime.strptime("2022-01-03", "%Y-%m-%d"),
        type_candle="a",
        normalize=True,
        export="",
    )
Exemple #2
0
 def call_historical(self, other_args: List[str]):
     """Process historical command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         prog="historical",
         description=
         """Historical price comparison between similar companies [Source: Yahoo Finance]
         """,
     )
     parser.add_argument(
         "-l",
         "--limit",
         action="store",
         dest="limit",
         type=check_positive,
         default=10,
         help="Limit of the most shorted stocks to retrieve.",
     )
     parser.add_argument(
         "-n",
         "--no-scale",
         action="store_false",
         dest="no_scale",
         default=False,
         help="Flag to not put all prices on same 0-1 scale",
     )
     parser.add_argument(
         "-s",
         "--start",
         type=valid_date,
         default=datetime.datetime.now() - datetime.timedelta(days=6 * 30),
         dest="start",
         help=
         "The starting date (format YYYY-MM-DD) of the historical price to plot",
     )
     parser.add_argument(
         "-t",
         "--type",
         action="store",
         dest="type_candle",
         choices=self.historical_candle_choices,
         default="a",  # in case it's adjusted close
         help=
         "type of candles: o-open, h-high, l-low, c-close, a-adjusted close.",
     )
     if other_args and "-" not in other_args[0][0]:
         other_args.insert(0, "-l")
     ns_parser = parse_known_args_and_warn(
         parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES)
     if ns_parser:
         self.screen_tickers = yahoofinance_view.historical(
             self.preset,
             ns_parser.limit,
             ns_parser.start,
             ns_parser.type_candle,
             not ns_parser.no_scale,
             ns_parser.export,
         )
Exemple #3
0
def test_historical(mocker):
    # FORCE SINGLE THREADING
    yf_download = yahoofinance_view.yf.download

    def mock_yf_download(*args, **kwargs):
        kwargs["threads"] = False
        return yf_download(*args, **kwargs)

    mocker.patch(
        "gamestonk_terminal.stocks.screener.yahoofinance_view.yf.download",
        side_effect=mock_yf_download,
    )

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

    # MOCK EXPORT_DATA
    mocker.patch(
        target="gamestonk_terminal.stocks.screener.finviz_view.export_data", )

    # MOCK PROGRESS_BAR
    mocker.patch(target="finvizfinance.screener.overview.progress_bar", )

    # MOCK EXPORT_DATA
    mocker.patch(target="random.shuffle", )

    yahoofinance_view.historical(
        preset_loaded="top_gainers",
        limit=2,
        start=datetime.strptime("2022-01-03", "%Y-%m-%d"),
        type_candle="a",
        normalize=True,
        export="",
    )
Exemple #4
0
 def call_historical(self, other_args: List[str]):
     """Process historical command"""
     self.screen_tickers = yahoofinance_view.historical(
         other_args, self.preset)