예제 #1
0
def test_plot_oi(calls_only, max_sp, min_sp, mocker, puts_only):
    # 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.gtff,
                        attribute="USE_COLOR",
                        new=True)

    tradier_view.plot_oi(
        ticker="AAPL",
        expiry="2022-02-25",
        min_sp=min_sp,
        max_sp=max_sp,
        calls_only=calls_only,
        puts_only=puts_only,
        export="",
    )
예제 #2
0
def test_plot_oi(calls_only, max_sp, min_sp, mocker, puts_only):
    # 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_oi(
        ticker="PM",
        expiry="2022-01-07",
        min_sp=min_sp,
        max_sp=max_sp,
        calls_only=calls_only,
        puts_only=puts_only,
        export="",
    )
 def call_oi(self, other_args: List[str]):
     """Process oi command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="oi",
         description=
         "Plot open interest.  Open interest represents the number of contracts that exist.",
     )
     parser.add_argument(
         "-m",
         "--min",
         default=-1,
         type=float,
         help="Min strike to plot",
         dest="min",
     )
     parser.add_argument(
         "-M",
         "--max",
         default=-1,
         type=float,
         help="Max strike to plot",
         dest="max",
     )
     parser.add_argument(
         "-c",
         "--calls",
         action="store_true",
         default=False,
         dest="calls",
         help="Flag to plot call options only",
     )
     parser.add_argument(
         "-p",
         "--puts",
         action="store_true",
         default=False,
         dest="puts",
         help="Flag to plot put options only",
     )
     parser.add_argument(
         "-s",
         "--source",
         type=str,
         default="tr",
         choices=self.oi_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_oi(
                         ticker=self.ticker,
                         expiry=self.selected_date,
                         min_sp=ns_parser.min,
                         max_sp=ns_parser.max,
                         calls_only=ns_parser.calls,
                         puts_only=ns_parser.puts,
                         export=ns_parser.export,
                     )
                 else:
                     yfinance_view.plot_oi(
                         ticker=self.ticker,
                         expiry=self.selected_date,
                         min_sp=ns_parser.min,
                         max_sp=ns_parser.max,
                         calls_only=ns_parser.calls,
                         puts_only=ns_parser.puts,
                         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")