Files
OpenBB/openbb_terminal/cryptocurrency/overview/withdrawalfees_view.py
Colin Delahunty 5bc7bc070e Tests over API Best Practices (#2344)
* Started new tests

* Added special function

* Improved dict

* Finished new test

* Got bad functions to 75

* Got bad func to 73

* Bad func down to 60

* Bad func down to 50

* Bad func down to 35

* Got bad func to 30

* No more bad functions

* Added tests

* Added fix

* Fixed some tests

* Fixed some tests

* Fixed some tests

* Fixed some tests

* Added tests to CI

* Fixed CI tests

* Fixed CI tests

* Imrproved CI tests

* Fixed reports

* Fixed reports

* Added stuff

* Removed CI

* Fixed

* Fixed some typing'

Co-authored-by: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com>
2022-09-22 22:31:46 +01:00

121 lines
3.1 KiB
Python

"""Withdrawal Fees view"""
import logging
import os
from openbb_terminal.cryptocurrency.overview.withdrawalfees_model import (
get_crypto_withdrawal_fees,
get_overall_exchange_withdrawal_fees,
get_overall_withdrawal_fees,
)
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import export_data, print_rich_table
from openbb_terminal.rich_config import console
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def display_overall_withdrawal_fees(limit: int = 15, export: str = "") -> None:
"""Top coins withdrawal fees
[Source: https://withdrawalfees.com/]
Parameters
----------
limit: int
Number of coins to search
export : str
Export dataframe data to csv,json,xlsx file
"""
df_fees = get_overall_withdrawal_fees(limit)
if df_fees.empty:
console.print("\nError in withdrawal fees request\n")
else:
console.print("\nWithdrawal fees on exchanges:")
print_rich_table(
df_fees.head(limit),
headers=list(df_fees.columns),
show_index=False,
title="Top Withdrawal Fees",
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"withdrawal_fees",
df_fees,
)
@log_start_end(log=logger)
def display_overall_exchange_withdrawal_fees(export: str = "") -> None:
"""Exchange withdrawal fees
[Source: https://withdrawalfees.com/]
Parameters
----------
export : str
Export dataframe data to csv,json,xlsx file
"""
df_fees = get_overall_exchange_withdrawal_fees()
if df_fees.empty:
console.print("\nError in withdrawal fees request\n")
else:
console.print("\nWithdrawal fees per exchange:")
print_rich_table(
df_fees,
headers=list(df_fees.columns),
show_index=False,
title="Withdrawal Fees",
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"exchange_withdrawal_fees",
df_fees,
)
@log_start_end(log=logger)
def display_crypto_withdrawal_fees(symbol: str, export: str = "") -> None:
"""Coin withdrawal fees per exchange
[Source: https://withdrawalfees.com/]
Parameters
----------
symbol: str
Coin to check withdrawal fees
export : str
Export dataframe data to csv,json,xlsx file
"""
res = get_crypto_withdrawal_fees(symbol)
stats_string = res[0]
df_fees = res[1]
if df_fees.empty:
console.print("\nError in withdrawal fees request\n")
else:
console.print(f"\nWithdrawal fees for {symbol}:")
console.print(f"\n{stats_string}\n")
print_rich_table(
df_fees,
headers=list(df_fees.columns),
show_index=False,
title="Withdrawal Fees per Exchange",
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"crypto_withdrawal_fees",
df_fees,
)