From 1aebf488ac499b6c2b7fc5b00639aed3aa98e4b6 Mon Sep 17 00:00:00 2001 From: James Maslek Date: Tue, 10 Jan 2023 17:36:26 -0500 Subject: [PATCH] Add crypto dd functions to sdk (#3888) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Add crypto dd functions to sdk * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Fixes currency and trailmap Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> --- .../due_diligence/sdk_helper.py | 115 ++++++++++++++++++ .../miscellaneous/library/trail_map.csv | 5 + 2 files changed, 120 insertions(+) create mode 100644 openbb_terminal/cryptocurrency/due_diligence/sdk_helper.py diff --git a/openbb_terminal/cryptocurrency/due_diligence/sdk_helper.py b/openbb_terminal/cryptocurrency/due_diligence/sdk_helper.py new file mode 100644 index 000000000000..c2d64e19c404 --- /dev/null +++ b/openbb_terminal/cryptocurrency/due_diligence/sdk_helper.py @@ -0,0 +1,115 @@ +"""Crypto DD SDK helper""" +__docformat__ = "numpy" + +import pandas as pd +import openbb_terminal.cryptocurrency.due_diligence.pycoingecko_model as gecko + + +def dev_stats(symbol: str) -> pd.DataFrame: + """Get developer stats for a coin + + Parameters + ---------- + symbol : str + Coin to get stats for + + Returns + ------- + pd.DataFrame + Dataframe of stats + + Examples + -------- + >>> from openbb_terminal.sdk import openbb + >>> btc_dev_stats = openbb.crypto.dd.dev("btc") + """ + coin = gecko.Coin(symbol) + return coin.get_developers_data() + + +def score(symbol: str) -> pd.DataFrame: + """Get scores for a coin from CoinGecko + + Parameters + ---------- + symbol : str + Coin to get scores for + + Returns + ------- + pd.DataFrame + Dataframe of scores + + Examples + -------- + >>> from openbb_terminal.sdk import openbb + >>> btc_scores = openbb.crypto.dd.score("btc") + """ + return gecko.Coin(symbol).get_scores() + + +def social(symbol: str) -> pd.DataFrame: + """Get social media stats for a coin + + Parameters + ---------- + symbol : str + Coin to get social stats for + + Returns + ------- + pd.DataFrame + Dataframe of social stats + + Examples + -------- + >>> from openbb_terminal.sdk import openbb + >>> btc_socials = openbb.crypto.dd.social("btc") + """ + return gecko.Coin(symbol).get_social_media() + + +def ath(symbol: str, currency: str = "USD") -> pd.DataFrame: + """Get all time high for a coin in a given currency + + Parameters + ---------- + symbol : str + Coin to get all time high for + currency: str + Currency to get all time high in + + Returns + ------- + pd.DataFrame + Dataframe of all time high + + Examples + -------- + >>> from openbb_terminal.sdk import openbb + >>> btc_ath = openbb.crypto.dd.ath("btc") + """ + return gecko.Coin(symbol).get_all_time_high(currency=currency.lower()) + + +def atl(symbol: str, currency: str = "USD") -> pd.DataFrame: + """Get all time low for a coin in a given currency + + Parameters + ---------- + symbol : str + Coin to get all time low for + currency: str + Currency to get all time low in + + Returns + ------- + pd.DataFrame + Dataframe of all time low + + Examples + -------- + >>> from openbb_terminal.sdk import openbb + >>> btc_atl = openbb.crypto.dd.atl("btc") + """ + return gecko.Coin(symbol).get_all_time_low(currency=currency.lower()) diff --git a/openbb_terminal/miscellaneous/library/trail_map.csv b/openbb_terminal/miscellaneous/library/trail_map.csv index c46a0be7fb3c..6e41c2cb34b4 100644 --- a/openbb_terminal/miscellaneous/library/trail_map.csv +++ b/openbb_terminal/miscellaneous/library/trail_map.csv @@ -161,6 +161,11 @@ crypto.dd.coin_market_chart,openbb_terminal.cryptocurrency.due_diligence.pycoing crypto.dd.pr,openbb_terminal.cryptocurrency.due_diligence.pycoingecko_model.get_coin_potential_returns,openbb_terminal.cryptocurrency.due_diligence.pycoingecko_view.display_coin_potential_returns crypto.dd.tokenomics,openbb_terminal.cryptocurrency.due_diligence.pycoingecko_model.get_coin_tokenomics, crypto.dd.gh,openbb_terminal.cryptocurrency.due_diligence.santiment_model.get_github_activity,openbb_terminal.cryptocurrency.due_diligence.santiment_view.display_github_activity +crypto.dd.dev,openbb_terminal.cryptocurrency.due_diligence.sdk_helper.dev_stats, +crypto.dd.score,openbb_terminal.cryptocurrency.due_diligence.sdk_helper.score, +crypto.dd.social,openbb_terminal.cryptocurrency.due_diligence.sdk_helper.social, +crypto.dd.ath,openbb_terminal.cryptocurrency.due_diligence.sdk_helper.ath, +crypto.dd.atl,openbb_terminal.cryptocurrency.due_diligence.sdk_helper.atl, crypto.nft.stats,openbb_terminal.cryptocurrency.nft.opensea_model.get_collection_stats,openbb_terminal.cryptocurrency.nft.opensea_view.display_collection_stats crypto.nft.fp,openbb_terminal.cryptocurrency.nft.nftpricefloor_model.get_floor_price,openbb_terminal.cryptocurrency.nft.nftpricefloor_view.display_floor_price crypto.nft.collections,openbb_terminal.cryptocurrency.nft.nftpricefloor_model.get_collections,openbb_terminal.cryptocurrency.nft.nftpricefloor_view.display_collections