Beispiel #1
0
def display_etf_by_name(name: str, limit: int, export: str):
    """Display ETFs matching search string. [Source: StockAnalysis]

    Parameters
    ----------
    name: str
        String being matched
    limit: int
        Limit of ETFs to display
    export: str
        Export to given file type

    """
    matching_etfs = stockanalysis_model.get_etfs_by_name(name)

    print_rich_table(
        matching_etfs.head(limit),
        show_index=False,
        title="ETF Search Result",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "ln_sa",
        matching_etfs,
    )
def display_etf_by_name(name: str, limit: int, export: str):
    """Display ETFs matching search string. [Source: StockAnalysis]

    Parameters
    ----------
    name: str
        String being matched
    limit: int
        Limit of ETFs to display
    export: str
        Export to given file type

    """
    matching_etfs = stockanalysis_model.get_etfs_by_name(name)

    if gtff.USE_TABULATE_DF:
        print(
            tabulate(
                matching_etfs.head(limit),
                showindex=False,
                tablefmt="fancy_grid",
            ),
            "\n",
        )
    else:
        print(matching_etfs.head(limit).to_string(), "\n")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "ln_sa",
        matching_etfs,
    )
def test_get_etfs_by_name(recorder, name_to_search):
    result_df = stockanalysis_model.get_etfs_by_name(name_to_search)

    assert not result_df.empty
    recorder.capture(result_df)