def call_rnval(self, other_args: List[str]):
     """Process rnval command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="rnval",
         description="The risk neutral value of the options",
     )
     parser.add_argument(
         "-p",
         "--put",
         action="store_true",
         default=False,
         help="Show puts instead of calls",
     )
     parser.add_argument(
         "-m",
         "--min",
         type=float,
         default=None,
         dest="mini",
         help="Minimum strike price shown",
     )
     parser.add_argument(
         "-M",
         "--max",
         type=float,
         default=None,
         dest="maxi",
         help="Maximum strike price shown",
     )
     parser.add_argument(
         "-r",
         "--risk",
         type=float,
         default=None,
         dest="risk",
         help="The risk-free rate to use",
     )
     ns_parser = parse_known_args_and_warn(parser, other_args)
     if ns_parser:
         if self.ticker:
             if self.selected_date:
                 if sum(self.prices["Chance"]) == 1:
                     yfinance_view.risk_neutral_vals(
                         self.ticker,
                         self.selected_date,
                         ns_parser.put,
                         self.prices,
                         ns_parser.mini,
                         ns_parser.maxi,
                         ns_parser.risk,
                     )
                 else:
                     console.print("Total chances must equal one\n")
             else:
                 console.print(
                     "No expiry loaded. First use `exp {expiry date}`\n")
         else:
             console.print("No ticker loaded. First use `load <ticker>`\n")
Esempio n. 2
0
def test_risk_neutral_vals(mocker):
    # MOCK CHARTS
    mocker.patch(
        target=
        "gamestonk_terminal.stocks.options.yfinance_view.theme.visualize_output"
    )

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

    yfinance_view.risk_neutral_vals(
        ticker="PM",
        exp="2022-01-07",
        put=True,
        df=pd.DataFrame(columns=["Price", "Chance"]),
        mini=None,
        maxi=None,
        risk=None,
    )
Esempio n. 3
0
def test_risk_neutral_vals(mocker):
    # MOCK CHARTS
    mocker.patch.object(target=yfinance_view.gtff,
                        attribute="USE_ION",
                        new=True)
    mocker.patch(
        target="gamestonk_terminal.stocks.options.yfinance_view.plt.ion")
    mocker.patch(
        target="gamestonk_terminal.stocks.options.yfinance_view.plt.show")

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

    yfinance_view.risk_neutral_vals(
        ticker="PM",
        exp="2022-01-07",
        put=True,
        df=pd.DataFrame(columns=["Price", "Chance"]),
        mini=None,
        maxi=None,
        risk=None,
    )