Exemplo n.º 1
0
def display_token_historical_prices(
    address: str,
    top: int = 30,
    sortby: str = "date",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display token historical prices with volume and market cap, and average price. [Source: Ethplorer]

    Parameters
    ----------
    address: str
        Token balance e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984
    top: int
        Limit of transactions. Maximum 100
    sortby: str
        Key to sort by.
    descend: str
        Sort in descending order.
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_token_historical_price(address)
    df_data = df.copy()

    if df.empty:
        console.print(f"No results found for balance: {address}\n")
        return

    df["volumeConverted"] = df["volumeConverted"].apply(
        lambda x: lambda_very_long_number_formatter(x))
    df["cap"] = df["cap"].apply(lambda x: lambda_very_long_number_formatter(x))
    df = df.sort_values(by=sortby, ascending=descend)

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Historical Token Prices",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "prices",
        df_data,
    )
Exemplo n.º 2
0
def display_ethereum_unique_senders(
    interval: str = "days",
    limit: int = 10,
    sortby: str = "date",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display number of unique ethereum addresses which made a transaction in given time interval
     [Source: https://graphql.bitquery.io/]

    Parameters
    ----------
    interval: str
        Time interval in which ethereum address made transaction. month, week or day
    limit: int
        Number of records to display. It's calculated base on provided interval.
        If interval is month then calculation is made in the way: limit * 30 = time period,
        in case if interval is set to week, then time period is calculated as limit * 7.
        For better user experience maximum time period in days is equal to 90.
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    Returns
    -------
    pd.DataFrame
        Number of unique ethereum addresses which made a transaction in given time interval
    """

    df = bitquery_model.get_ethereum_unique_senders(interval, limit)
    if not df.empty:

        df = df.sort_values(by=sortby, ascending=descend)

        df[["uniqueSenders", "transactions", "maximumGasPrice"]] = df[[
            "uniqueSenders", "transactions", "maximumGasPrice"
        ]].applymap(lambda x: lambda_very_long_number_formatter(x))

        df_data = df.copy()
        df.columns = prettify_column_names(df.columns)

        print_rich_table(
            df,
            headers=list(df.columns),
            show_index=False,
            title="Unique Ethereum Addresses",
        )
        console.print("")

        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "ueat",
            df_data,
        )
Exemplo n.º 3
0
def display_dex_volume_for_token(
    token: str = "WBTC",
    trade_amount_currency: str = "USD",
    top: int = 10,
    sortby: str = "tradeAmount",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display token volume on different Decentralized Exchanges. [Source: https://graphql.bitquery.io/]

    Parameters
    ----------
    token: str
        ERC20 token symbol or address
    trade_amount_currency: str
        Currency of displayed trade amount. Default: USD
    top: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    Returns
    -------
    pd.DataFrame
        Token volume on different decentralized exchanges
    """

    df = bitquery_model.get_token_volume_on_dexes(
        token=token, trade_amount_currency=trade_amount_currency)
    if not df.empty:
        df = df.sort_values(by=sortby, ascending=descend)

        df_data = df.copy()
        df[["tradeAmount", "trades"]] = df[[
            "tradeAmount", "trades"
        ]].applymap(lambda x: lambda_very_long_number_formatter(x))

        df.columns = prettify_column_names(df.columns)

        print_rich_table(
            df.head(top),
            headers=list(df.columns),
            show_index=False,
            title="Token Volume on Exchanges",
        )
        console.print("")

        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "tv",
            df_data,
        )
def display_coins(category: str,
                  top: int = 250,
                  sortby: str = "Symbol",
                  export: str = "") -> None:
    """Display top coins [Source: CoinGecko]

    Parameters
    ----------
    category: str
        Coingecko category. If no category is passed it will search for all coins. (E.g., smart-contract-platform)
    top: int
        Number of records to display
    sortby: str
        Key to sort data
    export : str
        Export dataframe data to csv,json,xlsx file
    """
    df = pycoingecko_model.get_coins(top=top, category=category)
    if not df.empty:
        df = df[[
            "symbol",
            "name",
            "total_volume",
            "market_cap",
            "market_cap_rank",
            "price_change_percentage_7d_in_currency",
            "price_change_percentage_24h_in_currency",
        ]]
        df = df.set_axis(
            COINS_COLUMNS,
            axis=1,
            inplace=False,
        )
        if sortby in COINS_COLUMNS:
            df = df[(df["Volume [$]"].notna())
                    & (df["Market Cap [$]"].notna())].sort_values(
                        by=sortby, ascending=False)
        for col in ["Volume [$]", "Market Cap [$]"]:
            if col in df.columns:
                df[col] = df[col].apply(
                    lambda x: lambda_very_long_number_formatter(x))
        print_rich_table(
            df.head(top),
            headers=list(df.columns),
            show_index=False,
        )
        console.print("")

        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "cgtop",
            df,
        )
    else:
        console.print("\nUnable to retrieve data from CoinGecko.\n")
