Beispiel #1
0
def display_borrow_rates(top: int,
                         current: bool = True,
                         export: str = "") -> None:
    """Displays DeFi borrow rates. By using smart contracts, borrowers are able to lock
    collateral to protect against defaults while seamlessly adding to or closing their
    loans at any time.

    [Source: https://defirate.com/]

    Parameters
    ----------
    top: int
        Number of records to display
    current: bool
        If true displays current funding rate values. If false displays last 30 day average of funding rates.
    export : str
        Export dataframe data to csv,json,xlsx file
    """
    df = defirate_model.get_borrow_rates(current)
    df_data = df.copy()
    df = df.loc[:, ~df.eq("–").all()]

    if gtff.USE_TABULATE_DF:
        print(
            tabulate(
                df.head(top),
                headers=df.columns,
                floatfmt=".2f",
                showindex=False,
                tablefmt="fancy_grid",
            ),
            "\n",
        )
    else:
        print(df.to_string, "\n")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "borrow",
        df_data,
    )
Beispiel #2
0
def display_borrow_rates(top: int,
                         current: bool = True,
                         export: str = "") -> None:
    """Displays DeFi borrow rates. By using smart contracts, borrowers are able to lock
    collateral to protect against defaults while seamlessly adding to or closing their
    loans at any time.

    [Source: https://defirate.com/]

    Parameters
    ----------
    top: int
        Number of records to display
    current: bool
        If true displays current funding rate values. If false displays last 30 day average of funding rates.
    export : str
        Export dataframe data to csv,json,xlsx file
    """
    df = defirate_model.get_borrow_rates(current)
    df_data = df.copy()
    df = df.loc[:, ~df.eq("–").all()]

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="DeFi Borrow Rates",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "borrow",
        df_data,
    )
def test_get_borrow_rates(recorder):
    df = defirate_model.get_borrow_rates(current=True)
    recorder.capture(df)