Files
OpenBB/openbb_terminal/cryptocurrency/overview/coinbase_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

55 lines
1.2 KiB
Python

"""Coinbase view"""
__docformat__ = "numpy"
import logging
import os
from openbb_terminal.cryptocurrency.overview import coinbase_model
from openbb_terminal.decorators import check_api_key
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import (
export_data,
print_rich_table,
)
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
@check_api_key(["API_COINBASE_KEY", "API_COINBASE_SECRET", "API_COINBASE_PASS_PHRASE"])
def display_trading_pairs(
limit: int = 20,
sortby: str = "quote_increment",
ascend: bool = True,
export: str = "",
) -> None:
"""Displays a list of available currency pairs for trading. [Source: Coinbase]
Parameters
----------
limit: int
Top n of pairs
sortby: str
Key to sortby data
ascend: bool
Sort ascending flag
export : str
Export dataframe data to csv,json,xlsx file
"""
df = coinbase_model.get_trading_pairs(limit, sortby, ascend)
print_rich_table(
df,
headers=list(df.columns),
show_index=False,
title="Available Pairs for Trading",
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"cbpairs",
df,
)