diff --git a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py index 06b305869650..376c4a40ba99 100644 --- a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py +++ b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py @@ -128,7 +128,9 @@ def check_supported_ticker(symbol: str) -> bool: @check_api_key(["API_SENTIMENTINVESTOR_TOKEN"]) def get_trending( - start_date: datetime = datetime.today(), hour: int = 0, number: int = 10 + start_date: str = datetime.today().strftime("%Y-%m-%d"), + hour: int = 0, + number: int = 10, ) -> pd.DataFrame: """Get sentiment data on the most talked about tickers within the last hour @@ -137,8 +139,8 @@ def get_trending( Parameters ---------- - start_date: datetime - Datetime object (e.g. datetime(2021, 12, 21) + start_date : str + Initial date, format YYYY-MM-DD hour: int Hour of the day in 24-hour notation (e.g. 14) number : int @@ -152,7 +154,7 @@ def get_trending( """ # type is datetime - start_timestamp = start_date + timedelta(hours=hour) + start_timestamp = datetime.strptime(start_date, "%Y-%m-%d") + timedelta(hours=hour) payload: Dict[str, Union[int, str]] = { "token": cfg.API_SENTIMENTINVESTOR_TOKEN, diff --git a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py index cedae294fb9b..37b023366647 100644 --- a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py +++ b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py @@ -146,7 +146,7 @@ def display_historical( @log_start_end(log=logger) @check_api_key(["API_SENTIMENTINVESTOR_TOKEN"]) def display_trending( - start_date: datetime = datetime.today(), + start_date: str = datetime.today().strftime("%Y-%m-%d"), hour: int = 0, number: int = 10, limit: int = 10, @@ -157,8 +157,8 @@ def display_trending( Parameters ---------- - start_date: datetime - Datetime object (e.g. datetime(2021, 12, 21) + start_date : str + Initial date, format YYYY-MM-DD hour: int Hour of the day in 24-hour notation (e.g. 14) number : int @@ -171,10 +171,6 @@ def display_trending( Format to export data """ - # Force datetime format to be datetime(year, month, day, 0, 0) - # 0 hours and minutes to look since day starts - start_date = datetime(start_date.year, start_date.month, start_date.day) - df = sentimentinvestor_model.get_trending(start_date, hour, number) if df.empty: diff --git a/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py b/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py index c5fc69f67882..327a2537189b 100644 --- a/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py +++ b/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py @@ -123,6 +123,40 @@ ] +def check_datetime( + ck_date: datetime | str | None = None, start: bool = True +) -> datetime: + """Checks if given argument is string and attempts to convert to datetime. + + Parameters + ---------- + ck_date : Optional[Union[datetime, str]], optional + Date to check, by default None + start : bool, optional + If True and string is invalid, will return 1100 days ago + If False and string is invalid, will return today, by default True + + Returns + ------- + datetime + Datetime object + """ + error_catch = (datetime.now() - timedelta(days=1100)) if start else datetime.now() + try: + if ck_date is None: + return error_catch + if isinstance(ck_date, datetime): + return ck_date + if isinstance(ck_date, str): + return datetime.strptime(ck_date, "%Y-%m-%d") + except Exception: + console.print( + f"Invalid date format (YYYY-MM-DD), " + f"Using {error_catch.strftime('%Y-%m-%d')} for {ck_date}" + ) + return error_catch + + def _load_coin_map(file_name: str) -> pd.DataFrame: if file_name.split(".")[1] != "json": raise TypeError("Please load json file") @@ -472,11 +506,11 @@ def load_from_yahoofinance( def load( symbol: str, - start_date: datetime = (datetime.now() - timedelta(days=1100)), + start_date: datetime | str | None = None, interval: str = "1440", exchange: str = "binance", vs_currency: str = "usdt", - end_date: datetime = datetime.now(), + end_date: datetime | str | None = None, source: str = "CCXT", ) -> pd.DataFrame: """Load crypto currency to get data for @@ -485,8 +519,8 @@ def load( ---------- symbol: str Coin to get - start_date: datetime - The datetime to start at + start_date: str or datetime, optional + Start date to get data from with. - datetime or string format (YYYY-MM-DD) interval: str The interval between data points in minutes. Choose from: 1, 15, 30, 60, 240, 1440, 10080, 43200 @@ -494,8 +528,8 @@ def load( The exchange to get data from. vs_currency: str Quote Currency (Defaults to usdt) - end_date: datetime - The datetime to end at + end_date: str or datetime, optional + End date to get data from with. - datetime or string format (YYYY-MM-DD) source: str The source of the data Choose from: CCXT, CoinGecko, YahooFinance @@ -505,6 +539,16 @@ def load( pd.DataFrame Dataframe consisting of price and volume data """ + + if start_date is None: + start_date = (datetime.now() - timedelta(days=1100)).strftime("%Y-%m-%d") + + if end_date is None: + end_date = datetime.now().strftime("%Y-%m-%d") + + start_date = check_datetime(start_date) + end_date = check_datetime(end_date, start=False) + if source == "CCXT": return load_from_ccxt(symbol, start_date, interval, exchange, vs_currency) if source == "CoinGecko": diff --git a/openbb_terminal/cryptocurrency/due_diligence/dd_controller.py b/openbb_terminal/cryptocurrency/due_diligence/dd_controller.py index a0c986495d90..a160a00c9535 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/dd_controller.py +++ b/openbb_terminal/cryptocurrency/due_diligence/dd_controller.py @@ -341,10 +341,11 @@ def call_nonzero(self, other_args: List[str]): ) if ns_parser: + glassnode_view.display_non_zero_addresses( symbol=self.symbol.upper(), - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) @@ -429,11 +430,12 @@ def call_active(self, other_args: List[str]): ) if ns_parser: + glassnode_view.display_active_addresses( symbol=self.symbol.upper(), interval=ns_parser.interval, - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) @@ -493,11 +495,12 @@ def call_change(self, other_args: List[str]): ) if ns_parser: + glassnode_view.display_exchange_net_position_change( symbol=self.symbol.upper(), exchange=ns_parser.exchange, - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) else: @@ -564,11 +567,12 @@ def call_eb(self, other_args: List[str]): ) if ns_parser: + glassnode_view.display_exchange_balances( symbol=self.symbol.upper(), exchange=ns_parser.exchange, - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), percentage=ns_parser.percentage, export=ns_parser.export, ) diff --git a/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py b/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py index bea0d790c457..e4d9b6fd82aa 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py +++ b/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta +from datetime import datetime import logging import json @@ -8,6 +8,7 @@ from openbb_terminal import config_terminal as cfg from openbb_terminal.decorators import log_start_end, check_api_key from openbb_terminal.rich_config import console +from openbb_terminal.helper_funcs import str_date_to_timestamp # pylint: disable=unsupported-assignment-operation @@ -203,16 +204,8 @@ def get_close_price( price over time """ - dt_start_date = int( - datetime.strptime( - start_date + " 00:00:00+0000", "%Y-%m-%d %H:%M:%S%z" - ).timestamp() - ) - dt_end_date = int( - datetime.strptime( - end_date + " 00:00:00+0000", "%Y-%m-%d %H:%M:%S%z" - ).timestamp() - ) + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) url = api_url + "market/price_usd_close" @@ -220,8 +213,8 @@ def get_close_price( "api_key": cfg.API_GLASSNODE_KEY, "a": symbol, "i": "24h", - "s": str(dt_start_date), - "u": str(dt_end_date), + "s": str(ts_start_date), + "u": str(ts_end_date), } r = requests.get(url, params=parameters) @@ -252,8 +245,8 @@ def get_close_price( @check_api_key(["API_GLASSNODE_KEY"]) def get_non_zero_addresses( symbol: str, - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), ) -> pd.DataFrame: """Returns addresses with non-zero balance of a certain symbol [Source: https://glassnode.com] @@ -262,10 +255,10 @@ def get_non_zero_addresses( ---------- symbol : str Asset to search (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_577_836_800) - end_date : int - End date timestamp (e.g., 1_609_459_200) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD Returns ------- @@ -273,14 +266,17 @@ def get_non_zero_addresses( addresses with non-zero balances """ + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + url = api_url + "addresses/non_zero_count" parameters = { "api_key": cfg.API_GLASSNODE_KEY, "a": symbol, "i": "24h", - "s": str(start_date), - "u": str(end_date), + "s": str(ts_start_date), + "u": str(ts_end_date), } r = requests.get(url, params=parameters) @@ -309,8 +305,8 @@ def get_non_zero_addresses( def get_active_addresses( symbol: str, interval: str = "24h", - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), ) -> pd.DataFrame: """Returns active addresses of a certain symbol [Source: https://glassnode.com] @@ -319,12 +315,12 @@ def get_active_addresses( ---------- symbol : str Asset to search active addresses (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) interval : str Interval frequency (e.g., 24h) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD Returns ------- @@ -332,14 +328,17 @@ def get_active_addresses( active addresses over time """ + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + url = api_url + "addresses/active_count" parameters = { "api_key": cfg.API_GLASSNODE_KEY, "a": symbol, "i": interval, - "s": str(start_date), - "u": str(end_date), + "s": str(ts_start_date), + "u": str(ts_end_date), } r = requests.get(url, params=parameters) @@ -367,8 +366,8 @@ def get_active_addresses( def get_hashrate( symbol: str, interval: str = "24h", - start_date: int = int((datetime.now() - timedelta(days=365 * 12)).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), ) -> pd.DataFrame: """Returns dataframe with mean hashrate of btc or eth blockchain and symbol price [Source: https://glassnode.com] @@ -377,10 +376,10 @@ def get_hashrate( ---------- symbol : str Blockchain to check hashrate (BTC or ETH) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD interval : str Interval frequency (e.g., 24h) @@ -390,6 +389,9 @@ def get_hashrate( mean hashrate and symbol price over time """ + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + url = api_url + "mining/hash_rate_mean" url2 = api_url + "market/price_usd_close" @@ -397,8 +399,8 @@ def get_hashrate( "api_key": cfg.API_GLASSNODE_KEY, "a": symbol, "i": interval, - "s": str(start_date), - "u": str(end_date), + "s": str(ts_start_date), + "u": str(ts_end_date), } df = pd.DataFrame() @@ -439,8 +441,8 @@ def get_hashrate( def get_exchange_balances( symbol: str, exchange: str = "binance", - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), ) -> pd.DataFrame: """Returns the total amount of coins held on exchange addresses in units and percentage. [Source: https://glassnode.com] @@ -451,16 +453,18 @@ def get_exchange_balances( Asset to search active addresses (e.g., BTC) exchange : str Exchange to check net position change (e.g., binance) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD Returns ------- pd.DataFrame total amount of coins in units/percentage and symbol price over time """ + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) url = api_url + "distribution/balance_exchanges" url2 = api_url + "distribution/balance_exchanges_relative" @@ -471,8 +475,8 @@ def get_exchange_balances( "a": symbol, "i": "24h", "e": exchange, - "s": str(start_date), - "u": str(end_date), + "s": str(ts_start_date), + "u": str(ts_end_date), } df = pd.DataFrame() @@ -519,8 +523,8 @@ def get_exchange_balances( def get_exchange_net_position_change( symbol: str, exchange: str = "binance", - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), ) -> pd.DataFrame: """Returns 30d change of the supply held in exchange wallets of a certain symbol. [Source: https://glassnode.com] @@ -531,10 +535,10 @@ def get_exchange_net_position_change( Asset symbol to search supply (e.g., BTC) exchange : str Exchange to check net position change (e.g., binance) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD Returns ------- @@ -542,6 +546,9 @@ def get_exchange_net_position_change( supply change in exchange wallets of a certain symbol over time """ + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + url = api_url + "distribution/exchange_net_position_change" parameters = { @@ -549,8 +556,8 @@ def get_exchange_net_position_change( "a": symbol, "i": "24h", "e": exchange, - "s": str(start_date), - "u": str(end_date), + "s": str(ts_start_date), + "u": str(ts_end_date), } r = requests.get(url, params=parameters) diff --git a/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py b/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py index d884ce37d374..8bd07ca40281 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py +++ b/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py @@ -1,6 +1,6 @@ import logging import os -from datetime import datetime, timedelta +from datetime import datetime from typing import List, Optional import numpy as np @@ -32,8 +32,8 @@ @check_api_key(["API_GLASSNODE_KEY"]) def display_active_addresses( symbol: str, - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), interval: str = "24h", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -45,10 +45,10 @@ def display_active_addresses( ---------- symbol : str Asset to search active addresses (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD interval : str Interval frequency (possible values are: 24h, 1w, 1month) export : str @@ -93,8 +93,8 @@ def display_active_addresses( @check_api_key(["API_GLASSNODE_KEY"]) def display_non_zero_addresses( symbol: str, - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -105,10 +105,10 @@ def display_non_zero_addresses( ---------- symbol : str Asset to search (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_577_836_800) - end_date : int - End date timestamp (e.g., 1_609_459_200) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional @@ -152,8 +152,8 @@ def display_non_zero_addresses( def display_exchange_net_position_change( symbol: str, exchange: str = "binance", - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -168,10 +168,10 @@ def display_exchange_net_position_change( Exchange to check net position change (possible values are: aggregated, binance, bittrex, coinex, gate.io, gemini, huobi, kucoin, poloniex, bibox, bigone, bitfinex, hitbtc, kraken, okex, bithumb, zb.com, cobinhood, bitmex, bitstamp, coinbase, coincheck, luno) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional @@ -230,8 +230,8 @@ def display_exchange_net_position_change( def display_exchange_balances( symbol: str, exchange: str = "binance", - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), percentage: bool = False, export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -247,10 +247,10 @@ def display_exchange_balances( Exchange to check net position change (possible values are: aggregated, binance, bittrex, coinex, gate.io, gemini, huobi, kucoin, poloniex, bibox, bigone, bitfinex, hitbtc, kraken, okex, bithumb, zb.com, cobinhood, bitmex, bitstamp, coinbase, coincheck, luno) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD percentage : bool Show percentage instead of stacked value. export : str @@ -306,8 +306,8 @@ def display_exchange_balances( @check_api_key(["API_GLASSNODE_KEY"]) def display_hashrate( symbol: str, - start_date: int = int((datetime.now() - timedelta(days=365)).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), interval: str = "24h", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -319,10 +319,10 @@ def display_hashrate( ---------- symbol : str Blockchain to check mean hashrate (BTC or ETH) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD interval : str Interval frequency (possible values are: 24, 1w, 1month) export : str diff --git a/openbb_terminal/cryptocurrency/onchain/blockchain_view.py b/openbb_terminal/cryptocurrency/onchain/blockchain_view.py index 4a48000fd5f0..56a6686acbc5 100644 --- a/openbb_terminal/cryptocurrency/onchain/blockchain_view.py +++ b/openbb_terminal/cryptocurrency/onchain/blockchain_view.py @@ -18,6 +18,7 @@ lambda_long_number_format, plot_autoscale, is_valid_axes_count, + str_date_to_timestamp, ) logger = logging.getLogger(__name__) @@ -25,8 +26,8 @@ @log_start_end(log=logger) def display_btc_circulating_supply( - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -34,10 +35,10 @@ def display_btc_circulating_supply( Parameters ---------- - start_date : int - Initial date timestamp (e.g., 1_609_459_200) - until : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional @@ -45,9 +46,13 @@ def display_btc_circulating_supply( """ df = blockchain_model.get_btc_circulating_supply() + + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + df = df[ - (df["x"] > datetime.fromtimestamp(start_date)) - & (df["x"] < datetime.fromtimestamp(end_date)) + (df["x"] > datetime.fromtimestamp(ts_start_date)) + & (df["x"] < datetime.fromtimestamp(ts_end_date)) ] # This plot has 1 axis @@ -78,8 +83,8 @@ def display_btc_circulating_supply( @log_start_end(log=logger) def display_btc_confirmed_transactions( - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -87,10 +92,10 @@ def display_btc_confirmed_transactions( Parameters ---------- - since : int - Initial date timestamp (e.g., 1_609_459_200) - until : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional @@ -98,9 +103,13 @@ def display_btc_confirmed_transactions( """ df = blockchain_model.get_btc_confirmed_transactions() + + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + df = df[ - (df["x"] > datetime.fromtimestamp(start_date)) - & (df["x"] < datetime.fromtimestamp(end_date)) + (df["x"] > datetime.fromtimestamp(ts_start_date)) + & (df["x"] < datetime.fromtimestamp(ts_end_date)) ] # This plot has 1 axis diff --git a/openbb_terminal/cryptocurrency/onchain/onchain_controller.py b/openbb_terminal/cryptocurrency/onchain/onchain_controller.py index 15a661f10902..2c8da84a665a 100644 --- a/openbb_terminal/cryptocurrency/onchain/onchain_controller.py +++ b/openbb_terminal/cryptocurrency/onchain/onchain_controller.py @@ -441,7 +441,7 @@ def call_btcct(self, other_args: List[str]): "--until", dest="until", type=valid_date, - help="Final date. Default: 2021-01-01", + help=f"Final date. Default: {(datetime.now()).strftime('%Y-%m-%d')}", default=(datetime.now()).strftime("%Y-%m-%d"), ) @@ -451,8 +451,8 @@ def call_btcct(self, other_args: List[str]): if ns_parser: blockchain_view.display_btc_confirmed_transactions( - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) @@ -492,8 +492,8 @@ def call_btccp(self, other_args: List[str]): if ns_parser: blockchain_view.display_btc_circulating_supply( - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) @@ -559,8 +559,8 @@ def call_hr(self, other_args: List[str]): display_hashrate( symbol=ns_parser.coin, interval=ns_parser.interval, - start_date=int(datetime.timestamp(ns_parser.since)), - end_date=int(datetime.timestamp(ns_parser.until)), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) diff --git a/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py b/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py index 44f7c3ecf1b3..e9a580808298 100644 --- a/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py +++ b/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py @@ -8,7 +8,7 @@ from bs4 import BeautifulSoup from openbb_terminal.decorators import log_start_end -from openbb_terminal.helper_funcs import get_user_agent +from openbb_terminal.helper_funcs import get_user_agent, str_date_to_timestamp logger = logging.getLogger(__name__) @@ -18,8 +18,8 @@ @log_start_end(log=logger) def get_altcoin_index( period: int = 30, - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), ) -> pd.DataFrame: """Get altcoin index overtime [Source: https://blockchaincenter.net] @@ -30,10 +30,10 @@ def get_altcoin_index( Number of days {30,90,365} to check performance of coins and calculate the altcoin index. E.g., 365 checks yearly performance, 90 will check seasonal performance (90 days), 30 will check monthly performance (30 days). - start_date : int - Initial date timestamp (e.g., 1_609_459_200) - end_date : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD Returns ------- @@ -62,9 +62,13 @@ def get_altcoin_index( df["Date"] = pd.to_datetime(df["Date"]) df["Value"] = df["Value"].astype(int) df = df.set_index("Date") + + ts_start_date = str_date_to_timestamp(start_date) + ts_end_date = str_date_to_timestamp(end_date) + df = df[ - (df.index > datetime.fromtimestamp(start_date)) - & (df.index < datetime.fromtimestamp(end_date)) + (df.index > datetime.fromtimestamp(ts_start_date)) + & (df.index < datetime.fromtimestamp(ts_end_date)) ] return df diff --git a/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py b/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py index 55e114f8f6fc..5eaa2138e1ba 100644 --- a/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py +++ b/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py @@ -26,8 +26,8 @@ @log_start_end(log=logger) def display_altcoin_index( period: int = 365, - start_date: int = int(datetime(2010, 1, 1).timestamp()), - end_date: int = int(datetime.now().timestamp()), + start_date: str = "2010-01-01", + end_date: str = datetime.now().strftime("%Y-%m-%d"), export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -36,10 +36,10 @@ def display_altcoin_index( Parameters ---------- - start_date : int - Initial date timestamp (e.g., 1_609_459_200) - end_date : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD period: int Number of days to check the performance of coins and calculate the altcoin index. E.g., 365 will check yearly performance , 90 will check seasonal performance (90 days), diff --git a/openbb_terminal/cryptocurrency/overview/overview_controller.py b/openbb_terminal/cryptocurrency/overview/overview_controller.py index ae01b32210f6..022d64408c28 100644 --- a/openbb_terminal/cryptocurrency/overview/overview_controller.py +++ b/openbb_terminal/cryptocurrency/overview/overview_controller.py @@ -520,12 +520,10 @@ def call_btcrb(self, other_args: List[str]): parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES ) if ns_parser: - start_date = ns_parser.since.strftime("%Y-%m-%d") - end_date = ns_parser.until.strftime("%Y-%m-%d") display_btc_rainbow( - start_date=start_date, - end_date=end_date, + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), export=ns_parser.export, ) @@ -581,8 +579,8 @@ def call_altindex(self, other_args: List[str]): if ns_parser: blockchaincenter_view.display_altcoin_index( - start_date=ns_parser.since.timestamp(), - end_date=ns_parser.until.timestamp(), + start_date=ns_parser.since.strftime("%Y-%m-%d"), + end_date=ns_parser.until.strftime("%Y-%m-%d"), period=ns_parser.period, export=ns_parser.export, ) diff --git a/openbb_terminal/helper_funcs.py b/openbb_terminal/helper_funcs.py index 157498292f9f..4efc6de9234e 100644 --- a/openbb_terminal/helper_funcs.py +++ b/openbb_terminal/helper_funcs.py @@ -1804,3 +1804,24 @@ def list_from_str(value: str) -> List[str]: if value: return value.split(",") return [] + + +def str_date_to_timestamp(date: str) -> int: + """Transform string date to timestamp + + Parameters + ---------- + start_date : str + Initial date, format YYYY-MM-DD + + Returns + ------- + date_ts : int + Initial date timestamp (e.g., 1_614_556_800) + """ + + date_ts = int( + datetime.strptime(date + " 00:00:00+0000", "%Y-%m-%d %H:%M:%S%z").timestamp() + ) + + return date_ts diff --git a/openbb_terminal/parent_classes.py b/openbb_terminal/parent_classes.py index 5da2277f3730..7b1f862b9ab3 100644 --- a/openbb_terminal/parent_classes.py +++ b/openbb_terminal/parent_classes.py @@ -1204,8 +1204,8 @@ def call_load(self, other_args): (self.current_df) = cryptocurrency_helpers.load( symbol=ns_parser.coin.lower(), vs_currency=ns_parser.vs, - end_date=ns_parser.end, - start_date=ns_parser.start, + end_date=ns_parser.end.strftime("%Y-%m-%d"), + start_date=ns_parser.start.strftime("%Y-%m-%d"), interval=ns_parser.interval, source=ns_parser.source, exchange=ns_parser.exchange, diff --git a/openbb_terminal/stocks/stocks_helper.py b/openbb_terminal/stocks/stocks_helper.py index 7b0d2e62a2af..14fa001954ed 100644 --- a/openbb_terminal/stocks/stocks_helper.py +++ b/openbb_terminal/stocks/stocks_helper.py @@ -219,9 +219,9 @@ def load( symbol: str, start_date: Optional[Union[datetime, str]] = ( datetime.now() - timedelta(days=1100) - ), + ).strftime("%Y-%m-%d"), interval: int = 1440, - end_date: Optional[Union[datetime, str]] = datetime.now(), + end_date: Optional[Union[datetime, str]] = datetime.now().strftime("%Y-%m-%d"), prepost: bool = False, source: str = "YahooFinance", iexrange: str = "ytd", @@ -439,10 +439,10 @@ def display_candle( ma: Optional[Iterable[int]] = None, asset_type: str = "", start_date: Optional[Union[datetime, str]] = ( - datetime.now() - timedelta(days=1100) - ), + datetime.today() - timedelta(days=1100) + ).strftime("%Y-%m-%d"), interval: int = 1440, - end_date: Optional[Union[datetime, str]] = datetime.now(), + end_date: Optional[Union[datetime, str]] = datetime.today().strftime("%Y-%m-%d"), prepost: bool = False, source: str = "YahooFinance", iexrange: str = "ytd", diff --git a/tests/openbb_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[2021-12-21-9-10].yaml b/tests/openbb_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[2021-12-21-9-10].yaml new file mode 100644 index 000000000000..11b6ee971412 --- /dev/null +++ b/tests/openbb_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[2021-12-21-9-10].yaml @@ -0,0 +1,28 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.28.1 + method: GET + uri: https://api.sentimentinvestor.com/v1/trending?end=2021-12-21+09%3A00%3A00&limit=10&start=2021-12-21+09%3A00%3A00&token=MOCK_TOKEN + response: + body: + string: Service Unavailable + headers: + Content-Length: + - '19' + Content-Type: + - text/plain; charset=utf-8 + Date: + - Thu, 10 Nov 2022 18:11:01 GMT + status: + code: 503 + message: Service Unavailable +version: 1 diff --git a/tests/openbb_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml b/tests/openbb_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml deleted file mode 100644 index e4adaca68fb0..000000000000 --- a/tests/openbb_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml +++ /dev/null @@ -1,34 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - python-requests/2.26.0 - method: GET - uri: https://api.sentimentinvestor.com/v1/trending?end=2021-12-21+09%3A00%3A00&limit=10&start=2021-12-21+09%3A00%3A00&token=MOCK_TOKEN - response: - body: - string: '{"success":true,"results":[{"id":"hist_21_9_btc.x","sentiment_count":22,"timestamp_date":"2021-12-21T09:00:00.000Z","total":40,"twitter":0,"stocktwits":40,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"btc.x","likes":25,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":3.4728,"AHI":3.3006,"SGP":0},{"id":"hist_21_9_amc","sentiment_count":33,"timestamp_date":"2021-12-21T09:00:00.000Z","total":40,"twitter":0,"stocktwits":40,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"amc","likes":57,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4931,"AHI":0.5699,"SGP":0},{"id":"hist_21_9_tsla","sentiment_count":19,"timestamp_date":"2021-12-21T09:00:00.000Z","total":33,"twitter":0,"stocktwits":31,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"tsla","likes":30,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4169,"AHI":0.5384,"SGP":1,"sentiment":7.8684},{"id":"hist_21_9_mrna","sentiment_count":11,"timestamp_date":"2021-12-21T09:00:00.000Z","total":15,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":7,"ticker":"mrna","likes":4,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.7673,"AHI":0.6587,"SGP":0},{"id":"hist_21_9_btc","sentiment_count":9,"timestamp_date":"2021-12-21T09:00:00.000Z","total":12,"twitter":0,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":12,"ticker":"btc","likes":0,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4879,"AHI":0.4465,"SGP":1,"sentiment":16.9798},{"id":"hist_21_9_aapl","sentiment_count":9,"timestamp_date":"2021-12-21T09:00:00.000Z","total":10,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":10,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.3676,"AHI":0.4111,"SGP":0},{"id":"hist_21_9_lcid","sentiment_count":8,"timestamp_date":"2021-12-21T09:00:00.000Z","total":10,"twitter":0,"stocktwits":9,"reddit_comment":0,"reddit_post":0,"yahoo":1,"ticker":"lcid","likes":23,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4674,"AHI":0.5561,"SGP":0},{"id":"hist_21_9_amd","sentiment_count":6,"timestamp_date":"2021-12-21T09:00:00.000Z","total":9,"twitter":0,"stocktwits":3,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"amd","likes":3,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4516,"AHI":0.5424,"SGP":0},{"id":"hist_21_9_nke","sentiment_count":4,"timestamp_date":"2021-12-21T09:00:00.000Z","total":6,"twitter":0,"stocktwits":4,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"nke","likes":1,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.3136,"AHI":2.0879,"SGP":0},{"id":"hist_21_9_t","sentiment_count":4,"timestamp_date":"2021-12-21T09:00:00.000Z","total":6,"twitter":0,"stocktwits":3,"reddit_comment":0,"reddit_post":0,"yahoo":3,"ticker":"t","likes":0,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4844,"AHI":0.6866,"SGP":0}],"start":"2021-12-21T09:00:00.000Z","end":"2021-12-21T09:00:00.000Z","limit":"10"}' - headers: - Access-Control-Allow-Origin: - - '*' - Content-Length: - - '2986' - Content-Type: - - application/json; charset=utf-8 - Date: - - Thu, 27 Jan 2022 16:22:37 GMT - Etag: - - W/"baa-MWXy163w4MAIoe1ZkpGOeHUUI0M" - X-Powered-By: - - Express - status: - code: 200 - message: OK -version: 1 diff --git a/tests/openbb_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[2021-12-21-9-10].csv b/tests/openbb_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[2021-12-21-9-10].csv new file mode 100644 index 000000000000..e16c76dff888 --- /dev/null +++ b/tests/openbb_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[2021-12-21-9-10].csv @@ -0,0 +1 @@ +"" diff --git a/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py b/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py index 327248c9e522..5a4a25797738 100644 --- a/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py +++ b/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py @@ -1,6 +1,3 @@ -# IMPORTATION STANDARD -from datetime import datetime - # IMPORTATION THIRDPARTY import pandas as pd import pytest @@ -44,7 +41,7 @@ def test_get_historical(symbol, start_date, end_date, limit, recorder): @pytest.mark.vcr @pytest.mark.parametrize( "start, hour, number", - [(datetime(2021, 12, 21), 9, 10)], + [("2021-12-21", 9, 10)], ) def test_get_trending(start, hour, number, recorder): df = sentimentinvestor_model.get_trending(start, hour, number) @@ -64,7 +61,7 @@ def test_get_trending_status_400(mocker): mock_response.status_code = 400 df = sentimentinvestor_model.get_trending( - start_date=datetime(2021, 12, 21), + start_date="2021-12-21", hour=9, number=10, ) diff --git a/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py b/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py index 20f92845f111..04e30ffff71d 100644 --- a/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py +++ b/tests/openbb_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py @@ -1,6 +1,3 @@ -# IMPORTATION STANDARD -from datetime import datetime - # IMPORTATION THIRDPARTY import pandas as pd import pytest @@ -77,11 +74,13 @@ def test_display_historical_empty_df(mocker): ) +# This api website seems to have stop working, but I have no key to check. +@pytest.mark.skip @pytest.mark.vcr @pytest.mark.record_stdout def test_display_trending(): sentimentinvestor_view.display_trending( - start_date=datetime(2021, 12, 21), + start_date="2021-12-12", hour=9, number=10, limit=10, @@ -101,7 +100,7 @@ def test_display_trending_empty_df(mocker): ) sentimentinvestor_view.display_trending( - start_date=datetime(2021, 12, 21), + start_date="2021-12-12", hour=9, number=10, limit=10, diff --git a/tests/openbb_terminal/cryptocurrency/onchain/test_blockchain_view.py b/tests/openbb_terminal/cryptocurrency/onchain/test_blockchain_view.py index d2c21418ebe8..df0ee09c8af2 100644 --- a/tests/openbb_terminal/cryptocurrency/onchain/test_blockchain_view.py +++ b/tests/openbb_terminal/cryptocurrency/onchain/test_blockchain_view.py @@ -9,7 +9,7 @@ def test_display_btc_circulating_supply(mocker): # MOCK VISUALIZE_OUTPUT mocker.patch(target="openbb_terminal.helper_classes.TerminalStyle.visualize_output") - blockchain_view.display_btc_circulating_supply(1_601_596_800, 1_641_573_787, "") + blockchain_view.display_btc_circulating_supply("2010-01-01", "2022-11-10", "") @pytest.mark.vcr @@ -17,4 +17,4 @@ def test_display_btc_circulating_supply(mocker): def test_display_btc_confirmed_transactions(mocker): # MOCK VISUALIZE_OUTPUT mocker.patch(target="openbb_terminal.helper_classes.TerminalStyle.visualize_output") - blockchain_view.display_btc_confirmed_transactions(1_601_596_800, 1_641_573_787, "") + blockchain_view.display_btc_confirmed_transactions("2010-01-01", "2022-11-10", "") diff --git a/tests/openbb_terminal/cryptocurrency/overview/test_blockchaincenter_view.py b/tests/openbb_terminal/cryptocurrency/overview/test_blockchaincenter_view.py index 9ada7e69967f..3cbd32332ac9 100644 --- a/tests/openbb_terminal/cryptocurrency/overview/test_blockchaincenter_view.py +++ b/tests/openbb_terminal/cryptocurrency/overview/test_blockchaincenter_view.py @@ -8,4 +8,4 @@ def test_get_altcoin_index(mocker): # MOCK VISUALIZE_OUTPUT mocker.patch(target="openbb_terminal.helper_classes.TerminalStyle.visualize_output") - blockchaincenter_view.get_altcoin_index(365, 1_601_596_800, 1_641_573_787) + blockchaincenter_view.get_altcoin_index(365, "2010-01-01", "2022-11-10") diff --git a/website/content/SDK/crypto/dd/active/_index.rst b/website/content/SDK/crypto/dd/active/_index.rst index 3063231800bf..1d5b9292644e 100644 --- a/website/content/SDK/crypto/dd/active/_index.rst +++ b/website/content/SDK/crypto/dd/active/_index.rst @@ -16,8 +16,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. crypto.dd.active( symbol: str, interval: str = '24h', - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -33,12 +33,12 @@ crypto.dd.active( symbol : str Asset to search active addresses (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) interval : str Interval frequency (e.g., 24h) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD chart: bool Flag to display chart @@ -59,8 +59,8 @@ crypto.dd.active( {{< highlight python >}} crypto.dd.active( symbol: str, - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', interval: str = '24h', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, @@ -79,10 +79,10 @@ crypto.dd.active( symbol : str Asset to search active addresses (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD interval : str Interval frequency (possible values are: 24h, 1w, 1month) export : str diff --git a/website/content/SDK/crypto/dd/change/_index.rst b/website/content/SDK/crypto/dd/change/_index.rst index 05782687aa10..627aecf0ccf1 100644 --- a/website/content/SDK/crypto/dd/change/_index.rst +++ b/website/content/SDK/crypto/dd/change/_index.rst @@ -16,8 +16,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. crypto.dd.change( symbol: str, exchange: str = 'binance', - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -35,10 +35,10 @@ crypto.dd.change( Asset symbol to search supply (e.g., BTC) exchange : str Exchange to check net position change (e.g., binance) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD chart: bool Flag to display chart @@ -60,8 +60,8 @@ crypto.dd.change( crypto.dd.change( symbol: str, exchange: str = 'binance', - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, chart: bool = False, @@ -83,10 +83,10 @@ crypto.dd.change( Exchange to check net position change (possible values are: aggregated, binance, bittrex, coinex, gate.io, gemini, huobi, kucoin, poloniex, bibox, bigone, bitfinex, hitbtc, kraken, okex, bithumb, zb.com, cobinhood, bitmex, bitstamp, coinbase, coincheck, luno) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional diff --git a/website/content/SDK/crypto/dd/eb/_index.rst b/website/content/SDK/crypto/dd/eb/_index.rst index e5f70fabbb74..d11de6ae2c8e 100644 --- a/website/content/SDK/crypto/dd/eb/_index.rst +++ b/website/content/SDK/crypto/dd/eb/_index.rst @@ -16,8 +16,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. crypto.dd.eb( symbol: str, exchange: str = 'binance', - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -35,10 +35,10 @@ crypto.dd.eb( Asset to search active addresses (e.g., BTC) exchange : str Exchange to check net position change (e.g., binance) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD chart: bool Flag to display chart @@ -60,8 +60,8 @@ crypto.dd.eb( crypto.dd.eb( symbol: str, exchange: str = 'binance', - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', percentage: bool = False, export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, @@ -84,10 +84,10 @@ crypto.dd.eb( Exchange to check net position change (possible values are: aggregated, binance, bittrex, coinex, gate.io, gemini, huobi, kucoin, poloniex, bibox, bigone, bitfinex, hitbtc, kraken, okex, bithumb, zb.com, cobinhood, bitmex, bitstamp, coinbase, coincheck, luno) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD percentage : bool Show percentage instead of stacked value. export : str diff --git a/website/content/SDK/crypto/dd/gh/_index.rst b/website/content/SDK/crypto/dd/gh/_index.rst index 03316656cc7c..d360c1105d4a 100644 --- a/website/content/SDK/crypto/dd/gh/_index.rst +++ b/website/content/SDK/crypto/dd/gh/_index.rst @@ -17,8 +17,8 @@ crypto.dd.gh( symbol: str, dev_activity: bool = False, interval: str = '1d', - start_date: str = '2021-11-10T10:57:03Z', - end_date: str = '2022-11-10T10:57:03Z', + start_date: str = '2021-11-10T20:12:25Z', + end_date: str = '2022-11-10T20:12:25Z', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -63,9 +63,9 @@ crypto.dd.gh( {{< highlight python >}} crypto.dd.gh( symbol: str, - start_date: str = '2021-11-10T10:57:03Z', + start_date: str = '2021-11-10T20:12:25Z', dev_activity: bool = False, - end_date: str = '2022-11-10T10:57:03Z', + end_date: str = '2022-11-10T20:12:25Z', interval: str = '1d', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, diff --git a/website/content/SDK/crypto/dd/nonzero/_index.rst b/website/content/SDK/crypto/dd/nonzero/_index.rst index 795aa45afd03..940847ef3a7b 100644 --- a/website/content/SDK/crypto/dd/nonzero/_index.rst +++ b/website/content/SDK/crypto/dd/nonzero/_index.rst @@ -15,8 +15,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. {{< highlight python >}} crypto.dd.nonzero( symbol: str, - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -32,10 +32,10 @@ crypto.dd.nonzero( symbol : str Asset to search (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_577_836_800) - end_date : int - End date timestamp (e.g., 1_609_459_200) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD chart: bool Flag to display chart @@ -56,8 +56,8 @@ crypto.dd.nonzero( {{< highlight python >}} crypto.dd.nonzero( symbol: str, - start_date: int = 1577836800, - end_date: int = 1609459200, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, chart: bool = False, @@ -75,10 +75,10 @@ crypto.dd.nonzero( symbol : str Asset to search (e.g., BTC) - start_date : int - Initial date timestamp (e.g., 1_577_836_800) - end_date : int - End date timestamp (e.g., 1_609_459_200) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional diff --git a/website/content/SDK/crypto/load/_index.rst b/website/content/SDK/crypto/load/_index.rst index f48a0c805b57..c1784c7a945e 100644 --- a/website/content/SDK/crypto/load/_index.rst +++ b/website/content/SDK/crypto/load/_index.rst @@ -13,14 +13,12 @@ {{< highlight python >}} crypto.load( symbol: 'str', - start_date: 'datetime' = datetime.datetime( - 2019, 11, 6, 10, 57, 3, 350989, chart: bool = False, -), interval: 'str' = '1440', + start_date: 'Optional[Union[datetime, str]]' = None, + interval: 'str' = '1440', exchange: 'str' = 'binance', vs_currency: 'str' = 'usdt', - end_date: 'datetime' = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 350990, chart: bool = False, -), source: 'str' = 'CCXT', + end_date: 'Optional[Union[datetime, str]]' = None, + source: 'str' = 'CCXT', chart: bool = False, ) -> 'pd.DataFrame' {{< /highlight >}} @@ -35,8 +33,8 @@ crypto.load( symbol: str Coin to get - start_date: datetime - The datetime to start at + start_date: str or datetime, optional + Start date to get data from with. - datetime or string format (YYYY-MM-DD) interval: str The interval between data points in minutes. Choose from: 1, 15, 30, 60, 240, 1440, 10080, 43200 @@ -44,8 +42,8 @@ crypto.load( The exchange to get data from. vs_currency: str Quote Currency (Defaults to usdt) - end_date: datetime - The datetime to end at + end_date: str or datetime, optional + End date to get data from with. - datetime or string format (YYYY-MM-DD) source: str The source of the data Choose from: CCXT, CoinGecko, YahooFinance diff --git a/website/content/SDK/crypto/onchain/btc_supply/_index.rst b/website/content/SDK/crypto/onchain/btc_supply/_index.rst index 896ab8783597..709447b6fa09 100644 --- a/website/content/SDK/crypto/onchain/btc_supply/_index.rst +++ b/website/content/SDK/crypto/onchain/btc_supply/_index.rst @@ -37,8 +37,8 @@ crypto.onchain.btc_supply() -> pandas.core.frame.DataFrame {{< highlight python >}} crypto.onchain.btc_supply( - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, chart: bool = False, @@ -53,10 +53,10 @@ crypto.onchain.btc_supply( * **Parameters** - start_date : int - Initial date timestamp (e.g., 1_609_459_200) - until : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional diff --git a/website/content/SDK/crypto/onchain/btc_transac/_index.rst b/website/content/SDK/crypto/onchain/btc_transac/_index.rst index c6123af388e9..558642af7c18 100644 --- a/website/content/SDK/crypto/onchain/btc_transac/_index.rst +++ b/website/content/SDK/crypto/onchain/btc_transac/_index.rst @@ -37,8 +37,8 @@ crypto.onchain.btc_transac() -> pandas.core.frame.DataFrame {{< highlight python >}} crypto.onchain.btc_transac( - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, chart: bool = False, @@ -53,10 +53,10 @@ crypto.onchain.btc_transac( * **Parameters** - since : int - Initial date timestamp (e.g., 1_609_459_200) - until : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file external_axes : Optional[List[plt.Axes]], optional diff --git a/website/content/SDK/crypto/onchain/hr/_index.rst b/website/content/SDK/crypto/onchain/hr/_index.rst index e36764e70005..b071a0485e37 100644 --- a/website/content/SDK/crypto/onchain/hr/_index.rst +++ b/website/content/SDK/crypto/onchain/hr/_index.rst @@ -16,8 +16,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. crypto.onchain.hr( symbol: str, interval: str = '24h', - start_date: int = 1289645823, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -33,10 +33,10 @@ crypto.onchain.hr( symbol : str Blockchain to check hashrate (BTC or ETH) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD interval : str Interval frequency (e.g., 24h) chart: bool @@ -59,8 +59,8 @@ crypto.onchain.hr( {{< highlight python >}} crypto.onchain.hr( symbol: str, - start_date: int = 1636541823, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', interval: str = '24h', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, @@ -79,10 +79,10 @@ crypto.onchain.hr( symbol : str Blockchain to check mean hashrate (BTC or ETH) - start_date : int - Initial date timestamp (e.g., 1_614_556_800) - end_date : int - End date timestamp (e.g., 1_614_556_800) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD interval : str Interval frequency (possible values are: 24, 1w, 1month) export : str diff --git a/website/content/SDK/crypto/ov/altindex/_index.rst b/website/content/SDK/crypto/ov/altindex/_index.rst index 0f27aaef181a..f3043fc27aec 100644 --- a/website/content/SDK/crypto/ov/altindex/_index.rst +++ b/website/content/SDK/crypto/ov/altindex/_index.rst @@ -15,8 +15,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. {{< highlight python >}} crypto.ov.altindex( period: int = 30, - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', chart: bool = False, ) -> pandas.core.frame.DataFrame {{< /highlight >}} @@ -34,10 +34,10 @@ crypto.ov.altindex( Number of days {30,90,365} to check performance of coins and calculate the altcoin index. E.g., 365 checks yearly performance, 90 will check seasonal performance (90 days), 30 will check monthly performance (30 days). - start_date : int - Initial date timestamp (e.g., 1_609_459_200) - end_date : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD chart: bool Flag to display chart @@ -58,8 +58,8 @@ crypto.ov.altindex( {{< highlight python >}} crypto.ov.altindex( period: int = 365, - start_date: int = 1262304000, - end_date: int = 1668077823, + start_date: str = '2010-01-01', + end_date: str = '2022-11-10', export: str = '', external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None, chart: bool = False, @@ -75,10 +75,10 @@ crypto.ov.altindex( * **Parameters** - start_date : int - Initial date timestamp (e.g., 1_609_459_200) - end_date : int - End date timestamp (e.g., 1_641_588_030) + start_date : str + Initial date, format YYYY-MM-DD + end_date : str + Final date, format YYYY-MM-DD period: int Number of days to check the performance of coins and calculate the altcoin index. E.g., 365 will check yearly performance , 90 will check seasonal performance (90 days), diff --git a/website/content/SDK/etf/candle/_index.rst b/website/content/SDK/etf/candle/_index.rst index 6d8234dcb2b2..fbd1746d544a 100644 --- a/website/content/SDK/etf/candle/_index.rst +++ b/website/content/SDK/etf/candle/_index.rst @@ -19,14 +19,10 @@ etf.candle( add_trend: bool = False, ma: Optional[Iterable[int]] = None, asset_type: str = '', - start_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2019, 11, 6, 10, 57, 3, 415209, chart: bool = False, -), interval: int = 1440, - end_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 415211, chart: bool = False, -), prepost: bool = False, + start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06', + interval: int = 1440, + end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10', + prepost: bool = False, source: str = 'YahooFinance', iexrange: str = 'ytd', weekly: bool = False, diff --git a/website/content/SDK/etf/load/_index.rst b/website/content/SDK/etf/load/_index.rst index b556833a108d..971dd3eff1ff 100644 --- a/website/content/SDK/etf/load/_index.rst +++ b/website/content/SDK/etf/load/_index.rst @@ -13,14 +13,10 @@ {{< highlight python >}} etf.load( symbol: str, - start_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2019, 11, 6, 10, 57, 3, 415198, chart: bool = False, -), interval: int = 1440, - end_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 415206, chart: bool = False, -), prepost: bool = False, + start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06', + interval: int = 1440, + end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10', + prepost: bool = False, source: str = 'YahooFinance', iexrange: str = 'ytd', weekly: bool = False, diff --git a/website/content/SDK/stocks/ba/trend/_index.rst b/website/content/SDK/stocks/ba/trend/_index.rst index 9d902b87403b..9a87c9b81e87 100644 --- a/website/content/SDK/stocks/ba/trend/_index.rst +++ b/website/content/SDK/stocks/ba/trend/_index.rst @@ -14,9 +14,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter. {{< highlight python >}} stocks.ba.trend( - start_date: datetime.datetime = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 4358, chart: bool = False, -), hour: int = 0, + start_date: str = '2022-11-10', + hour: int = 0, number: int = 10, chart: bool = False, ) -> pandas.core.frame.DataFrame @@ -33,8 +32,8 @@ stocks.ba.trend( * **Parameters** - start_date: datetime - Datetime object (e.g. datetime(2021, 12, 21) + start_date : str + Initial date, format YYYY-MM-DD hour: int Hour of the day in 24-hour notation (e.g. 14) number : int @@ -59,9 +58,8 @@ stocks.ba.trend( {{< highlight python >}} stocks.ba.trend( - start_date: datetime.datetime = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 4582, chart: bool = False, -), hour: int = 0, + start_date: str = '2022-11-10', + hour: int = 0, number: int = 10, limit: int = 10, export: str = '', @@ -78,8 +76,8 @@ stocks.ba.trend( * **Parameters** - start_date: datetime - Datetime object (e.g. datetime(2021, 12, 21) + start_date : str + Initial date, format YYYY-MM-DD hour: int Hour of the day in 24-hour notation (e.g. 14) number : int diff --git a/website/content/SDK/stocks/candle/_index.rst b/website/content/SDK/stocks/candle/_index.rst index b0f4bc7233d2..59901a1afa40 100644 --- a/website/content/SDK/stocks/candle/_index.rst +++ b/website/content/SDK/stocks/candle/_index.rst @@ -19,14 +19,10 @@ stocks.candle( add_trend: bool = False, ma: Optional[Iterable[int]] = None, asset_type: str = '', - start_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2019, 11, 6, 10, 57, 3, 415209, chart: bool = False, -), interval: int = 1440, - end_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 415211, chart: bool = False, -), prepost: bool = False, + start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06', + interval: int = 1440, + end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10', + prepost: bool = False, source: str = 'YahooFinance', iexrange: str = 'ytd', weekly: bool = False, diff --git a/website/content/SDK/stocks/load/_index.rst b/website/content/SDK/stocks/load/_index.rst index 9764bb9971a5..3b8e9fe73e56 100644 --- a/website/content/SDK/stocks/load/_index.rst +++ b/website/content/SDK/stocks/load/_index.rst @@ -13,14 +13,10 @@ {{< highlight python >}} stocks.load( symbol: str, - start_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2019, 11, 6, 10, 57, 3, 415198, chart: bool = False, -), interval: int = 1440, - end_date: Union[datetime.datetime, str, - NoneType] = datetime.datetime( - 2022, 11, 10, 10, 57, 3, 415206, chart: bool = False, -), prepost: bool = False, + start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06', + interval: int = 1440, + end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10', + prepost: bool = False, source: str = 'YahooFinance', iexrange: str = 'ytd', weekly: bool = False,