def valinvest_score(other_args: List[str], ticker: str): """Value investing tool based on Warren Buffett, Joseph Piotroski and Benjamin Graham thoughts [Source: FMP] Parameters ---------- other_args : List[str] argparse other args ticker : str Fundamental analysis ticker symbol """ parser = argparse.ArgumentParser( add_help=False, prog="score", description=""" Value investing tool based on Warren Buffett, Joseph Piotroski and Benjamin Graham thoughts [Source: FMP] """, ) try: ns_parser = parse_known_args_and_warn(parser, other_args) if not ns_parser: return valstock = valinvest.Fundamental(ticker, cfg.API_KEY_FINANCIALMODELINGPREP) score = 100 * (valstock.fscore() / 9) print(f"Score: {score:.2f}".rstrip("0").rstrip(".") + " %") print("") except Exception as e: print(e, "\n") return
def get_score(ticker: str) -> Optional[np.number]: """Gets value score from fmp Parameters ---------- ticker : str Stock ticker Returns ------- np.number Value score """ value_score = None try: valstock = valinvest.Fundamental(ticker, cfg.API_KEY_FINANCIALMODELINGPREP) value_score = 100 * (valstock.fscore() / 9) except KeyError: console.print("[red]Invalid API Key[/red]\n") # Invalid ticker (Ticker should be a NASDAQ 100 ticker or SP 500 ticker) except ValueError as e: console.print(e, "\n") return value_score
def get_score(ticker: str) -> np.number: """Gets value score from fmp Parameters ---------- ticker : str Stock ticker Returns ------- np.number Value score """ valstock = valinvest.Fundamental(ticker, cfg.API_KEY_FINANCIALMODELINGPREP) return 100 * (valstock.fscore() / 9)