mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 04:13:06 +00:00
* Combine CA peers to smiliar command * crypto/disc/top into one sdk function * Exchanges into sdk function * delete wrong platforms trail * #3478 sdk crypto load * Options hist 1 sdk function * SDK functions Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""SDK Helper Functions."""
|
|
__docfromat__ = "numpy"
|
|
|
|
import pandas as pd
|
|
from openbb_terminal.cryptocurrency.discovery import (
|
|
coinmarketcap_model,
|
|
pycoingecko_model,
|
|
)
|
|
|
|
|
|
def top_coins(source: str = "CoinGecko", limit: int = 10) -> pd.DataFrame:
|
|
"""Get top cryptp coins.
|
|
|
|
Parameters
|
|
----------
|
|
source : str, optional
|
|
Source of data, by default "CoinGecko"
|
|
limit : int, optional
|
|
Number of coins to return, by default 10
|
|
|
|
Returns
|
|
-------
|
|
pd.DataFrame
|
|
DataFrame with top coins
|
|
|
|
Examples
|
|
--------
|
|
>>> from openbb_terminal.sdk import openbb
|
|
>>> top_coins = openbb.crypto.disc.top_coins()
|
|
|
|
To get 30 results from coinmarketcap, use the source parameter and the limit parameter:
|
|
>>> top_coins = openbb.crypto.disc.top_coins(source="CoinMarketCap", limit=30)
|
|
|
|
"""
|
|
if source.lower() == "coingecko":
|
|
df = pycoingecko_model.get_coins(limit=limit)
|
|
return df
|
|
if source.lower() == "coinmarketcap":
|
|
df = coinmarketcap_model.get_cmc_top_n()
|
|
return df
|
|
return pd.DataFrame()
|