mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Feature/price (#961)
* Begin implementing price option for quote in stocks * Still sane tests. Note: Why can't we interface with the ticker (pandas df) itself from within the GST? E.g. GME.price * Basic function of price option for quote achieved (e.g. "quote -t GME -p" returns "Price of GME 210.0"). Not sure if this is compatible with non-YF data backends. Still need to update documentation. * Removed personalized comments in prep for pull request. Simple feature works, but IMO brings up questions about ideal function of load and quote functions. * Changed one comment, also tried testing pre-commit, no output is good? * Added option [-p] to usage and description * cleaned extra lines * Cleaned extra lines * Test print df in load, fixed formatting for print in quote (hope it passes linter) * Deleted whitespace for linter... * Reformatted for linter * Removed tests for load * Rewrote but black linter still seems to fail on ```
This commit is contained in:
@@ -284,7 +284,6 @@ def load(
|
||||
df_stock_candidate = yf.download(
|
||||
ns_parser.s_ticker,
|
||||
start=ns_parser.s_start_date,
|
||||
end=ns_parser.s_end_date,
|
||||
progress=False,
|
||||
)
|
||||
|
||||
@@ -699,6 +698,16 @@ def quote(other_args: List[str], s_ticker: str):
|
||||
help="Stock ticker",
|
||||
)
|
||||
|
||||
# Price only option.
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--price",
|
||||
action="store_true",
|
||||
dest="price_only",
|
||||
default=False,
|
||||
help="Price only",
|
||||
)
|
||||
|
||||
try:
|
||||
# For the case where a user uses: 'quote BB'
|
||||
if other_args and "-" not in other_args[0]:
|
||||
@@ -713,6 +722,11 @@ def quote(other_args: List[str], s_ticker: str):
|
||||
|
||||
ticker = yf.Ticker(ns_parser.s_ticker)
|
||||
|
||||
# If price only option, return immediate market price for ticker.
|
||||
if ns_parser.price_only:
|
||||
print(f"Price of {ns_parser.s_ticker} {ticker.info['regularMarketPrice']}")
|
||||
return
|
||||
|
||||
try:
|
||||
quote_df = pd.DataFrame(
|
||||
[
|
||||
@@ -761,6 +775,7 @@ def quote(other_args: List[str], s_ticker: str):
|
||||
stralign="right",
|
||||
)
|
||||
)
|
||||
|
||||
except KeyError:
|
||||
print(f"Invalid stock ticker: {ns_parser.s_ticker}")
|
||||
|
||||
|
||||
3
website/content/stocks/quote/_index.md
vendored
3
website/content/stocks/quote/_index.md
vendored
@@ -1,5 +1,5 @@
|
||||
```
|
||||
usage: quote [-t S_TICKER] [-h]
|
||||
usage: quote [-t S_TICKER] [-p] [-h]
|
||||
```
|
||||
|
||||
Retrieves a current quote from the currently [loaded ticker](https://gamestonkterminal.github.io/GamestonkTerminal/stocks/load/). To view a quote from a different symbol than what is currently loaded, add the '-t' argument to the command string.
|
||||
@@ -8,6 +8,7 @@ Retrieves a current quote from the currently [loaded ticker](https://gamestonkte
|
||||
optional arguments:
|
||||
-t S_TICKER, --ticker S_TICKER
|
||||
Stock ticker (default: AAPL)
|
||||
-p, --price Return only the current price (default: False)
|
||||
-h, --help show this help message (default: False)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user