Exemplo n.º 5
0
def display_token_history(
    address: str,
    top: int = 10,
    sortby: str = "timestamp",
    hash_: bool = False,
    descend: bool = False,
    export: str = "",
) -> None:
    """Display info about token history. [Source: Ethplorer]

    Parameters
    ----------
    address: str
        Token balance e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984
    top: int
        Limit of transactions. Maximum 100
    sortby: str
        Key to sort by.
    descend: str
        Sort in descending order.
    hash_: bool,
        Flag to show transaction hash.
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_token_history(address)
    df_data = df.copy()
    if df.empty:
        console.print(f"No results found for balance: {address}\n")
        return

    df["value"] = df["value"].apply(
        lambda x: lambda_very_long_number_formatter(x))
    df = df.sort_values(by=sortby, ascending=descend)

    if hash_:
        df.drop(["from", "to"], axis=1, inplace=True)
    else:
        df.drop("transactionHash", inplace=True, axis=1)

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Token History Information",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "th",
        df_data,
    )
Exemplo n.º 6
0
def display_most_traded_pairs(
    exchange="Uniswap",
    days: int = 10,
    top: int = 10,
    sortby: str = "tradeAmount",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display most traded crypto pairs on given decentralized exchange in chosen time period.
     [Source: https://graphql.bitquery.io/]

    Parameters
    ----------
    exchange:
        Decentralized exchange name
    days:
        Number of days taken into calculation account.
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    Returns
    -------
    pd.DataFrame
        Most traded crypto pairs on given decentralized exchange in chosen time period.
    """

    df = bitquery_model.get_most_traded_pairs(exchange=exchange, limit=days)
    if not df.empty:
        df = df.sort_values(by=sortby, ascending=descend)
        df_data = df.copy()
        df[["tradeAmount", "trades"]] = df[[
            "tradeAmount", "trades"
        ]].applymap(lambda x: lambda_very_long_number_formatter(x))
        df.columns = prettify_column_names(df.columns)

        print_rich_table(
            df.head(top),
            headers=list(df.columns),
            show_index=False,
            title="Most Traded Crypto Pairs",
        )
        console.print("")

        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "ttcp",
            df_data,
        )
Exemplo n.º 7
0
def display_uni_tokens(
    skip: int = 0,
    limit: int = 20,
    sortby: str = "index",
    descend: bool = True,
    export: str = "",
) -> None:
    """Displays tokens trade-able on Uniswap DEX.
    [Source: https://thegraph.com/en/]

    Parameters
    ----------
    skip: int
        Number of records to skip
    limit: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = graph_model.get_uni_tokens(skip=skip)
    df_data = df.copy()

    df = df.sort_values(by=sortby, ascending=descend)

    df[["totalLiquidity", "tradeVolumeUSD"
        ]] = df[["totalLiquidity", "tradeVolumeUSD"
                 ]].applymap(lambda x: lambda_very_long_number_formatter(x))

    print_rich_table(
        df.head(limit),
        headers=list(df.columns),
        show_index=False,
        title="UniSwarp DEX Trade-able Tokens",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "tokens",
        df_data,
    )
Exemplo n.º 8
0
def display_address_info(
    address: str,
    top: int = 15,
    sortby: str = "index",
    descend: bool = True,
    export: str = "",
) -> None:
    """Display info about tokens for given ethereum blockchain balance e.g. ETH balance, balance of all tokens with
    name and symbol. [Source: Ethplorer]

    Parameters
    ----------
    address: str
        Ethereum balance.
    top: int
        Limit of transactions. Maximum 100
    sortby: str
        Key to sort by.
    descend: str
        Sort in descending order.
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_address_info(address)
    df_data = df.copy()
    df = df.sort_values(by=sortby, ascending=descend)
    df["balance"] = df["balance"].apply(
        lambda x: lambda_very_long_number_formatter(x)
        if x >= 10000 else round(float(x), 4))

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Blockchain Token Information",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "balance",
        df_data,
    )
