def call_dd(self, other_args: List[str]): """Process DD command""" due_diligence_view.due_diligence(other_args)
def screener(other_args: List[str], loaded_preset: str, data_type: str) -> List[str]: """Screener Parameters ---------- other_args : List[str] Command line arguments to be processed with argparse ticker : str Loaded preset filter data_type : str Data type string between: overview, valuation, financial, ownership, performance, technical Returns ------- List[str] List of stocks that meet preset criteria """ parser = argparse.ArgumentParser( add_help=False, prog="screener", description=""" Prints screener data of the companies that meet the pre-set filtering. The following information fields are expected: overview, valuation, financial, ownership, performance, technical. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz] """, ) parser.add_argument( "-p", "--preset", action="store", dest="preset", type=str, default=loaded_preset, help="Filter presets", choices=[ preset.split(".")[0] for preset in os.listdir(presets_path) if preset[-4:] == ".ini" ], ) parser.add_argument( "-s", "--signal", action="store", dest="signal", type=str, default=None, help="Signal", choices=list(d_signals.keys()), ) parser.add_argument( "-l", "--limit", action="store", dest="limit", type=check_positive, default=0, help="Limit of stocks to print", ) parser.add_argument( "-a", "--ascend", action="store_true", default=False, dest="ascend", help="Set order to Ascend, the default is Descend", ) parser.add_argument( "-e", "--export", action="store_true", dest="exportFile", help="Save list as a text file", ) parser.add_argument( "-m", "--mill", action="store_true", dest="mill", help="Run papermill on list", ) try: ns_parser = parse_known_args_and_warn(parser, other_args) if not ns_parser: return [] df_screen = get_screener_data( ns_parser.preset, data_type, ns_parser.signal, ns_parser.limit, ns_parser.ascend, ) if isinstance(df_screen, pd.DataFrame): print(df_screen.to_string()) print("") if ns_parser.exportFile: now = datetime.now() if not os.path.exists("reports/screener"): os.makedirs("reports/screener") with open( f"reports/screener/{ns_parser.signal}-{now.strftime('%Y-%m-%d_%H:%M:%S')}", "w", ) as file: file.write(df_screen.to_string(index=False) + "\n") if ns_parser.mill: for i in range(len(df_screen)): ticker = [df_screen.iat[i, 0]] due_diligence_view.due_diligence(ticker, show=False) return list(df_screen["Ticker"].values) print("") return [] except Exception as e: print(e) print("") return []