def test_unusual_options(recorder):
    result_tuple = fdscanner_model.unusual_options(num=5)
    result_tuple = (
        result_tuple[0],
        result_tuple[1].isoformat(),
    )

    recorder.capture_list(result_tuple)
def test_unusual_options_invalid_status(mocker):
    mock_response = requests.Response()
    mock_response.status_code = 400
    mocker.patch(target="requests.get",
                 new=mocker.Mock(return_value=mock_response))

    result_tuple = fdscanner_model.unusual_options(num=5)

    assert result_tuple[0].empty
    assert isinstance(result_tuple[1], str)
Ejemplo n.º 3
0
def display_options(
    num: int,
    sort_column: pd.Timestamp,
    export: str = "",
    ascending: bool = False,
    calls_only: bool = False,
    puts_only: bool = False,
):
    """Displays the unusual options table

    Parameters
    ----------
    num: int
        Number of rows to show
    sort_columns: pd.Timestamp
        Data column to sort on
    export: str
        File type to export
    ascending: bool
        Whether to sort in ascending order
    calls_only : bool
        Flag to only show calls
    puts_only : bool
        Flag to show puts only
    """
    data, last_update = fdscanner_model.unusual_options(num)
    data = data.sort_values(by=sort_column, ascending=ascending)
    if puts_only:
        data = data[data.Type == "Put"]
    if calls_only:
        data = data[data.Type == "Call"]
    print(f"Last Updated: {last_update} (EST)")
    if gtff.USE_TABULATE_DF:
        print(
            tabulate(
                data[:num],
                headers=data.columns,
                tablefmt="fancy_grid",
                showindex=False,
                floatfmt=[
                    "", "", ".1f", "", ".1f", ".0f", ".0f", ".2f", ".2f"
                ],
            ))
    else:
        print(data[:num].to_string())
    print("")

    if export:
        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "unu_",
            data,
        )
Ejemplo n.º 4
0
def display_options(
    num: int,
    sort_column: pd.Timestamp,
    export: str = "",
    ascending: bool = False,
    calls_only: bool = False,
    puts_only: bool = False,
):
    """Displays the unusual options table

    Parameters
    ----------
    num: int
        Number of rows to show
    sort_columns: pd.Timestamp
        Data column to sort on
    export: str
        File type to export
    ascending: bool
        Whether to sort in ascending order
    calls_only : bool
        Flag to only show calls
    puts_only : bool
        Flag to show puts only
    """
    data, last_update = fdscanner_model.unusual_options(num)
    data = data.sort_values(by=sort_column, ascending=ascending)
    if puts_only:
        data = data[data.Type == "Put"]
    if calls_only:
        data = data[data.Type == "Call"]
    print_rich_table(
        data[:num],
        headers=list(data.columns),
        show_index=False,
        title=f"Last Updated: {last_update} (EST)",
    )
    console.print("")

    if export:
        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "unu_",
            data,
        )