def display_gainers(period: str = "1h",
                    top: int = 20,
                    sortby: str = "Symbol",
                    export: str = "") -> None:
    """Shows Largest Gainers - coins which gain the most in given period. [Source: CoinGecko]

    Parameters
    ----------
    period: str
        Time period by which data is displayed. One from [1h, 24h, 7d, 14d, 30d, 60d, 1y]
    top: int
        Number of records to display
    sortby: str
        Key to sort data
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = pycoingecko_model.get_gainers_or_losers(top=top,
                                                 period=period,
                                                 typ="gainers")
    if not df.empty:
        if sortby in COINS_COLUMNS:
            df = df[(df["Volume [$]"].notna())
                    & (df["Market Cap [$]"].notna())].sort_values(
                        by=sortby, ascending=False)
        for col in ["Volume [$]", "Market Cap [$]"]:
            if col in df.columns:
                df[col] = df[col].apply(
                    lambda x: lambda_very_long_number_formatter(x))
        print_rich_table(
            df.head(top),
            headers=list(df.columns),
            show_index=False,
        )
        console.print("")

        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "gainers",
            df,
        )
    else:
        console.print("\nUnable to retrieve data from CoinGecko.\n")
Exemplo n.º 10
0
def display_address_history(
    address: str,
    top: int = 10,
    sortby: str = "timestamp",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display information about balance historical transactions. [Source: Ethplorer]

    Parameters
    ----------
    address: str
        Ethereum nlockchain balance e.g. 0x3cD751E6b0078Be393132286c442345e5DC49699
    top: int
        Limit of transactions. Maximum 100
    sortby: str
        Key to sort by.
    descend: str
        Sort in descending order.
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_address_history(address)
    df_data = df.copy()
    df = df.sort_values(by=sortby, ascending=descend)
    df["value"] = df["value"].apply(
        lambda x: lambda_very_long_number_formatter(x)
        if x >= 10000 else round(float(x), 4))

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Historical Transactions Information",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "hist",
        df_data,
    )
def display_validators(top: int = 10,
                       sortby: str = "votingPower",
                       descend: bool = False,
                       export: str = "") -> None:
    """Display information about terra validators [Source: https://fcd.terra.dev/swagger]

    Parameters
    ----------
    top: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = terramoney_fcd_model.get_validators()
    df_data = df.copy()
    df = df.sort_values(by=sortby, ascending=descend)
    df["tokensAmount"] = df["tokensAmount"].apply(
        lambda x: lambda_very_long_number_formatter(x))
    df.columns = [
        x
        if x not in ["Voting power", "Commission rate", "Uptime"] else f"{x} %"
        for x in prettify_column_names(df.columns)
    ]

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        floatfmt=".2f",
        show_index=False,
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "validators",
        df_data,
    )
Exemplo n.º 12
0
def display_top_token_holders(
    address: str,
    top: int = 10,
    sortby: str = "balance",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display info about top ERC20 token holders. [Source: Ethplorer]

    Parameters
    ----------
    address: str
        Token balance e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984
    top: int
        Limit of transactions. Maximum 100
    sortby: str
        Key to sort by.
    descend: str
        Sort in descending order.
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_top_token_holders(address)
    df_data = df.copy()
    df = df.sort_values(by=sortby, ascending=descend)
    df["balance"] = df["balance"].apply(
        lambda x: lambda_very_long_number_formatter(x))

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="ERC20 Token Holder Info",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "holders",
        df_data,
    )
