From cf39c910c23634ffe462c95e896788b7fcc5c636 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 21 Nov 2022 21:42:06 -0500 Subject: [PATCH 1/4] Report fixes --- .../reports/templates/equity.ipynb | 42 +++++++------------ openbb_terminal/reports/templates/etf.ipynb | 14 +++++-- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/openbb_terminal/reports/templates/equity.ipynb b/openbb_terminal/reports/templates/equity.ipynb index 91d5dc828e62..f3a21c511440 100644 --- a/openbb_terminal/reports/templates/equity.ipynb +++ b/openbb_terminal/reports/templates/equity.ipynb @@ -317,7 +317,9 @@ "outputs": [], "source": [ "expiry_dates = openbb.stocks.options.expirations(symbol)\n", - "exp = expiry_dates[0]" + "exp = expiry_dates[0]\n", + "option_chain = openbb.stocks.options.chains(symbol, expiration=exp)\n", + "current_price = float(info[\"Previous close\"][0])" ] }, { @@ -328,13 +330,13 @@ "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(11, 3), dpi=150)\n", - "openbb.stocks.options.vol_yf_chart(\n", - " symbol,\n", - " exp,\n", - " external_axes=[\n", - " ax,\n", - " ],\n", + "ax.plot(\n", + " option_chain[\"strike\"], option_chain[\"c_Openinterest\"], label=\"Call Open Interest\"\n", + ")\n", + "ax.plot(\n", + " option_chain[\"strike\"], option_chain[\"p_Openinterest\"], label=\"Put Open Interest\"\n", ")\n", + "ax.legend()\n", "fig.tight_layout()\n", "f = io.BytesIO()\n", "fig.savefig(f, format=\"svg\")\n", @@ -349,31 +351,15 @@ "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(11, 8), dpi=150)\n", - "openbb.stocks.options.voi_yf_chart(\n", - " symbol,\n", - " exp,\n", - " external_axes=[\n", - " ax,\n", - " ],\n", - ")\n", + "ax.plot(option_chain[\"strike\"], option_chain[\"c_Volume\"], label=\"Call Volume\")\n", + "ax.plot(option_chain[\"strike\"], option_chain[\"p_Volume\"], label=\"Put Volume\")\n", + "ax.legend()\n", "fig.tight_layout()\n", "f = io.BytesIO()\n", "fig.savefig(f, format=\"svg\")\n", "voi_chart = f.getvalue().decode(\"utf-8\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "fc0fdd88", - "metadata": {}, - "outputs": [], - "source": [ - "current_price = float(info[\"Previous close\"][0])\n", - "options_df = openbb.stocks.options.chains(symbol, expiration=exp, source=\"YahooFinance\")\n", - "options_df.reset_index(drop=True, inplace=True)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -503,7 +489,7 @@ "metadata": {}, "outputs": [], "source": [ - "similar_companies = openbb.stocks.ca.polygon_peers(symbol)\n", + "similar_companies = openbb.stocks.ca.similar(symbol, source=\"Polygon\")\n", "similar_companies.append(symbol)" ] }, @@ -1363,7 +1349,7 @@ "htmlcode += widgets.row(\n", " [\n", " widgets.p(\n", - " \"Note that similar companies have been found using openbb.stocks.ca.polygon_peers\"\n", + " \"Note that similar companies have been found using openbb.stocks.ca.similar\"\n", " )\n", " ]\n", ")\n", diff --git a/openbb_terminal/reports/templates/etf.ipynb b/openbb_terminal/reports/templates/etf.ipynb index 4fb4486924b5..5d2ed00ac88f 100644 --- a/openbb_terminal/reports/templates/etf.ipynb +++ b/openbb_terminal/reports/templates/etf.ipynb @@ -200,7 +200,13 @@ "outputs": [], "source": [ "fig, ax = plt.subplots(dpi=150)\n", - "openbb.etf.weights_chart(ticker, external_axes=[ax])\n", + "ax.pie(\n", + " weights_df[weights_df[\"Percentage\"] > 10][\"Percentage\"],\n", + " labels=weights_df[weights_df[\"Percentage\"] > 10].index,\n", + " autopct=\"%1.1f%%\",\n", + " shadow=True,\n", + " startangle=90,\n", + ")\n", "fig.tight_layout()\n", "f = io.BytesIO()\n", "fig.savefig(f, format=\"svg\")\n", @@ -280,7 +286,7 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "Python 3.9.13 ('obb')", + "display_name": "Python 3.9.6 ('obb')", "language": "python", "name": "python3" }, @@ -294,11 +300,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.6" }, "vscode": { "interpreter": { - "hash": "e784374cc4f9a84ed6af2983247aaf351b155c82bcc2188134a65f3c99031000" + "hash": "cb66ba39c97f15743fbb79e204a841ea03600987d49579cfb0ffc8e8dd934c69" } } }, From 7952d39b989df40da3b53bdf957d6812bb1ac9e8 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 22 Nov 2022 12:29:19 +0000 Subject: [PATCH 2/4] replace wrong typing --- .../sentimentinvestor_model.py | 14 ++++++------- .../sentimentinvestor_view.py | 12 +++++------ openbb_terminal/common/newsapi_model.py | 6 +++--- openbb_terminal/common/newsapi_view.py | 5 +++-- .../common/technical_analysis/overlap_view.py | 12 +++++------ .../due_diligence/glassnode_model.py | 21 ++++++++++--------- .../due_diligence/glassnode_view.py | 18 ++++++++-------- .../due_diligence/messari_model.py | 18 ++++++++-------- .../due_diligence/messari_view.py | 16 +++++++------- .../due_diligence/santiment_model.py | 9 ++++---- .../due_diligence/santiment_view.py | 8 +++---- .../cryptocurrency/onchain/blockchain_view.py | 8 +++---- .../overview/blockchaincenter_model.py | 5 +++-- .../overview/blockchaincenter_view.py | 4 ++-- .../overview/glassnode_model.py | 5 +++-- .../cryptocurrency/overview/glassnode_view.py | 4 ++-- openbb_terminal/economy/econdb_model.py | 18 ++++++++-------- openbb_terminal/economy/econdb_view.py | 8 +++---- openbb_terminal/economy/fred_model.py | 12 ++++++----- openbb_terminal/economy/fred_view.py | 8 +++---- openbb_terminal/economy/nasdaq_model.py | 10 ++++----- openbb_terminal/forex/forex_helper.py | 4 ++-- openbb_terminal/forex/polygon_model.py | 5 +++-- openbb_terminal/futures/yfinance_view.py | 4 ++-- .../behavioural_analysis/finnhub_model.py | 10 ++++----- .../yahoo_finance_model.py | 14 ++++++------- .../comparison_analysis/yahoo_finance_view.py | 12 +++++------ .../stocks/dark_pool_shorts/sec_model.py | 9 ++++---- .../stocks/dark_pool_shorts/sec_view.py | 8 +++---- .../stocks/discovery/finnhub_model.py | 8 +++---- .../due_diligence/business_insider_view.py | 4 ++-- .../yahoo_finance_model.py | 6 +++--- .../yahoo_finance_view.py | 4 ++-- .../stocks/insider/businessinsider_view.py | 4 ++-- .../stocks/options/alphaquery_model.py | 5 +++-- 35 files changed, 164 insertions(+), 154 deletions(-) diff --git a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py index 2141fc1d7c35..856dba11d3f6 100644 --- a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py +++ b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_model.py @@ -1,7 +1,7 @@ """SentimentInvestor Model""" __docformat__ = "numpy" -from typing import Union, Dict +from typing import Union, Dict, Optional from datetime import datetime, timedelta import logging @@ -19,8 +19,8 @@ @check_api_key(["API_SENTIMENTINVESTOR_TOKEN"]) def get_historical( symbol: str, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, number: int = 100, ) -> pd.DataFrame: """Get hour-level sentiment data for the chosen symbol. @@ -31,9 +31,9 @@ def get_historical( ---------- symbol: str Ticker to view sentiment data - start_date: str + start_date: Optional[str] Initial date like string or unix timestamp (e.g. 12-21-2021) - end_date: str + end_date: Optional[str] End date like string or unix timestamp (e.g. 12-21-2021) number : int Number of results returned by API call @@ -134,7 +134,7 @@ def check_supported_ticker(symbol: str) -> bool: @check_api_key(["API_SENTIMENTINVESTOR_TOKEN"]) def get_trending( - start_date: str = None, + start_date: Optional[str] = None, hour: int = 0, number: int = 10, ) -> pd.DataFrame: @@ -143,7 +143,7 @@ def get_trending( Parameters ---------- - start_date : str + start_date : Optional[str] Initial date, format YYYY-MM-DD hour: int Hour of the day in 24-hour notation (e.g. 14) diff --git a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py index d96d46f43297..cb87284b3a5d 100644 --- a/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py +++ b/openbb_terminal/common/behavioural_analysis/sentimentinvestor_view.py @@ -30,8 +30,8 @@ @check_api_key(["API_SENTIMENTINVESTOR_TOKEN"]) def display_historical( symbol: str, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, number: int = 100, raw: bool = False, limit: int = 10, @@ -45,9 +45,9 @@ def display_historical( ---------- symbol: str Ticker symbol to view sentiment data - start_date: str + start_date: Optional[str] Initial date like string or unix timestamp (e.g. 2021-12-21) - end_date: str + end_date: Optional[str] End date like string or unix timestamp (e.g. 2022-01-15) number: int Number of results returned by API call @@ -150,7 +150,7 @@ def display_historical( @log_start_end(log=logger) @check_api_key(["API_SENTIMENTINVESTOR_TOKEN"]) def display_trending( - start_date: str = None, + start_date: Optional[str] = None, hour: int = 0, number: int = 10, limit: int = 10, @@ -161,7 +161,7 @@ def display_trending( Parameters ---------- - start_date : str + start_date : Optional[str] Initial date, format YYYY-MM-DD hour: int Hour of the day in 24-hour notation (e.g. 14) diff --git a/openbb_terminal/common/newsapi_model.py b/openbb_terminal/common/newsapi_model.py index e54ee8fe1683..eba9ef25a168 100644 --- a/openbb_terminal/common/newsapi_model.py +++ b/openbb_terminal/common/newsapi_model.py @@ -4,7 +4,7 @@ import logging from datetime import datetime, timedelta -from typing import Any, List, Tuple +from typing import Any, List, Optional, Tuple import requests import pandas as pd from openbb_terminal import config_terminal as cfg @@ -19,7 +19,7 @@ def get_news( query: str, limit: int = 10, - start_date: str = None, + start_date: Optional[str] = None, show_newest: bool = True, sources: str = "", ) -> List[Tuple[pd.DataFrame, Any]]: @@ -29,7 +29,7 @@ def get_news( ---------- query : str term to search on the news articles - start_date: str + start_date: Optional[str] date to start searching articles from formatted YYYY-MM-DD show_newest: bool flag to show newest articles first diff --git a/openbb_terminal/common/newsapi_view.py b/openbb_terminal/common/newsapi_view.py index ddb6e98cfc75..3493dcffe138 100644 --- a/openbb_terminal/common/newsapi_view.py +++ b/openbb_terminal/common/newsapi_view.py @@ -3,6 +3,7 @@ import os import logging +from typing import Optional import pandas as pd @@ -20,7 +21,7 @@ def display_news( query: str, limit: int = 3, - start_date: str = None, + start_date: Optional[str] = None, show_newest: bool = True, sources: str = "", export: str = "", @@ -31,7 +32,7 @@ def display_news( ---------- query : str term to search on the news articles - start_date: str + start_date: Optional[str] date to start searching articles from formatted YYYY-MM-DD limit : int number of articles to display diff --git a/openbb_terminal/common/technical_analysis/overlap_view.py b/openbb_terminal/common/technical_analysis/overlap_view.py index 66e9ff02fd04..e975cb0c9880 100644 --- a/openbb_terminal/common/technical_analysis/overlap_view.py +++ b/openbb_terminal/common/technical_analysis/overlap_view.py @@ -121,8 +121,8 @@ def view_ma( def view_vwap( data: pd.DataFrame, symbol: str = "", - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, offset: int = 0, interval: str = "", export: str = "", @@ -138,10 +138,10 @@ def view_vwap( Ticker offset : int Offset variable - start_date: datetime - Start date to get data from with - end_date: datetime - End date to get data from with + start_date: Optional[str] + Initial date, format YYYY-MM-DD + end_date: Optional[str] + Final date, format YYYY-MM-DD interval : str Interval of data export : str diff --git a/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py b/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py index 16ba962cf84a..35ed7dfc1b27 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py +++ b/openbb_terminal/cryptocurrency/due_diligence/glassnode_model.py @@ -1,6 +1,7 @@ from datetime import datetime import logging import json +from typing import Optional import pandas as pd import requests @@ -181,7 +182,7 @@ def get_close_price( symbol: str, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, print_errors: bool = True, ) -> pd.DataFrame: """Returns the price of a cryptocurrency @@ -249,7 +250,7 @@ def get_close_price( def get_non_zero_addresses( symbol: str, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns addresses with non-zero balance of a certain symbol [Source: https://glassnode.com] @@ -312,7 +313,7 @@ def get_active_addresses( symbol: str, interval: str = "24h", start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns active addresses of a certain symbol [Source: https://glassnode.com] @@ -376,7 +377,7 @@ def get_hashrate( symbol: str, interval: str = "24h", start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns dataframe with mean hashrate of btc or eth blockchain and symbol price [Source: https://glassnode.com] @@ -454,7 +455,7 @@ def get_exchange_balances( symbol: str, exchange: str = "binance", start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns the total amount of coins held on exchange addresses in units and percentage. [Source: https://glassnode.com] @@ -465,9 +466,9 @@ 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 : str + start_date : Optional[str] Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD Returns @@ -540,7 +541,7 @@ def get_exchange_net_position_change( symbol: str, exchange: str = "binance", start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns 30d change of the supply held in exchange wallets of a certain symbol. [Source: https://glassnode.com] @@ -551,9 +552,9 @@ 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 : str + start_date : Optional[str] Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD Returns diff --git a/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py b/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py index 448047a054d4..56d1c9df7b1b 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py +++ b/openbb_terminal/cryptocurrency/due_diligence/glassnode_view.py @@ -33,7 +33,7 @@ def display_active_addresses( symbol: str, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, interval: str = "24h", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -47,7 +47,7 @@ def display_active_addresses( Asset to search active addresses (e.g., BTC) start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD interval : str Interval frequency (possible values are: 24h, 1w, 1month) @@ -97,7 +97,7 @@ def display_active_addresses( def display_non_zero_addresses( symbol: str, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -110,7 +110,7 @@ def display_non_zero_addresses( Asset to search (e.g., BTC) start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file @@ -159,7 +159,7 @@ def display_exchange_net_position_change( symbol: str, exchange: str = "binance", start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -176,7 +176,7 @@ def display_exchange_net_position_change( hitbtc, kraken, okex, bithumb, zb.com, cobinhood, bitmex, bitstamp, coinbase, coincheck, luno) start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file @@ -240,7 +240,7 @@ def display_exchange_balances( symbol: str, exchange: str = "binance", start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, percentage: bool = False, export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -319,7 +319,7 @@ def display_exchange_balances( def display_hashrate( symbol: str, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, interval: str = "24h", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -333,7 +333,7 @@ def display_hashrate( Blockchain to check mean hashrate (BTC or ETH) start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD interval : str Interval frequency (possible values are: 24, 1w, 1month) diff --git a/openbb_terminal/cryptocurrency/due_diligence/messari_model.py b/openbb_terminal/cryptocurrency/due_diligence/messari_model.py index ac8b6f7acdf2..db42333406c6 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/messari_model.py +++ b/openbb_terminal/cryptocurrency/due_diligence/messari_model.py @@ -4,7 +4,7 @@ # pylint: disable=C0301,C0302 import logging -from typing import Any, Tuple +from typing import Any, Optional, Tuple from datetime import datetime, timedelta import re import pandas as pd @@ -81,8 +81,8 @@ def get_available_timeseries(only_free: bool = True) -> pd.DataFrame: def get_marketcap_dominance( symbol: str, interval: str = "1d", - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns market dominance of a coin over time [Source: https://messari.io/] @@ -93,9 +93,9 @@ def get_marketcap_dominance( Crypto symbol to check market cap dominance interval : str Interval frequency (possible values are: 5m, 15m, 30m, 1h, 1d, 1w) - start_date : int + start_date : Optional[str] Initial date like string (e.g., 2021-10-01) - end_date : int + end_date : Optional[str] End date like string (e.g., 2021-10-01) Returns @@ -126,8 +126,8 @@ def get_messari_timeseries( symbol: str, timeseries_id: str, interval: str = "1d", - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> Tuple[pd.DataFrame, str]: """Returns messari timeseries [Source: https://messari.io/] @@ -140,9 +140,9 @@ def get_messari_timeseries( Messari timeserie id interval : str Interval frequency (possible values are: 5m, 15m, 30m, 1h, 1d, 1w) - start : int + start : Optional[str] Initial date like string (e.g., 2021-10-01) - end : int + end : Optional[str] End date like string (e.g., 2021-10-01) Returns diff --git a/openbb_terminal/cryptocurrency/due_diligence/messari_view.py b/openbb_terminal/cryptocurrency/due_diligence/messari_view.py index 42affc2a6b9b..bdcefcfaa619 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/messari_view.py +++ b/openbb_terminal/cryptocurrency/due_diligence/messari_view.py @@ -104,8 +104,8 @@ def display_messari_timeseries_list( def display_messari_timeseries( symbol: str, timeseries_id: str, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, interval: str = "1d", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -119,9 +119,9 @@ def display_messari_timeseries( Crypto symbol to check market cap dominance timeseries_id: str Obtained by api.crypto.dd.get_mt command - start_date : int + start_date : Optional[str] Initial date like string (e.g., 2021-10-01) - end_date : int + end_date : Optional[str] End date like string (e.g., 2021-10-01) interval : str Interval frequency (possible values are: 5m, 15m, 30m, 1h, 1d, 1w) @@ -181,8 +181,8 @@ def display_messari_timeseries( @check_api_key(["API_MESSARI_KEY"]) def display_marketcap_dominance( symbol: str, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, interval: str = "1d", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -194,9 +194,9 @@ def display_marketcap_dominance( ---------- symbol : str Crypto symbol to check market cap dominance - start_date : int + start_date : Optional[str] Initial date like string (e.g., 2021-10-01) - end_date : int + end_date : Optional[str] End date like string (e.g., 2021-10-01) interval : str Interval frequency (possible values are: 5m, 15m, 30m, 1h, 1d, 1w) diff --git a/openbb_terminal/cryptocurrency/due_diligence/santiment_model.py b/openbb_terminal/cryptocurrency/due_diligence/santiment_model.py index 37fb366542bb..06f3e586cca0 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/santiment_model.py +++ b/openbb_terminal/cryptocurrency/due_diligence/santiment_model.py @@ -1,5 +1,6 @@ import logging from datetime import datetime, timedelta +from typing import Optional import requests @@ -30,8 +31,8 @@ def get_github_activity( symbol: str, dev_activity: bool = False, interval: str = "1d", - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Returns a list of developer activity for a given coin and time interval. @@ -45,9 +46,9 @@ def get_github_activity( Whether to filter only for development activity interval : str Interval frequency (e.g., 1d) - start_date : int + start_date : Optional[str] Initial date like string (e.g., 2021-10-01) - end_date : int + end_date : Optional[str] End date like string (e.g., 2021-10-01) Returns diff --git a/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py b/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py index 2aa24d4581db..7c069db528ad 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py +++ b/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py @@ -25,9 +25,9 @@ @check_api_key(["API_SANTIMENT_KEY"]) def display_github_activity( symbol: str, - start_date: str = None, + start_date: Optional[str] = None, dev_activity: bool = False, - end_date: str = None, + end_date: Optional[str] = None, interval: str = "1d", export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -42,9 +42,9 @@ def display_github_activity( Crypto symbol to check github activity dev_activity: bool Whether to filter only for development activity - start_date : int + start_date : Optional[str] Initial date like string (e.g., 2021-10-01) - end_date : int + end_date : Optional[str] End date like string (e.g., 2021-10-01) interval : str Interval frequency (some possible values are: 1h, 1d, 1w) diff --git a/openbb_terminal/cryptocurrency/onchain/blockchain_view.py b/openbb_terminal/cryptocurrency/onchain/blockchain_view.py index 467240f10dec..1a5c69a35a36 100644 --- a/openbb_terminal/cryptocurrency/onchain/blockchain_view.py +++ b/openbb_terminal/cryptocurrency/onchain/blockchain_view.py @@ -27,7 +27,7 @@ @log_start_end(log=logger) def display_btc_circulating_supply( start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -37,7 +37,7 @@ def display_btc_circulating_supply( ---------- start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file @@ -87,7 +87,7 @@ def display_btc_circulating_supply( @log_start_end(log=logger) def display_btc_confirmed_transactions( start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -97,7 +97,7 @@ def display_btc_confirmed_transactions( ---------- start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file diff --git a/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py b/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py index 61eccc0568bc..45ec4b3e4657 100644 --- a/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py +++ b/openbb_terminal/cryptocurrency/overview/blockchaincenter_model.py @@ -2,6 +2,7 @@ import json import logging from datetime import datetime +from typing import Optional import pandas as pd import requests @@ -19,7 +20,7 @@ def get_altcoin_index( period: int = 30, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Get altcoin index overtime [Source: https://blockchaincenter.net] @@ -32,7 +33,7 @@ def get_altcoin_index( 30 will check monthly performance (30 days). start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD Returns diff --git a/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py b/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py index 3fa3f9881cde..3f46f386e664 100644 --- a/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py +++ b/openbb_terminal/cryptocurrency/overview/blockchaincenter_view.py @@ -27,7 +27,7 @@ def display_altcoin_index( period: int = 365, start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ) -> None: @@ -38,7 +38,7 @@ def display_altcoin_index( ---------- start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD period: int Number of days to check the performance of coins and calculate the altcoin index. diff --git a/openbb_terminal/cryptocurrency/overview/glassnode_model.py b/openbb_terminal/cryptocurrency/overview/glassnode_model.py index 11b5bea7dcda..9eabf7169126 100644 --- a/openbb_terminal/cryptocurrency/overview/glassnode_model.py +++ b/openbb_terminal/cryptocurrency/overview/glassnode_model.py @@ -1,5 +1,6 @@ from datetime import datetime import logging +from typing import Optional from pandas import DataFrame from openbb_terminal.decorators import log_start_end @@ -17,7 +18,7 @@ @log_start_end(log=logger) def get_btc_rainbow( start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> DataFrame: """Get bitcoin price data [Price data from source: https://glassnode.com] @@ -27,7 +28,7 @@ def get_btc_rainbow( ---------- start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD Returns diff --git a/openbb_terminal/cryptocurrency/overview/glassnode_view.py b/openbb_terminal/cryptocurrency/overview/glassnode_view.py index 19cadb6f88b6..b3a9813c9467 100644 --- a/openbb_terminal/cryptocurrency/overview/glassnode_view.py +++ b/openbb_terminal/cryptocurrency/overview/glassnode_view.py @@ -29,7 +29,7 @@ @check_api_key(["API_GLASSNODE_KEY"]) def display_btc_rainbow( start_date: str = "2010-01-01", - end_date: str = None, + end_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ): @@ -41,7 +41,7 @@ def display_btc_rainbow( ---------- start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD export : str Export dataframe data to csv,json,xlsx file diff --git a/openbb_terminal/economy/econdb_model.py b/openbb_terminal/economy/econdb_model.py index 70d4482694cd..522c2cbb2f17 100644 --- a/openbb_terminal/economy/econdb_model.py +++ b/openbb_terminal/economy/econdb_model.py @@ -4,7 +4,7 @@ # pylint: disable=no-member import logging -from typing import Dict, Any, Tuple, Union +from typing import Dict, Any, Optional, Tuple, Union from urllib.error import HTTPError from datetime import datetime @@ -483,8 +483,8 @@ def get_macro_data( parameter: str, country: str, transform: str = "", - start_date=None, - end_date=None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, symbol: str = "", ) -> Tuple[pd.Series, Union[str, Any]]: """Query the EconDB database to find specific macro data about a company [Source: EconDB] @@ -503,9 +503,9 @@ def get_macro_data( 'TUSD' - level USD, 'TPGP' - Percentage of GDP, 'TNOR' - Start = 100 - start_date : str + start_date : Optional[str] The starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31. - end_date : str + end_date : Optional[str] The end date, format "YEAR-MONTH-DAY", i.e. 2020-06-05. symbol : str In what currency you wish to convert all values. @@ -658,7 +658,7 @@ def get_aggregated_macro_data( countries: list = None, transform: str = "", start_date: str = "1900-01-01", - end_date: str = None, + end_date: Optional[str] = None, symbol: str = "", ) -> Tuple[pd.DataFrame, Dict[Any, Dict[Any, Any]], str]: """This functions groups the data queried from the EconDB database [Source: EconDB] @@ -673,7 +673,7 @@ def get_aggregated_macro_data( The selected transform. Available transforms can be accessed through get_macro_transform(). start_date : str The starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31. - end_date : str + end_date : Optional[str] The end date, format "YEAR-MONTH-DAY", i.e. 2020-06-05. symbol : str In what currency you wish to convert all values. @@ -739,7 +739,7 @@ def get_treasuries( maturities: list = None, frequency: str = "monthly", start_date: str = "1900-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Get U.S. Treasury rates [Source: EconDB] @@ -754,7 +754,7 @@ def get_treasuries( Frequency of the data, this can be annually, monthly, weekly or daily. start_date : str Starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31. - end_date : str + end_date : Optional[str] End date, format "YEAR-MONTH-DAY", i.e. 2020-06-05. Returns diff --git a/openbb_terminal/economy/econdb_view.py b/openbb_terminal/economy/econdb_view.py index 47771acaaa1a..616dab4a9f25 100644 --- a/openbb_terminal/economy/econdb_view.py +++ b/openbb_terminal/economy/econdb_view.py @@ -27,7 +27,7 @@ def show_macro_data( countries: list = None, transform: str = "", start_date: str = "1900-01-01", - end_date: str = None, + end_date: Optional[str] = None, symbol: str = "", raw: bool = False, external_axes: Optional[List[plt.axes]] = None, @@ -51,7 +51,7 @@ def show_macro_data( 'TNOR' - Start = 100 start_date : str The starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31. - end_date : str + end_date : Optional[str] The end date, format "YEAR-MONTH-DAY", i.e. 2020-06-05. symbol : str In what currency you wish to convert all values. @@ -147,7 +147,7 @@ def show_treasuries( maturities: list = None, frequency: str = "monthly", start_date: str = "1900-01-01", - end_date: str = None, + end_date: Optional[str] = None, raw: bool = False, external_axes: Optional[List[plt.axes]] = None, export: str = "", @@ -165,7 +165,7 @@ def show_treasuries( Frequency of the data, this can be daily, weekly, monthly or annually start_date : str Starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31. - end_date : str + end_date : Optional[str] End date, format "YEAR-MONTH-DAY", i.e. 2020-06-05. raw : bool Whether to display the raw output. diff --git a/openbb_terminal/economy/fred_model.py b/openbb_terminal/economy/fred_model.py index 0997fc1ad1af..220285c64b94 100644 --- a/openbb_terminal/economy/fred_model.py +++ b/openbb_terminal/economy/fred_model.py @@ -4,7 +4,7 @@ import os import logging import textwrap -from typing import List, Tuple +from typing import List, Optional, Tuple from datetime import datetime, timedelta from requests import HTTPError @@ -169,7 +169,7 @@ def get_series_ids(search_query: str, limit: int = -1) -> pd.DataFrame: @log_start_end(log=logger) @check_api_key(["API_FRED_KEY"]) def get_series_data( - series_id: str, start_date: str = None, end_date: str = None + series_id: str, start_date: Optional[str] = None, end_date: Optional[str] = None ) -> pd.DataFrame: """Get Series data. [Source: FRED] @@ -177,9 +177,9 @@ def get_series_data( ---------- series_id : str Series ID to get data from - start_date : str + start_date : Optional[str] Start date to get data from, format yyyy-mm-dd - end_date : str + end_date : Optional[str] End data to get from, format yyyy-mm-dd Returns @@ -207,7 +207,9 @@ def get_series_data( @log_start_end(log=logger) @check_api_key(["API_FRED_KEY"]) def get_aggregated_series_data( - series_ids: List[str], start_date: str = None, end_date: str = None + series_ids: List[str], + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> Tuple[pd.DataFrame, dict]: """Get Series data. [Source: FRED] diff --git a/openbb_terminal/economy/fred_view.py b/openbb_terminal/economy/fred_view.py index a53052d94660..c362d726eecd 100644 --- a/openbb_terminal/economy/fred_view.py +++ b/openbb_terminal/economy/fred_view.py @@ -76,8 +76,8 @@ def notes(search_query: str, limit: int = 10): @check_api_key(["API_FRED_KEY"]) def display_fred_series( series_ids: List[str], - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, limit: int = 10, get_data: bool = False, raw: bool = False, @@ -90,9 +90,9 @@ def display_fred_series( ---------- series_ids : List[str] FRED Series ID from https://fred.stlouisfed.org. For multiple series use: series1,series2,series3 - start_date : str + start_date : Optional[str] Starting date (YYYY-MM-DD) of data - end_date : str + end_date : Optional[str] Ending date (YYYY-MM-DD) of data limit : int Number of data points to display. diff --git a/openbb_terminal/economy/nasdaq_model.py b/openbb_terminal/economy/nasdaq_model.py index 945870818feb..a81bd8874305 100644 --- a/openbb_terminal/economy/nasdaq_model.py +++ b/openbb_terminal/economy/nasdaq_model.py @@ -4,7 +4,7 @@ import argparse import logging import os -from typing import List, Union +from typing import List, Optional, Union from datetime import datetime as dt import pandas as pd @@ -20,8 +20,8 @@ @log_start_end(log=logger) def get_economic_calendar( countries: Union[List[str], str] = "", - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Get economic calendar for countries between specified dates @@ -29,9 +29,9 @@ def get_economic_calendar( ---------- countries : [List[str],str] List of countries to include in calendar. Empty returns all - start_date : str + start_date : Optional[str] Start date for calendar - end_date : str + end_date : Optional[str] End date for calendar Returns diff --git a/openbb_terminal/forex/forex_helper.py b/openbb_terminal/forex/forex_helper.py index 5294556d898d..b608cbed1b2e 100644 --- a/openbb_terminal/forex/forex_helper.py +++ b/openbb_terminal/forex/forex_helper.py @@ -97,7 +97,7 @@ def load( from_symbol: str, resolution: str = "d", interval: str = "1day", - start_date: str = None, + start_date: Optional[str] = None, source: str = "YahooFinance", verbose: bool = False, ) -> pd.DataFrame: @@ -113,7 +113,7 @@ def load( The resolution for the data, by default "d" interval : str, optional What interval to get data for, by default "1day" - start_date : str, optional + start_date : Optional[str], optional When to begin loading in data, by default last_year.strftime("%Y-%m-%d") source : str, optional Where to get data from, by default "YahooFinance" diff --git a/openbb_terminal/forex/polygon_model.py b/openbb_terminal/forex/polygon_model.py index 251528ad87f6..aa2938fec550 100644 --- a/openbb_terminal/forex/polygon_model.py +++ b/openbb_terminal/forex/polygon_model.py @@ -2,6 +2,7 @@ __docformat__ = "numpy" from datetime import datetime +from typing import Optional import requests import pandas as pd from openbb_terminal.config_terminal import API_POLYGON_KEY as api_key @@ -18,7 +19,7 @@ def get_historical( multiplier: int = 1, timespan: str = "day", start_date: str = "2000-01-01", - end_date: str = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Load historical fx data from polygon @@ -32,7 +33,7 @@ def get_historical( Window to aggregate data. start_date : str Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD Returns diff --git a/openbb_terminal/futures/yfinance_view.py b/openbb_terminal/futures/yfinance_view.py index 3a2c34782463..080e2bb07539 100644 --- a/openbb_terminal/futures/yfinance_view.py +++ b/openbb_terminal/futures/yfinance_view.py @@ -65,7 +65,7 @@ def display_search( def display_historical( symbols: List[str], expiry: str = "", - start_date: str = None, + start_date: Optional[str] = None, raw: bool = False, export: str = "", external_axes: Optional[List[plt.Axes]] = None, @@ -78,7 +78,7 @@ def display_historical( List of future timeseries symbols to display expiry: str Future expiry date with format YYYY-MM - start_date : str + start_date : Optional[str] Initial date like string (e.g., 2021-10-01) raw: bool Display futures timeseries in raw format diff --git a/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py b/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py index 72e12aee7634..7ba361a76b8a 100644 --- a/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py +++ b/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py @@ -4,7 +4,7 @@ import logging from datetime import datetime, timedelta -from typing import List, Dict +from typing import List, Dict, Optional import finnhub import pandas as pd from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer @@ -20,8 +20,8 @@ @check_api_key(["API_FINNHUB_KEY"]) def get_company_news( symbol: str, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> List[Dict]: """Get news from a company. [Source: Finnhub] @@ -29,9 +29,9 @@ def get_company_news( ---------- symbol : str company ticker to look for news articles - start_date: str + start_date: Optional[str] date to start searching articles, with format YYYY-MM-DD - end_date: str + end_date: Optional[str] date to end searching articles, with format YYYY-MM-DD Returns diff --git a/openbb_terminal/stocks/comparison_analysis/yahoo_finance_model.py b/openbb_terminal/stocks/comparison_analysis/yahoo_finance_model.py index a2af0a583094..879b212f9af0 100644 --- a/openbb_terminal/stocks/comparison_analysis/yahoo_finance_model.py +++ b/openbb_terminal/stocks/comparison_analysis/yahoo_finance_model.py @@ -3,7 +3,7 @@ import logging from datetime import datetime, timedelta -from typing import List, Tuple +from typing import List, Optional, Tuple import warnings import numpy as np @@ -30,7 +30,7 @@ @log_start_end(log=logger) def get_historical( similar: List[str], - start_date: str = None, + start_date: Optional[str] = None, candle_type: str = "a", ) -> pd.DataFrame: """Get historical prices for all comparison stocks @@ -41,7 +41,7 @@ def get_historical( List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). - start_date: str, optional + start_date: Optional[str], optional Initial date (e.g., 2021-10-01). Defaults to 1 year back candle_type: str, optional Candle variable to compare, by default "a" for Adjusted Close. Possible values are: o, h, l, c, a, v, r @@ -97,7 +97,7 @@ def get_historical( @log_start_end(log=logger) def get_correlation( similar: List[str], - start_date: str = None, + start_date: Optional[str] = None, candle_type: str = "a", ) -> Tuple[pd.DataFrame, pd.DataFrame]: """ @@ -109,7 +109,7 @@ def get_correlation( List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). - start_date : str, optional + start_date : Optional[str], optional Initial date (e.g., 2021-10-01). Defaults to 1 year back candle_type : str, optional OHLCA column to use for candles or R for returns, by default "a" for Adjusted Close @@ -133,7 +133,7 @@ def get_correlation( @log_start_end(log=logger) def get_volume( similar: List[str], - start_date: str = None, + start_date: Optional[str] = None, ) -> pd.DataFrame: """Get stock volume. [Source: Yahoo Finance] @@ -143,7 +143,7 @@ def get_volume( List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). - start_date : str, optional + start_date : Optional[str], optional Initial date (e.g., 2021-10-01). Defaults to 1 year back Returns diff --git a/openbb_terminal/stocks/comparison_analysis/yahoo_finance_view.py b/openbb_terminal/stocks/comparison_analysis/yahoo_finance_view.py index 1cf77ac452d6..d747b99cce3f 100644 --- a/openbb_terminal/stocks/comparison_analysis/yahoo_finance_view.py +++ b/openbb_terminal/stocks/comparison_analysis/yahoo_finance_view.py @@ -42,7 +42,7 @@ @log_start_end(log=logger) def display_historical( similar: List[str], - start_date: str = None, + start_date: Optional[str] = None, candle_type: str = "a", normalize: bool = True, export: str = "", @@ -56,7 +56,7 @@ def display_historical( List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). - start_date: str, optional + start_date: Optional[str], optional Initial date (e.g., 2021-10-01). Defaults to 1 year back candle_type: str, optional OHLCA column to use or R to use daily returns calculated from Adjusted Close, by default "a" for Adjusted Close @@ -106,7 +106,7 @@ def display_historical( @log_start_end(log=logger) def display_volume( similar: List[str], - start_date: str = None, + start_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ): @@ -118,7 +118,7 @@ def display_volume( List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). - start_date : str, optional + start_date : Optional[str], optional Initial date (e.g., 2021-10-01). Defaults to 1 year back export : str, optional Format to export historical prices, by default "" @@ -158,7 +158,7 @@ def display_volume( @log_start_end(log=logger) def display_correlation( similar: List[str], - start_date: str = None, + start_date: Optional[str] = None, candle_type: str = "a", display_full_matrix: bool = False, raw: bool = False, @@ -175,7 +175,7 @@ def display_correlation( List of similar tickers. Comparable companies can be accessed through finnhub_peers(), finviz_peers(), polygon_peers(). - start_date : str, optional + start_date : Optional[str], optional Initial date (e.g., 2021-10-01). Defaults to 1 year back candle_type : str, optional OHLCA column to use for candles or R for returns, by default "a" for Adjusted Close diff --git a/openbb_terminal/stocks/dark_pool_shorts/sec_model.py b/openbb_terminal/stocks/dark_pool_shorts/sec_model.py index 42f5c698b1af..9fbc4ad59f22 100644 --- a/openbb_terminal/stocks/dark_pool_shorts/sec_model.py +++ b/openbb_terminal/stocks/dark_pool_shorts/sec_model.py @@ -3,6 +3,7 @@ import logging from datetime import datetime, timedelta +from typing import Optional import pandas as pd import requests @@ -58,8 +59,8 @@ def catching_diff_url_formats(ftd_urls: list) -> list: @log_start_end(log=logger) def get_fails_to_deliver( symbol: str, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, limit: int = 0, ) -> pd.DataFrame: """Display fails-to-deliver data for a given ticker. [Source: SEC] @@ -68,9 +69,9 @@ def get_fails_to_deliver( ---------- symbol : str Stock ticker - start_date : str + start_date : Optional[str] Start of data, in YYYY-MM-DD format - end_date : str + end_date : Optional[str] End of data, in YYYY-MM-DD format limit : int Number of latest fails-to-deliver being printed diff --git a/openbb_terminal/stocks/dark_pool_shorts/sec_view.py b/openbb_terminal/stocks/dark_pool_shorts/sec_view.py index 1152b934ca10..3aff1bef570b 100644 --- a/openbb_terminal/stocks/dark_pool_shorts/sec_view.py +++ b/openbb_terminal/stocks/dark_pool_shorts/sec_view.py @@ -28,8 +28,8 @@ def fails_to_deliver( symbol: str, data: pd.DataFrame = None, - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, limit: int = 0, raw: bool = False, export: str = "", @@ -43,9 +43,9 @@ def fails_to_deliver( Stock ticker data: pd.DataFrame Stock data - start_date: str + start_date: Optional[str] Start of data, in YYYY-MM-DD format - end_date: str + end_date: Optional[str] End of data, in YYYY-MM-DD format limit : int Number of latest fails-to-deliver being printed diff --git a/openbb_terminal/stocks/discovery/finnhub_model.py b/openbb_terminal/stocks/discovery/finnhub_model.py index 7335cd346115..8f4780fe2985 100644 --- a/openbb_terminal/stocks/discovery/finnhub_model.py +++ b/openbb_terminal/stocks/discovery/finnhub_model.py @@ -15,16 +15,16 @@ @log_start_end(log=logger) @check_api_key(["API_FINNHUB_KEY"]) def get_ipo_calendar( - start_date: str = None, - end_date: str = None, + start_date: Optional[str] = None, + end_date: Optional[str] = None, ) -> pd.DataFrame: """Get IPO calendar Parameters ---------- - start_date : str + start_date : Optional[str] Initial date, format YYYY-MM-DD - end_date : str + end_date : Optional[str] Final date, format YYYY-MM-DD Returns diff --git a/openbb_terminal/stocks/due_diligence/business_insider_view.py b/openbb_terminal/stocks/due_diligence/business_insider_view.py index 373506423177..53db737a109b 100644 --- a/openbb_terminal/stocks/due_diligence/business_insider_view.py +++ b/openbb_terminal/stocks/due_diligence/business_insider_view.py @@ -31,7 +31,7 @@ def price_target_from_analysts( symbol: str, data: DataFrame, - start_date: str = None, + start_date: Optional[str] = None, limit: int = 10, raw: bool = False, export: str = "", @@ -45,7 +45,7 @@ def price_target_from_analysts( Due diligence ticker symbol data: DataFrame Due diligence stock dataframe - start_date : str + start_date : Optional[str] Start date of the stock data, format YYYY-MM-DD limit : int Number of latest price targets from analysts to print diff --git a/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_model.py b/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_model.py index bef9cf7b8696..0b7b4f052034 100644 --- a/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_model.py +++ b/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_model.py @@ -3,7 +3,7 @@ import logging from datetime import datetime, timedelta -from typing import Tuple +from typing import Optional, Tuple from urllib.request import Request, urlopen import re @@ -272,7 +272,7 @@ def get_dividends(symbol: str) -> pd.DataFrame: @log_start_end(log=logger) def get_mktcap( symbol: str, - start_date: str = None, + start_date: Optional[str] = None, ) -> Tuple[pd.DataFrame, str]: """Get market cap over time for ticker. [Source: Yahoo Finance] @@ -280,7 +280,7 @@ def get_mktcap( ---------- symbol: str Ticker to get market cap over time - start_date: str + start_date: Optional[str] Initial date (e.g., 2021-10-01). Defaults to 3 years back Returns diff --git a/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_view.py b/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_view.py index c46349a0f185..122d46d86c3a 100644 --- a/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_view.py +++ b/openbb_terminal/stocks/fundamental_analysis/yahoo_finance_view.py @@ -334,7 +334,7 @@ def display_splits( @log_start_end(log=logger) def display_mktcap( symbol: str, - start_date: str = None, + start_date: Optional[str] = None, export: str = "", external_axes: Optional[List[plt.Axes]] = None, ): @@ -344,7 +344,7 @@ def display_mktcap( ---------- symbol: str Stock ticker symbol - start_date: str + start_date: Optional[str] Initial date (e.g., 2021-10-01). Defaults to 3 years back export: str Format to export data diff --git a/openbb_terminal/stocks/insider/businessinsider_view.py b/openbb_terminal/stocks/insider/businessinsider_view.py index 7aa14bc26727..a78f6518060c 100644 --- a/openbb_terminal/stocks/insider/businessinsider_view.py +++ b/openbb_terminal/stocks/insider/businessinsider_view.py @@ -32,7 +32,7 @@ def insider_activity( data: pd.DataFrame, symbol: str, - start_date: str = None, + start_date: Optional[str] = None, interval: str = "1440min", limit: int = 10, raw: bool = False, @@ -47,7 +47,7 @@ def insider_activity( Stock dataframe symbol: str Due diligence ticker symbol - start_date: str + start_date: Optional[str] Initial date (e.g., 2021-10-01). Defaults to 3 years back interval: str Stock data interval diff --git a/openbb_terminal/stocks/options/alphaquery_model.py b/openbb_terminal/stocks/options/alphaquery_model.py index 8f3807b09a05..96482be36ce4 100644 --- a/openbb_terminal/stocks/options/alphaquery_model.py +++ b/openbb_terminal/stocks/options/alphaquery_model.py @@ -3,6 +3,7 @@ import logging from datetime import datetime, timedelta +from typing import Optional import pandas as pd import requests @@ -16,7 +17,7 @@ def get_put_call_ratio( symbol: str, window: int = 30, - start_date: str = None, + start_date: Optional[str] = None, ) -> pd.DataFrame: """Gets put call ratio over last time window [Source: AlphaQuery.com] @@ -26,7 +27,7 @@ def get_put_call_ratio( Ticker symbol to look for window: int, optional Window to consider, by default 30 - start_date: str, optional + start_date: Optional[str], optional Start date to plot (e.g., 2021-10-01), by default last 366 days Returns From dba394be2f1f7e16b8c3a1f57a9bb4993f9c1fbd Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 22 Nov 2022 13:38:00 +0000 Subject: [PATCH 3/4] mypy --- openbb_terminal/economy/econdb_model.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/openbb_terminal/economy/econdb_model.py b/openbb_terminal/economy/econdb_model.py index 522c2cbb2f17..1405eca12b12 100644 --- a/openbb_terminal/economy/econdb_model.py +++ b/openbb_terminal/economy/econdb_model.py @@ -483,7 +483,7 @@ def get_macro_data( parameter: str, country: str, transform: str = "", - start_date: Optional[str] = None, + start_date: str = "1900-01-01", end_date: Optional[str] = None, symbol: str = "", ) -> Tuple[pd.Series, Union[str, Any]]: @@ -503,7 +503,7 @@ def get_macro_data( 'TUSD' - level USD, 'TPGP' - Percentage of GDP, 'TNOR' - Start = 100 - start_date : Optional[str] + start_date : str The starting date, format "YEAR-MONTH-DAY", i.e. 2010-12-31. end_date : Optional[str] The end date, format "YEAR-MONTH-DAY", i.e. 2020-06-05. @@ -517,11 +517,8 @@ def get_macro_data( The units of the macro data, e.g. 'Bbl/day" for oil. """ - if start_date is None: - start_date = pd.to_datetime("1900-01-01") - if end_date is None: - end_date = datetime.today().date() + end_date = datetime.today().strftime("%Y-%m-%d") df, units = pd.DataFrame(), "" country = country.replace("_", " ") From af2943c8651500f886f59d46a3f925ddb4b7c79c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 22 Nov 2022 14:44:51 +0000 Subject: [PATCH 4/4] mypy again --- openbb_terminal/economy/econdb_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openbb_terminal/economy/econdb_model.py b/openbb_terminal/economy/econdb_model.py index 1405eca12b12..c58eaffbbf5c 100644 --- a/openbb_terminal/economy/econdb_model.py +++ b/openbb_terminal/economy/econdb_model.py @@ -569,7 +569,9 @@ def get_macro_data( if start_date or end_date: try: - df = df.loc[start_date:end_date] + dt_start = pd.to_datetime(start_date) + dt_end = pd.to_datetime(end_date) + df = df.loc[dt_start:dt_end] except TypeError: console.print("[red]Invalid date sent. Format as YYYY-MM-DD[/red]\n") return pd.DataFrame(), "NA/NA"