Ejemplo n.º 1
0
def test_plot_volume_open_interest(max_sp, min_sp, min_vol, mocker):
    # MOCK CHARTS
    mocker.patch.object(target=tradier_view.gtff,
                        attribute="USE_ION",
                        new=True)
    mocker.patch(
        target="gamestonk_terminal.stocks.options.tradier_view.plt.ion")
    mocker.patch(
        target="gamestonk_terminal.stocks.options.tradier_view.plt.show")

    # MOCK EXPORT_DATA
    mocker.patch(
        target="gamestonk_terminal.stocks.options.tradier_view.export_data")

    # MOCK USE_COLOR
    mocker.patch.object(target=tradier_view.gtff,
                        attribute="USE_COLOR",
                        new=True)

    tradier_view.plot_volume_open_interest(
        ticker="PM",
        expiry="2022-01-07",
        min_sp=min_sp,
        max_sp=max_sp,
        min_vol=min_vol,
        export="",
    )
Ejemplo n.º 2
0
def test_plot_volume_open_interest(max_sp, min_sp, min_vol, mocker):
    # MOCK CHARTS
    mocker.patch(
        target="gamestonk_terminal.stocks.options.tradier_view.theme.visualize_output"
    )

    # MOCK EXPORT_DATA
    mocker.patch(target="gamestonk_terminal.stocks.options.tradier_view.export_data")

    # MOCK USE_COLOR
    mocker.patch.object(
        target=tradier_view.rich_config, attribute="USE_COLOR", new=True
    )

    tradier_view.plot_volume_open_interest(
        ticker="AAPL",
        expiry="2022-02-25",
        min_sp=min_sp,
        max_sp=max_sp,
        min_vol=min_vol,
        export="",
    )
Ejemplo n.º 3
0
 def call_voi(self, other_args: List[str]):
     """Process voi command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="voi",
         description="""Plots Volume + Open Interest of calls vs puts.""",
     )
     parser.add_argument(
         "-v",
         "--minv",
         dest="min_vol",
         type=float,
         default=-1,
         help=
         "minimum volume (considering open interest) threshold of the plot.",
     )
     parser.add_argument(
         "-m",
         "--min",
         dest="min_sp",
         type=float,
         default=-1,
         help="minimum strike price to consider in the plot.",
     )
     parser.add_argument(
         "-M",
         "--max",
         dest="max_sp",
         type=float,
         default=-1,
         help="maximum strike price to consider in the plot.",
     )
     parser.add_argument(
         "-s",
         "--source",
         type=str,
         default="tr",
         choices=self.voi_source_choices,
         dest="source",
         help="Source to get data from",
     )
     ns_parser = parse_known_args_and_warn(
         parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES)
     if ns_parser:
         if self.ticker:
             if self.selected_date:
                 if ns_parser.source == "tr" and TRADIER_TOKEN != "REPLACE_ME":
                     tradier_view.plot_volume_open_interest(
                         ticker=self.ticker,
                         expiry=self.selected_date,
                         min_sp=ns_parser.min_sp,
                         max_sp=ns_parser.max_sp,
                         min_vol=ns_parser.min_vol,
                         export=ns_parser.export,
                     )
                 else:
                     yfinance_view.plot_volume_open_interest(
                         ticker=self.ticker,
                         expiry=self.selected_date,
                         min_sp=ns_parser.min_sp,
                         max_sp=ns_parser.max_sp,
                         min_vol=ns_parser.min_vol,
                         export=ns_parser.export,
                     )
             else:
                 print("No expiry loaded. First use `exp {expiry date}`\n")
         else:
             print("No ticker loaded. First use `load <ticker>`\n")