Exemplo n.º 13
0
def display_top_tokens(
    top: int = 15,
    sortby: str = "rank",
    descend: bool = True,
    export: str = "",
) -> None:
    """Display top ERC20 tokens [Source: Ethplorer]

    Parameters
    ----------
    top: int
        Limit of transactions. Maximum 100
    sortby: str
        Key to sort by.
    descend: str
        Sort in descending order.
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_top_tokens()
    df_data = df.copy()
    df.fillna("", inplace=True)
    df = df.sort_values(by=sortby, ascending=descend)
    for col in ["txsCount", "transfersCount", "holdersCount"]:
        if col in df.columns:
            df[col] = df[col].apply(
                lambda x: lambda_very_long_number_formatter(x))

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Top ERC20 Tokens",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "top",
        df_data,
    )
Exemplo n.º 14
0
def display_token_info(
    address: str,
    social: bool = False,
    export: str = "",
) -> None:
    """Display info about ERC20 token. [Source: Ethplorer]

    Parameters
    ----------
    address: str
        Token balance e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984
    social: bool
        Flag to display social media links
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = ethplorer_model.get_token_info(address)
    df_data = df.copy()
    df["Value"] = df["Value"].apply(
        lambda x: lambda_very_long_number_formatter(x))

    socials = ["website", "telegram", "reddit", "twitter", "coingecko"]
    if social:
        df = df[df["Metric"].isin(["balance", "name", "symbol"] + socials)]
    else:
        df = df[~df["Metric"].isin(socials)]

    print_rich_table(df,
                     headers=list(df.columns),
                     show_index=False,
                     title="ERC20 Token Information")
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "info",
        df_data,
    )
Exemplo n.º 15
0
def display_uni_pools(top: int = 20,
                      sortby: str = "volumeUSD",
                      descend: bool = False,
                      export: str = "") -> None:
    """Displays uniswap pools by volume.
    [Source: https://thegraph.com/en/]

    Parameters
    ----------
    top: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = graph_model.get_uni_pools_by_volume().sort_values(by=sortby,
                                                           ascending=descend)
    df["volumeUSD"] = df["volumeUSD"].apply(
        lambda x: lambda_very_long_number_formatter(x))
    df_data = df.copy()

    print_rich_table(df.head(top),
                     headers=list(df.columns),
                     show_index=False,
                     title="Uniswap Pools")
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "pools",
        df_data,
    )
Exemplo n.º 16
0
def get_uniswap_stats() -> pd.DataFrame:
    """Get base statistics about Uniswap DEX. [Source: https://thegraph.com/en/]

    uniswapFactory id: 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f - ethereum address on which Uniswap Factory
    smart contract was deployed. The factory contract is deployed once from the off-chain source code, and it contains
    functions that make it possible to create exchange contracts for any ERC20 token that does not already have one.
    It also functions as a registry of ERC20 tokens that have been added to the system, and the exchange with which they
    are associated. More: https://docs.uniswap.org/protocol/V1/guides/connect-to-uniswap
    We use 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f address to fetch all smart contracts that were
    created with usage of this factory.


    Returns
    -------
    pd.DataFrame
        Uniswap DEX statistics like liquidity, volume, number of pairs, number of transactions.
    """

    query = """
       {
        uniswapFactory(id: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"){
         totalVolumeUSD
         totalLiquidityUSD
         pairCount
         txCount
         totalLiquidityUSD
         totalLiquidityETH
        }
       }
       """
    data = query_graph(UNI_URL, query)
    if not data:
        return pd.DataFrame()
    df = pd.Series(data["uniswapFactory"]).reset_index()
    df.columns = ["Metric", "Value"]
    df["Value"] = df["Value"].apply(
        lambda x: lambda_very_long_number_formatter(x))
    return df
Exemplo n.º 17
0
def display_last_uni_swaps(top: int = 20,
                           sortby: str = "timestamp",
                           descend: bool = False,
                           export: str = "") -> None:
    """Displays last swaps done on Uniswap
    [Source: https://thegraph.com/en/]

    Parameters
    ----------
    top: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = graph_model.get_last_uni_swaps(limit=top).sort_values(
        by=sortby, ascending=descend)
    df["amountUSD"] = df["amountUSD"].apply(
        lambda x: lambda_very_long_number_formatter(x))
    df_data = df.copy()

    print_rich_table(df,
                     headers=list(df.columns),
                     show_index=False,
                     title="Last Uniswap Swaps")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "swaps",
        df_data,
    )
Exemplo n.º 18
0
def display_daily_volume_for_given_pair(
    token: str = "WBTC",
    vs: str = "USDT",
    top: int = 20,
    sortby: str = "date",
    descend: bool = False,
    export: str = "",
) -> None:
    """Display daily volume for given pair
    [Source: https://graphql.bitquery.io/]

    Parameters
    ----------
    token: str
        ERC20 token symbol or address
    vs: str
        Quote currency.
    top: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    Returns
    -------
    pd.DataFrame
        Token volume on different decentralized exchanges
    """

    df = bitquery_model.get_daily_dex_volume_for_given_pair(
        token=token,
        vs=vs,
        limit=top,
    )

    if df.empty:
        return
    df = df.sort_values(by=sortby, ascending=descend)

    df_data = df.copy()

    df[["tradeAmount", "trades"
        ]] = df[["tradeAmount", "trades"
                 ]].applymap(lambda x: lambda_very_long_number_formatter(x))
    df.columns = prettify_column_names(df.columns)

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Daily Volume for Pair",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "dvcp",
        df_data,
    )
