mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 13:32:08 +00:00
Merge branch 'feature/plotly-react' of https://github.com/tehcoderer/OpenBBTerminal into feature/plotly-react
This commit is contained in:
@@ -27,6 +27,7 @@ class StocksController(model.StocksRoot):
|
||||
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
|
||||
`process_candle`: Process DataFrame into candle style plot.\n
|
||||
`quote`: Gets ticker quote from FMP\n
|
||||
`quote_chart`: Financial Modeling Prep ticker(s) quote.\n
|
||||
`search`: Search selected query for tickers.\n
|
||||
`tob`: Get top of book bid and ask for ticker on exchange [CBOE.com]\n
|
||||
"""
|
||||
|
||||
@@ -14,6 +14,7 @@ class StocksRoot(Category):
|
||||
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
|
||||
`process_candle`: Process DataFrame into candle style plot.\n
|
||||
`quote`: Gets ticker quote from FMP\n
|
||||
`quote_chart`: Financial Modeling Prep ticker(s) quote.\n
|
||||
`search`: Search selected query for tickers.\n
|
||||
`tob`: Get top of book bid and ask for ticker on exchange [CBOE.com]\n
|
||||
"""
|
||||
@@ -27,6 +28,7 @@ class StocksRoot(Category):
|
||||
self.news = lib.common_ultima_newsmonitor_model.get_news
|
||||
self.process_candle = lib.stocks_helper.process_candle
|
||||
self.quote = lib.stocks_model.get_quote
|
||||
self.quote_chart = lib.stocks_view.display_quote
|
||||
self.search = lib.stocks_helper.search
|
||||
self.tob = lib.stocks_cboe_model.get_top_of_book
|
||||
|
||||
|
||||
@@ -147,9 +147,7 @@ class Category:
|
||||
|
||||
def __getattribute__(self, name: str):
|
||||
"""We override the __getattribute__ method and wrap all callable
|
||||
|
||||
attributes with a wrapper that logs the call and the result.
|
||||
|
||||
"""
|
||||
|
||||
attr = super().__getattribute__(name)
|
||||
@@ -258,39 +256,21 @@ class OperationLogger:
|
||||
@staticmethod
|
||||
def __merge_function_args(func: Callable, args: tuple, kwargs: dict) -> dict:
|
||||
"""
|
||||
|
||||
Merge user input args and kwargs with signature defaults into a dictionary.
|
||||
|
||||
|
||||
|
||||
Parameters
|
||||
|
||||
----------
|
||||
|
||||
|
||||
|
||||
func : Callable
|
||||
|
||||
Function to get the args from
|
||||
|
||||
args : tuple
|
||||
|
||||
Positional args
|
||||
|
||||
kwargs : dict
|
||||
|
||||
Keyword args
|
||||
|
||||
|
||||
|
||||
Returns
|
||||
|
||||
----------
|
||||
|
||||
-------
|
||||
dict
|
||||
|
||||
Merged user args and signature defaults
|
||||
|
||||
"""
|
||||
|
||||
import inspect # pylint: disable=C0415
|
||||
@@ -316,33 +296,19 @@ class OperationLogger:
|
||||
@staticmethod
|
||||
def __remove_key_and_log_state(func_module: str, function_args: dict) -> dict:
|
||||
"""
|
||||
|
||||
Remove API key from the function args and log state of keys.
|
||||
|
||||
|
||||
|
||||
Parameters
|
||||
|
||||
----------
|
||||
|
||||
func_module : str
|
||||
|
||||
Module of the function
|
||||
|
||||
function_args : dict
|
||||
|
||||
Function args
|
||||
|
||||
|
||||
|
||||
Returns
|
||||
|
||||
----------
|
||||
|
||||
-------
|
||||
dict
|
||||
|
||||
Function args with API key removed
|
||||
|
||||
"""
|
||||
|
||||
if func_module == "openbb_terminal.keys_model":
|
||||
@@ -435,16 +401,12 @@ def get_sdk_imports_text() -> str:
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
import openbb_terminal.config_terminal as cfg
|
||||
|
||||
from openbb_terminal import helper_funcs as helper # noqa: F401
|
||||
|
||||
from openbb_terminal.core.plots.plotly_helper import theme # noqa: F401
|
||||
|
||||
|
||||
|
||||
from openbb_terminal.cryptocurrency.due_diligence.pycoingecko_model import Coin
|
||||
|
||||
from openbb_terminal.dashboards.dashboards_controller import DashboardsController
|
||||
@@ -455,16 +417,12 @@ from openbb_terminal.reports import widget_helpers as widgets # noqa: F401
|
||||
|
||||
from openbb_terminal.reports.reports_controller import ReportController
|
||||
|
||||
|
||||
|
||||
import openbb_terminal.core.sdk.sdk_init as lib
|
||||
|
||||
from openbb_terminal.core.sdk import (
|
||||
|
||||
controllers as ctrl,
|
||||
|
||||
models as model,
|
||||
|
||||
)
|
||||
|
||||
from openbb_terminal.core.session.current_system import get_current_system
|
||||
@@ -473,12 +431,8 @@ from openbb_terminal.core.session.current_user import is_local
|
||||
|
||||
from openbb_terminal.terminal_helper import is_auth_enabled
|
||||
|
||||
|
||||
|
||||
cfg.setup_config_terminal(is_sdk=True)
|
||||
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
cfg.theme.applyMPLstyle()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
# noqa: F401
|
||||
|
||||
|
||||
# Session
|
||||
|
||||
from openbb_terminal.core.session import sdk_session
|
||||
@@ -581,7 +580,6 @@ except ImportError:
|
||||
|
||||
from openbb_terminal.portfolio import portfolio_model, portfolio_view
|
||||
|
||||
|
||||
try:
|
||||
# pylint: disable=W0611 # noqa: F401 # pyright: reportMissingImports=false
|
||||
|
||||
|
||||
2
openbb_terminal/core/sdk/trail_map.csv
vendored
2
openbb_terminal/core/sdk/trail_map.csv
vendored
@@ -526,7 +526,7 @@ stocks.qa.beta,stocks_qa_beta_model.beta_model,stocks_qa_beta_view.beta_view
|
||||
stocks.qa.capm,stocks_qa_factors_model.capm_information,
|
||||
stocks.qa.fama_raw,stocks_qa_factors_model.get_fama_raw,
|
||||
stocks.qa.historical_5,stocks_qa_factors_model.get_historical_5,
|
||||
stocks.quote,stocks_model.get_quote,
|
||||
stocks.quote,stocks_model.get_quote,stocks_view.display_quote
|
||||
stocks.screener.screener_data,stocks_screener_finviz_model.get_screener_data,stocks_screener_finviz_view.screener
|
||||
stocks.search,stocks_helper.search,
|
||||
stocks.ta.recom,stocks_ta_tradingview_model.get_tradingview_recommendation,stocks_ta_tradingview_view.print_recommendation
|
||||
|
||||
|
@@ -3,6 +3,7 @@ search -c United States -s Consumer Cyclical -i Specialty Retail -e USA -l 5
|
||||
load ${ticker=aapl} -i 5
|
||||
load ${ticker=aapl} -s 2022-10-01
|
||||
quote
|
||||
quote --ticker AAPL,MSFT,GOOG,META,AMZN,NFLX
|
||||
tob
|
||||
tob -e EDGX
|
||||
candle
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"quote_data = openbb.stocks.quote(symbol)\n",
|
||||
"quote_data = openbb.stocks.quote([symbol])\n",
|
||||
"quote_data"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ class OpenBBSDK:
|
||||
Attributes:
|
||||
`login`: Login and load user info.\n
|
||||
`logout`: Logout and clear session.\n
|
||||
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
|
||||
`news`: Get news for a given term and source. [Source: Feedparser]\n
|
||||
`whoami`: Display user info.\n
|
||||
"""
|
||||
|
||||
@@ -518,6 +518,7 @@ class OpenBBSDK:
|
||||
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
|
||||
`process_candle`: Process DataFrame into candle style plot.\n
|
||||
`quote`: Gets ticker quote from FMP\n
|
||||
`quote_chart`: Financial Modeling Prep ticker(s) quote.\n
|
||||
`search`: Search selected query for tickers.\n
|
||||
`tob`: Get top of book bid and ask for ticker on exchange [CBOE.com]\n
|
||||
"""
|
||||
|
||||
@@ -332,6 +332,7 @@ class StocksController(StockBaseController):
|
||||
action="store",
|
||||
dest="s_ticker",
|
||||
required=False,
|
||||
default=self.ticker,
|
||||
help=translate("stocks/QUOTE_ticker"),
|
||||
)
|
||||
|
||||
@@ -342,12 +343,13 @@ class StocksController(StockBaseController):
|
||||
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
|
||||
)
|
||||
if ns_parser:
|
||||
if ns_parser.s_ticker:
|
||||
tickers = ns_parser.s_ticker.split(",")
|
||||
if ns_parser.s_ticker and len(tickers) == 1:
|
||||
self.ticker = ns_parser.s_ticker
|
||||
self.custom_load_wrapper([self.ticker])
|
||||
|
||||
stocks_view.display_quote(
|
||||
self.ticker,
|
||||
tickers,
|
||||
ns_parser.export,
|
||||
" ".join(ns_parser.sheet_name) if ns_parser.sheet_name else None,
|
||||
)
|
||||
|
||||
@@ -286,20 +286,33 @@ def load_stock_polygon(
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_FINANCIALMODELINGPREP"])
|
||||
def get_quote(symbol: str) -> pd.DataFrame:
|
||||
def get_quote(symbols: list[str]) -> pd.DataFrame:
|
||||
"""Gets ticker quote from FMP
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbol : str
|
||||
Stock ticker symbol
|
||||
symbols : List[str]
|
||||
A list of Stock ticker symbols
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe of ticker quote
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
A single ticker must be entered as a list.
|
||||
|
||||
>>> df = openbb.stocks.quote(["AAPL"])
|
||||
|
||||
Multiple tickers can be retrieved.
|
||||
|
||||
>>> df = openbb.stocks.quote(["AAPL","MSFT","GOOG","NFLX","META","AMZN","NVDA"])
|
||||
"""
|
||||
|
||||
symbol = symbols if isinstance(symbols, list) is False else ",".join(symbols)
|
||||
|
||||
df_fa = pd.DataFrame()
|
||||
|
||||
try:
|
||||
@@ -315,25 +328,30 @@ def get_quote(symbol: str) -> pd.DataFrame:
|
||||
|
||||
if not df_fa.empty:
|
||||
clean_df_index(df_fa)
|
||||
df_fa.loc["Market cap"][0] = lambda_long_number_format(
|
||||
df_fa.loc["Market cap"][0]
|
||||
)
|
||||
df_fa.loc["Shares outstanding"][0] = lambda_long_number_format(
|
||||
df_fa.loc["Shares outstanding"][0]
|
||||
)
|
||||
df_fa.loc["Volume"][0] = lambda_long_number_format(df_fa.loc["Volume"][0])
|
||||
# Check if there is a valid earnings announcement
|
||||
if df_fa.loc["Earnings announcement"][0]:
|
||||
earning_announcement = datetime.strptime(
|
||||
df_fa.loc["Earnings announcement"][0][0:19], "%Y-%m-%dT%H:%M:%S"
|
||||
for c in df_fa.columns:
|
||||
df_fa.loc["Market cap"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Market cap"][c]
|
||||
)
|
||||
df_fa.loc["Earnings announcement"][
|
||||
0
|
||||
] = f"{earning_announcement.date()} {earning_announcement.time()}"
|
||||
# Check if there is a valid timestamp and convert it to a readable format
|
||||
if "Timestamp" in df_fa.index and df_fa.loc["Timestamp"][0]:
|
||||
df_fa.loc["Timestamp"][0] = datetime.fromtimestamp(
|
||||
df_fa.loc["Timestamp"][0]
|
||||
).strftime("%Y-%m-%d %H:%M:%S")
|
||||
df_fa.loc["Shares outstanding"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Shares outstanding"][c]
|
||||
)
|
||||
df_fa.loc["Volume"][c] = lambda_long_number_format(df_fa.loc["Volume"][c])
|
||||
# Check if there is a valid earnings announcement
|
||||
if df_fa.loc["Earnings announcement"][c]:
|
||||
earning_announcement = datetime.strptime(
|
||||
df_fa.loc["Earnings announcement"][c][0:19], "%Y-%m-%dT%H:%M:%S"
|
||||
)
|
||||
df_fa.loc["Earnings announcement"][
|
||||
c
|
||||
] = f"{earning_announcement.date()} {earning_announcement.time()}"
|
||||
# Check if there is a valid timestamp and convert it to a readable format
|
||||
if "Timestamp" in df_fa.index and df_fa.loc["Timestamp"][c]:
|
||||
df_fa.loc["Timestamp"][c] = datetime.fromtimestamp(
|
||||
df_fa.loc["Timestamp"][c]
|
||||
).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
df_fa.columns = df_fa.loc["Symbol"][:]
|
||||
df_fa = df_fa.drop("Symbol", axis=0)
|
||||
df_fa.index = df_fa.index.str.title()
|
||||
|
||||
return df_fa
|
||||
|
||||
@@ -12,27 +12,40 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_FINANCIALMODELINGPREP"])
|
||||
def display_quote(symbol: str, export: str = "", sheet_name: Optional[str] = None):
|
||||
"""Financial Modeling Prep ticker quote
|
||||
def display_quote(
|
||||
symbols: list[str], export: str = "", sheet_name: Optional[str] = None
|
||||
):
|
||||
"""Financial Modeling Prep ticker(s) quote.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbol : str
|
||||
Fundamental analysis ticker symbol
|
||||
symbols : list[str]
|
||||
A list of ticker symbols.
|
||||
sheet_name: str
|
||||
Optionally specify the name of the sheet the data is exported to.
|
||||
export: str
|
||||
Format to export data
|
||||
|
||||
Examples
|
||||
--------
|
||||
This end point displays the results as an interactive table.
|
||||
|
||||
>>> from openbb_terminal.sdk import openbb
|
||||
>>> openbb.stocks.quote_chart(["MSFT"])
|
||||
|
||||
Multiple tickers are retrieved at once using a comma-separated list.
|
||||
|
||||
>>> openbb.stocks.quote_chart(["MSFT","AAPL"])
|
||||
"""
|
||||
|
||||
quote = stocks_model.get_quote(symbol)
|
||||
quote = stocks_model.get_quote(symbols)
|
||||
if quote.empty:
|
||||
console.print("[red]Data not found[/red]\n")
|
||||
return
|
||||
print_rich_table(
|
||||
quote,
|
||||
headers=["Value"],
|
||||
title=f"{symbol.upper()} Quote",
|
||||
headers=quote.columns,
|
||||
title="Quote",
|
||||
index_name="Info",
|
||||
show_index=True,
|
||||
export=bool(export),
|
||||
|
||||
90
tests/openbb_terminal/stocks/cassettes/test_stocks_helper/test_multi_quote.yaml
vendored
Normal file
90
tests/openbb_terminal/stocks/cassettes/test_stocks_helper/test_multi_quote.yaml
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Connection:
|
||||
- close
|
||||
Host:
|
||||
- financialmodelingprep.com
|
||||
User-Agent:
|
||||
- Python-urllib/3.10
|
||||
method: GET
|
||||
uri: https://financialmodelingprep.com/api/v3/quote/AAPL,MSFT,AMZN,TSLA,BTCUSD?apikey=MOCK_API_KEY
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"symbol\": \"AAPL\",\n \"name\": \"Apple Inc.\",\n
|
||||
\ \"price\": 169.59,\n \"changesPercentage\": -0.053,\n \"change\":
|
||||
-0.09,\n \"dayLow\": 168.64,\n \"dayHigh\": 170.45,\n \"yearHigh\":
|
||||
176.15,\n \"yearLow\": 124.17,\n \"marketCap\": 2683235983012,\n \"priceAvg50\":
|
||||
157.903,\n \"priceAvg200\": 150.89626,\n \"exchange\": \"NASDAQ\",\n
|
||||
\ \"volume\": 47584395,\n \"avgVolume\": 61989696,\n \"open\": 169.28,\n
|
||||
\ \"previousClose\": 169.68,\n \"eps\": 5.89,\n \"pe\": 28.79,\n \"earningsAnnouncement\":
|
||||
\"2023-05-04T20:00:00.000+0000\",\n \"sharesOutstanding\": 15821899776,\n
|
||||
\ \"timestamp\": 1682971204\n },\n {\n \"symbol\": \"MSFT\",\n \"name\":
|
||||
\"Microsoft Corporation\",\n \"price\": 305.56,\n \"changesPercentage\":
|
||||
-0.5533,\n \"change\": -1.7,\n \"dayLow\": 305.15,\n \"dayHigh\":
|
||||
308.6,\n \"yearHigh\": 308.93,\n \"yearLow\": 213.43,\n \"marketCap\":
|
||||
2271988260844,\n \"priceAvg50\": 272.9444,\n \"priceAvg200\": 256.1089,\n
|
||||
\ \"exchange\": \"NASDAQ\",\n \"volume\": 20749354,\n \"avgVolume\":
|
||||
31388708,\n \"open\": 306.97,\n \"previousClose\": 307.26,\n \"eps\":
|
||||
9.22,\n \"pe\": 33.14,\n \"earningsAnnouncement\": \"2023-07-24T10:59:00.000+0000\",\n
|
||||
\ \"sharesOutstanding\": 7435489792,\n \"timestamp\": 1682971204\n },\n
|
||||
\ {\n \"symbol\": \"AMZN\",\n \"name\": \"Amazon.com, Inc.\",\n \"price\":
|
||||
102.05,\n \"changesPercentage\": -3.2243,\n \"change\": -3.4,\n \"dayLow\":
|
||||
101.82,\n \"dayHigh\": 105.23,\n \"yearHigh\": 146.57,\n \"yearLow\":
|
||||
81.43,\n \"marketCap\": 1046828886938,\n \"priceAvg50\": 98.942,\n \"priceAvg200\":
|
||||
106.82795,\n \"exchange\": \"NASDAQ\",\n \"volume\": 71685223,\n \"avgVolume\":
|
||||
64279718,\n \"open\": 104.95,\n \"previousClose\": 105.45,\n \"eps\":
|
||||
-0.26,\n \"pe\": -392.5,\n \"earningsAnnouncement\": \"2023-07-26T10:59:00.000+0000\",\n
|
||||
\ \"sharesOutstanding\": 10257999872,\n \"timestamp\": 1682971204\n },\n
|
||||
\ {\n \"symbol\": \"TSLA\",\n \"name\": \"Tesla, Inc.\",\n \"price\":
|
||||
161.83,\n \"changesPercentage\": -1.5093,\n \"change\": -2.48,\n \"dayLow\":
|
||||
158.83,\n \"dayHigh\": 163.27,\n \"yearHigh\": 318.5,\n \"yearLow\":
|
||||
101.81,\n \"marketCap\": 512920169464,\n \"priceAvg50\": 186.3808,\n
|
||||
\ \"priceAvg200\": 210.43953,\n \"exchange\": \"NASDAQ\",\n \"volume\":
|
||||
108089884,\n \"avgVolume\": 153783115,\n \"open\": 163.17,\n \"previousClose\":
|
||||
164.31,\n \"eps\": 3.48,\n \"pe\": 46.5,\n \"earningsAnnouncement\":
|
||||
\"2023-07-18T20:00:00.000+0000\",\n \"sharesOutstanding\": 3169499904,\n
|
||||
\ \"timestamp\": 1682971204\n },\n {\n \"symbol\": \"BTCUSD\",\n \"name\":
|
||||
\"Bitcoin USD\",\n \"price\": 28009.943,\n \"changesPercentage\": -4.6604,\n
|
||||
\ \"change\": -1369.1914,\n \"dayLow\": 27680.793,\n \"dayHigh\":
|
||||
29325.674,\n \"yearHigh\": 39902.95,\n \"yearLow\": 15599.047,\n \"marketCap\":
|
||||
542320281443,\n \"priceAvg50\": 28050.547,\n \"priceAvg200\": 21765.43,\n
|
||||
\ \"exchange\": \"CRYPTO\",\n \"volume\": 18651375616,\n \"avgVolume\":
|
||||
23774151613,\n \"open\": 29248.242,\n \"previousClose\": 29248.242,\n
|
||||
\ \"eps\": null,\n \"pe\": null,\n \"earningsAnnouncement\": null,\n
|
||||
\ \"sharesOutstanding\": 19361706,\n \"timestamp\": 1682981820\n }\n]"
|
||||
headers:
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Headers:
|
||||
- X-Requested-With, content-type, auth-token, Authorization, stripe-signature,
|
||||
APPS
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, OPTIONS
|
||||
Access-Control-Allow-Origin:
|
||||
- '*'
|
||||
Access-Control-Max-Age:
|
||||
- '3600'
|
||||
Connection:
|
||||
- close
|
||||
Content-Length:
|
||||
- '3018'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Mon, 01 May 2023 22:58:54 GMT
|
||||
ETag:
|
||||
- W/"bca-t18O6Ptklma9u9zVacTGRlZOKjg"
|
||||
Server:
|
||||
- nginx/1.14.0 (Ubuntu)
|
||||
Vary:
|
||||
- Accept-Encoding
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Powered-By:
|
||||
- Express
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -13,14 +13,14 @@ interactions:
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"symbol\": \"GME\",\n \"name\": \"GameStop Corp.\",\n
|
||||
\ \"price\": 18.06,\n \"changesPercentage\": -3.1635,\n \"change\":
|
||||
-0.59,\n \"dayLow\": 18.06,\n \"dayHigh\": 18.835,\n \"yearHigh\":
|
||||
49.8525,\n \"yearLow\": 15.41,\n \"marketCap\": 5500678391,\n \"priceAvg50\":
|
||||
19.9016,\n \"priceAvg200\": 27.140675,\n \"exchange\": \"NYSE\",\n \"volume\":
|
||||
2366114,\n \"avgVolume\": 4727827,\n \"open\": 18.54,\n \"previousClose\":
|
||||
18.65,\n \"eps\": -1.64,\n \"pe\": -11.01,\n \"earningsAnnouncement\":
|
||||
\"2023-03-15T10:59:00.000+0000\",\n \"sharesOutstanding\": 304577984,\n
|
||||
\ \"timestamp\": 1678222802\n }\n]"
|
||||
\ \"price\": 18.55,\n \"changesPercentage\": -3.8362,\n \"change\":
|
||||
-0.74,\n \"dayLow\": 18.46,\n \"dayHigh\": 19.25,\n \"yearHigh\":
|
||||
47.99,\n \"yearLow\": 15.41,\n \"marketCap\": 5651721398,\n \"priceAvg50\":
|
||||
20.2712,\n \"priceAvg200\": 25.07525,\n \"exchange\": \"NYSE\",\n \"volume\":
|
||||
2337859,\n \"avgVolume\": 4985721,\n \"open\": 19.16,\n \"previousClose\":
|
||||
19.29,\n \"eps\": -1.05,\n \"pe\": -17.67,\n \"earningsAnnouncement\":
|
||||
\"2023-05-30T10:59:00.000+0000\",\n \"sharesOutstanding\": 304675008,\n
|
||||
\ \"timestamp\": 1682971202\n }\n]"
|
||||
headers:
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
@@ -36,13 +36,13 @@ interactions:
|
||||
Connection:
|
||||
- close
|
||||
Content-Length:
|
||||
- '594'
|
||||
- '590'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Wed, 08 Mar 2023 14:01:23 GMT
|
||||
- Mon, 01 May 2023 22:58:54 GMT
|
||||
ETag:
|
||||
- W/"252-3YV8k360rN54CWWpVAM/bjKtIxg"
|
||||
- W/"24e-XRtJPSt+45Q/tN8/AO8qQev8aT8"
|
||||
Server:
|
||||
- nginx/1.14.0 (Ubuntu)
|
||||
Vary:
|
||||
|
||||
74
tests/openbb_terminal/stocks/cassettes/test_stocks_helper/test_quote_bad_ticker.yaml
vendored
Normal file
74
tests/openbb_terminal/stocks/cassettes/test_stocks_helper/test_quote_bad_ticker.yaml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Connection:
|
||||
- close
|
||||
Host:
|
||||
- financialmodelingprep.com
|
||||
User-Agent:
|
||||
- Python-urllib/3.10
|
||||
method: GET
|
||||
uri: https://financialmodelingprep.com/api/v3/quote/F,GM,RIVN,VW,69420?apikey=MOCK_API_KEY
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"symbol\": \"F\",\n \"name\": \"Ford Motor Company\",\n
|
||||
\ \"price\": 12.06,\n \"changesPercentage\": 1.5152,\n \"change\":
|
||||
0.18,\n \"dayLow\": 11.99,\n \"dayHigh\": 12.29,\n \"yearHigh\":
|
||||
16.68,\n \"yearLow\": 10.61,\n \"marketCap\": 47218880379,\n \"priceAvg50\":
|
||||
12.1882,\n \"priceAvg200\": 13.11915,\n \"exchange\": \"NYSE\",\n \"volume\":
|
||||
55959087,\n \"avgVolume\": 69625791,\n \"open\": 12.005,\n \"previousClose\":
|
||||
11.88,\n \"eps\": -0.49,\n \"pe\": -24.61,\n \"earningsAnnouncement\":
|
||||
\"2023-05-02T20:05:00.000+0000\",\n \"sharesOutstanding\": 3915330048,\n
|
||||
\ \"timestamp\": 1682971388\n },\n {\n \"symbol\": \"GM\",\n \"name\":
|
||||
\"General Motors Company\",\n \"price\": 33.48,\n \"changesPercentage\":
|
||||
1.3317,\n \"change\": 0.44,\n \"dayLow\": 33.435,\n \"dayHigh\":
|
||||
34.2796,\n \"yearHigh\": 43.63,\n \"yearLow\": 30.33,\n \"marketCap\":
|
||||
46541215457,\n \"priceAvg50\": 36.261,\n \"priceAvg200\": 37.10095,\n
|
||||
\ \"exchange\": \"NYSE\",\n \"volume\": 16839357,\n \"avgVolume\":
|
||||
14667721,\n \"open\": 34,\n \"previousClose\": 33.04,\n \"eps\":
|
||||
6.53,\n \"pe\": 5.13,\n \"earningsAnnouncement\": \"2023-07-25T12:30:00.000+0000\",\n
|
||||
\ \"sharesOutstanding\": 1390119936,\n \"timestamp\": 1682971202\n },\n
|
||||
\ {\n \"symbol\": \"RIVN\",\n \"name\": \"Rivian Automotive, Inc.\",\n
|
||||
\ \"price\": 12.65,\n \"changesPercentage\": -1.3261,\n \"change\":
|
||||
-0.17,\n \"dayLow\": 12.37,\n \"dayHigh\": 12.83,\n \"yearHigh\":
|
||||
40.86,\n \"yearLow\": 11.68,\n \"marketCap\": 11628702554,\n \"priceAvg50\":
|
||||
14.7598,\n \"priceAvg200\": 25.518675,\n \"exchange\": \"NASDAQ\",\n
|
||||
\ \"volume\": 12487673,\n \"avgVolume\": 29025515,\n \"open\": 12.805,\n
|
||||
\ \"previousClose\": 12.82,\n \"eps\": -7.49,\n \"pe\": -1.69,\n \"earningsAnnouncement\":
|
||||
\"2023-05-09T20:00:00.000+0000\",\n \"sharesOutstanding\": 919265024,\n
|
||||
\ \"timestamp\": 1682971204\n }\n]"
|
||||
headers:
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
Access-Control-Allow-Headers:
|
||||
- X-Requested-With, content-type, auth-token, Authorization, stripe-signature,
|
||||
APPS
|
||||
Access-Control-Allow-Methods:
|
||||
- GET, POST, OPTIONS
|
||||
Access-Control-Allow-Origin:
|
||||
- '*'
|
||||
Access-Control-Max-Age:
|
||||
- '3600'
|
||||
Connection:
|
||||
- close
|
||||
Content-Length:
|
||||
- '1792'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Mon, 01 May 2023 22:58:55 GMT
|
||||
ETag:
|
||||
- W/"700-IpaNmdmCYQhRNNWUZgdju/Q/0zE"
|
||||
Server:
|
||||
- nginx/1.14.0 (Ubuntu)
|
||||
Vary:
|
||||
- Accept-Encoding
|
||||
X-Frame-Options:
|
||||
- SAMEORIGIN
|
||||
X-Powered-By:
|
||||
- Express
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -1,15 +1,15 @@
|
||||
date,Open,High,Low,Close,Adj Close,Volume
|
||||
2021-12-01 09:30:00,199.39999389648438,200.10499572753906,194.8800048828125,195.67999267578125,195.67999267578125,290211
|
||||
2021-12-01 10:30:00,195.47000122070312,196.2899932861328,192.27999877929688,193.30149841308594,193.30149841308594,171312
|
||||
2021-12-01 11:30:00,193.4499969482422,193.4499969482422,190.6199951171875,190.77499389648438,190.77499389648438,116741
|
||||
2021-12-01 12:30:00,190.64999389648438,191.08999633789062,184.0,188.35000610351562,188.35000610351562,387586
|
||||
2021-12-01 13:30:00,188.3699951171875,189.0,182.3000030517578,185.83999633789062,185.83999633789062,327882
|
||||
2021-12-01 14:30:00,185.5399932861328,186.27999877929688,177.00999450683594,179.80499267578125,179.80499267578125,535512
|
||||
2021-12-01 15:30:00,179.8000030517578,183.22000122070312,178.16000366210938,179.7100067138672,179.7100067138672,471727
|
||||
2021-12-02 09:30:00,185.0,187.42999267578125,177.50010681152344,178.1199951171875,178.1199951171875,667373
|
||||
2021-12-02 10:30:00,178.1199951171875,182.5,173.07000732421875,181.5399932861328,181.5399932861328,497901
|
||||
2021-12-02 11:30:00,181.6199951171875,184.99899291992188,179.89999389648438,183.55999755859375,183.55999755859375,213772
|
||||
2021-12-02 12:30:00,184.14480590820312,184.91000366210938,179.00999450683594,179.21299743652344,179.21299743652344,223252
|
||||
2021-12-02 13:30:00,179.1300048828125,181.42269897460938,177.94000244140625,181.22000122070312,181.22000122070312,155763
|
||||
2021-12-02 14:30:00,181.33999633789062,183.35989379882812,180.25,180.92999267578125,180.92999267578125,132262
|
||||
2021-12-02 15:30:00,180.9499969482422,181.86000061035156,180.24000549316406,181.7100067138672,181.7100067138672,162508
|
||||
date,Open,High,Low,Close,Adj Close,Volume
|
||||
2021-12-01 09:30:00,199.39999389648438,200.10499572753906,194.8800048828125,195.67999267578125,195.67999267578125,290211
|
||||
2021-12-01 10:30:00,195.47000122070312,196.2899932861328,192.27999877929688,193.30149841308594,193.30149841308594,171312
|
||||
2021-12-01 11:30:00,193.4499969482422,193.4499969482422,190.6199951171875,190.77499389648438,190.77499389648438,116741
|
||||
2021-12-01 12:30:00,190.64999389648438,191.08999633789062,184.0,188.35000610351562,188.35000610351562,387586
|
||||
2021-12-01 13:30:00,188.3699951171875,189.0,182.3000030517578,185.83999633789062,185.83999633789062,327882
|
||||
2021-12-01 14:30:00,185.5399932861328,186.27999877929688,177.00999450683594,179.80499267578125,179.80499267578125,535512
|
||||
2021-12-01 15:30:00,179.8000030517578,183.22000122070312,178.16000366210938,179.7100067138672,179.7100067138672,471727
|
||||
2021-12-02 09:30:00,185.0,187.42999267578125,177.50010681152344,178.1199951171875,178.1199951171875,667373
|
||||
2021-12-02 10:30:00,178.1199951171875,182.5,173.07000732421875,181.5399932861328,181.5399932861328,497901
|
||||
2021-12-02 11:30:00,181.6199951171875,184.99899291992188,179.89999389648438,183.55999755859375,183.55999755859375,213772
|
||||
2021-12-02 12:30:00,184.14480590820312,184.91000366210938,179.00999450683594,179.21299743652344,179.21299743652344,223252
|
||||
2021-12-02 13:30:00,179.1300048828125,181.42269897460938,177.94000244140625,181.22000122070312,181.22000122070312,155763
|
||||
2021-12-02 14:30:00,181.33999633789062,183.35989379882812,180.25,180.92999267578125,180.92999267578125,132262
|
||||
2021-12-02 15:30:00,180.9499969482422,181.86000061035156,180.24000549316406,181.7100067138672,181.7100067138672,162508
|
||||
|
||||
|
@@ -30,7 +30,17 @@ def vcr_config():
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_quote():
|
||||
stocks_view.display_quote("GME")
|
||||
stocks_view.display_quote(["GME"])
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_multi_quote() -> None:
|
||||
stocks_view.display_quote(["AAPL", "MSFT", "AMZN", "TSLA", "BTCUSD"])
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_quote_bad_ticker() -> None:
|
||||
stocks_view.display_quote(["F", "GM", "RIVN", "VW", "69420"])
|
||||
|
||||
|
||||
@pytest.mark.default_cassette("test_search")
|
||||
|
||||
22
tests/openbb_terminal/stocks/txt/test_stocks_helper/test_multi_quote.txt
vendored
Normal file
22
tests/openbb_terminal/stocks/txt/test_stocks_helper/test_multi_quote.txt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Symbol AAPL MSFT AMZN TSLA BTCUSD
|
||||
Name Apple Inc. Microsoft Corporation Amazon.com, Inc. Tesla, Inc. Bitcoin USD
|
||||
Price 169.59 305.56 102.05 161.83 28009.943
|
||||
Changes Percentage -0.053 -0.5533 -3.2243 -1.5093 -4.6604
|
||||
Change -0.09 -1.7 -3.4 -2.48 -1369.1914
|
||||
Day Low 168.64 305.15 101.82 158.83 27680.793
|
||||
Day High 170.45 308.6 105.23 163.27 29325.674
|
||||
Year High 176.15 308.93 146.57 318.5 39902.95
|
||||
Year Low 124.17 213.43 81.43 101.81 15599.047
|
||||
Market Cap 2.683 T 2.272 T 1.047 T 512.920 B 542.320 B
|
||||
Price Avg50 157.903 272.9444 98.942 186.3808 28050.547
|
||||
Price Avg200 150.89626 256.1089 106.82795 210.43953 21765.43
|
||||
Exchange NASDAQ NASDAQ NASDAQ NASDAQ CRYPTO
|
||||
Volume 47.584 M 20.749 M 71.685 M 108.090 M 18.651 B
|
||||
Avg Volume 61989696 31388708 64279718 153783115 23774151613
|
||||
Open 169.28 306.97 104.95 163.17 29248.242
|
||||
Previous Close 169.68 307.26 105.45 164.31 29248.242
|
||||
Eps 5.89 9.22 -0.26 3.48 NaN
|
||||
Pe 28.79 33.14 -392.5 46.5 NaN
|
||||
Earnings Announcement 2023-05-04 20:00:00 2023-07-24 10:59:00 2023-07-26 10:59:00 2023-07-18 20:00:00 None
|
||||
Shares Outstanding 15.822 B 7.435 B 10.258 B 3.169 B 19.362 M
|
||||
Timestamp 2023-05-01 13:00:04 2023-05-01 13:00:04 2023-05-01 13:00:04 2023-05-01 13:00:04 2023-05-01 15:57:00
|
||||
22
tests/openbb_terminal/stocks/txt/test_stocks_helper/test_quote.txt
vendored
Normal file
22
tests/openbb_terminal/stocks/txt/test_stocks_helper/test_quote.txt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Symbol GME
|
||||
Name GameStop Corp.
|
||||
Price 18.55
|
||||
Changes Percentage -3.8362
|
||||
Change -0.74
|
||||
Day Low 18.46
|
||||
Day High 19.25
|
||||
Year High 47.99
|
||||
Year Low 15.41
|
||||
Market Cap 5.652 B
|
||||
Price Avg50 20.2712
|
||||
Price Avg200 25.07525
|
||||
Exchange NYSE
|
||||
Volume 2.338 M
|
||||
Avg Volume 4985721
|
||||
Open 19.16
|
||||
Previous Close 19.29
|
||||
Eps -1.05
|
||||
Pe -17.67
|
||||
Earnings Announcement 2023-05-30 10:59:00
|
||||
Shares Outstanding 304.675 M
|
||||
Timestamp 2023-05-01 13:00:02
|
||||
22
tests/openbb_terminal/stocks/txt/test_stocks_helper/test_quote_bad_ticker.txt
vendored
Normal file
22
tests/openbb_terminal/stocks/txt/test_stocks_helper/test_quote_bad_ticker.txt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Symbol F GM RIVN
|
||||
Name Ford Motor Company General Motors Company Rivian Automotive, Inc.
|
||||
Price 12.06 33.48 12.65
|
||||
Changes Percentage 1.5152 1.3317 -1.3261
|
||||
Change 0.18 0.44 -0.17
|
||||
Day Low 11.99 33.435 12.37
|
||||
Day High 12.29 34.2796 12.83
|
||||
Year High 16.68 43.63 40.86
|
||||
Year Low 10.61 30.33 11.68
|
||||
Market Cap 47.219 B 46.541 B 11.629 B
|
||||
Price Avg50 12.1882 36.261 14.7598
|
||||
Price Avg200 13.11915 37.10095 25.518675
|
||||
Exchange NYSE NYSE NASDAQ
|
||||
Volume 55.959 M 16.839 M 12.488 M
|
||||
Avg Volume 69625791 14667721 29025515
|
||||
Open 12.005 34.0 12.805
|
||||
Previous Close 11.88 33.04 12.82
|
||||
Eps -0.49 6.53 -7.49
|
||||
Pe -24.61 5.13 -1.69
|
||||
Earnings Announcement 2023-05-02 20:05:00 2023-07-25 12:30:00 2023-05-09 20:00:00
|
||||
Shares Outstanding 3.915 B 1.390 B 919.265 M
|
||||
Timestamp 2023-05-01 13:03:08 2023-05-01 13:00:02 2023-05-01 13:00:04
|
||||
Reference in New Issue
Block a user