Exemplo n.º 19
0
def display_recently_added(
    top: int = 20,
    days: int = 7,
    min_volume: int = 20,
    min_liquidity: int = 0,
    min_tx: int = 100,
    sortby: str = "created",
    descend: bool = False,
    export: str = "",
) -> None:
    """Displays Lastly added pairs on Uniswap DEX.
    [Source: https://thegraph.com/en/]

    Parameters
    ----------
    top: int
        Number of records to display
    days: int
        Number of days the pair has been active,
    min_volume: int
        Minimum trading volume,
    min_liquidity: int
        Minimum liquidity
    min_tx: int
        Minimum number of transactions
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    df = graph_model.get_uniswap_pool_recently_added(
        last_days=days,
        min_volume=min_volume,
        min_liquidity=min_liquidity,
        min_tx=min_tx,
    )
    df_data = df.copy()

    df = df.sort_values(by=sortby, ascending=descend)

    df[["volumeUSD", "totalSupply"
        ]] = df[["volumeUSD", "totalSupply"
                 ]].applymap(lambda x: lambda_very_long_number_formatter(x))

    print_rich_table(
        df.head(top),
        headers=list(df.columns),
        show_index=False,
        title="Latest Added Pairs on Uniswap DEX",
    )
    console.print("")

    export_data(
        export,
        os.path.dirname(os.path.abspath(__file__)),
        "pairs",
        df_data,
    )
Exemplo n.º 20
0
def display_dex_trades(
    trade_amount_currency: str = "USD",
    kind: str = "dex",
    top: int = 20,
    days: int = 90,
    sortby: str = "tradeAmount",
    descend: bool = False,
    export: str = "",
) -> None:
    """Trades on Decentralized Exchanges aggregated by DEX or Month [Source: https://graphql.bitquery.io/]

    Parameters
    ----------
    kind: str
        Aggregate trades by dex or time
    trade_amount_currency: str
        Currency of displayed trade amount. Default: USD
    top: int
        Number of records to display
    sortby: str
        Key by which to sort data
    descend: bool
        Flag to sort data descending
    days:  int
        Last n days to query data. Maximum 365 (bigger numbers can cause timeouts
        on server side)
    export : str
        Export dataframe data to csv,json,xlsx file
    """

    if kind == "time":
        df = bitquery_model.get_dex_trades_monthly(trade_amount_currency, days)
        if not df.empty:
            df = df.sort_values(by="date", ascending=descend)
    else:
        df = bitquery_model.get_dex_trades_by_exchange(trade_amount_currency,
                                                       days)
        if not df.empty:
            df = df.sort_values(by=sortby, ascending=descend)

    if not df.empty:
        df_data = df.copy()

        df[["tradeAmount", "trades"]] = df[[
            "tradeAmount", "trades"
        ]].applymap(lambda x: lambda_very_long_number_formatter(x))

        df.columns = prettify_column_names(df.columns)

        print_rich_table(
            df.head(top),
            headers=list(df.columns),
            show_index=False,
            title="Trades on Decentralized Exchanges",
        )
        console.print("")

        export_data(
            export,
            os.path.dirname(os.path.abspath(__file__)),
            "lt",
            df_data,
        )