Merge branch 'feature/openbb-sdk-v4' into feature/sdk-v4-updates

This commit is contained in:
tehcoderer
2023-08-11 14:05:36 -04:00
4 changed files with 20 additions and 192 deletions

View File

@@ -43,7 +43,7 @@ from openbb import obb
stock_data = obb.stocks.load(symbol="TSLA", chart=True)
```
Which would result in an `Obbject` object containing a `chart` attribute, which contains plotly json data.
This results in a `Obbject` object containing a `chart` attribute, which contains Plotly JSON data.
In order to display the chart, you need to call the `show()` method:

View File

@@ -5,7 +5,7 @@ from typing import Annotated, List, Literal, Optional, Union
import pydantic
import pydantic.main
from pydantic import BaseModel, validate_arguments
from pydantic import validate_arguments
import openbb_core.app.model.command_context
import openbb_core.app.model.results.empty
@@ -101,10 +101,10 @@ class CLASS_stocks(Container):
),
] = None,
chart: bool = False,
provider: Optional[Literal["cboe", "fmp", "polygon", "yfinance"]] = None,
provider: Optional[Literal["polygon", "fmp"]] = None,
**kwargs,
) -> Obbject[List]:
"""Load stock data for a specific ticker.
r"""Load stock data for a specific ticker.
openbb
@@ -267,7 +267,7 @@ class CLASS_stocks(Container):
),
] = 15,
chart: bool = False,
provider: Optional[Literal["benzinga", "fmp", "polygon"]] = None,
provider: Optional[Literal["benzinga", "polygon", "fmp"]] = None,
**kwargs,
) -> Obbject[List]:
"""Get news for one or more stock tickers.
@@ -645,7 +645,7 @@ class CLASS_stocks(Container):
def tob(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""View top of book for loaded ticker (US exchanges only).""" # noqa: E501
"""View top of book for loaded ticker (US exchanges only)."""
inputs = filter_inputs(
chart=chart,
)
@@ -659,70 +659,10 @@ class CLASS_stocks(Container):
@filter_call
@validate_arguments
def search(
self,
query: Annotated[
str, OpenBBCustomParameter(description="The search query.")
] = "",
ticker: Annotated[
bool,
OpenBBCustomParameter(description="Whether to search by ticker symbol."),
] = False,
chart: bool = False,
provider: Optional[Literal["cboe"]] = None,
**kwargs,
) -> Obbject[List]:
"""Search for a company or stock ticker.
openbb
======
Parameters
----------
provider: Literal[cboe]
The provider to use for the query.
query : str
The search query.
ticker : bool
Whether to search by ticker symbol.
Returns
-------
Obbject
results: List[Data]
Serializable results.
provider: Optional[PROVIDERS]
Provider name.
warnings: Optional[List[Warning_]]
List of warnings.
error: Optional[Error]
Caught exceptions.
chart: Optional[Chart]
Chart object.
StockSearch
-----------
symbol : str
The ticker symbol of the company.
name : str
The name of the company.
cboe
====
Parameters
----------
All fields are standardized.
StockSearch
-----------
dpmName : Optional[str]
The name of the primary market maker.
postStation : Optional[str]
The post and station location on the CBOE trading floor.""" # noqa: E501
def quote(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""View the current price for a specific stock ticker."""
inputs = filter_inputs(
provider_choices={
"provider": provider,
@@ -860,117 +800,10 @@ class CLASS_stocks(Container):
@filter_call
@validate_arguments
def info(
self,
symbol: Annotated[
Union[str, List[str]],
OpenBBCustomParameter(description="Symbol to get data for."),
],
chart: bool = False,
provider: Optional[Literal["cboe"]] = None,
**kwargs,
) -> Obbject[BaseModel]:
"""Get general price and performance metrics of a stock.
openbb
======
Parameters
----------
provider: Literal[cboe]
The provider to use for the query.
symbol : str
Symbol to get data for.
Returns
-------
Obbject
results: List[Data]
Serializable results.
provider: Optional[PROVIDERS]
Provider name.
warnings: Optional[List[Warning_]]
List of warnings.
error: Optional[Error]
Caught exceptions.
chart: Optional[Chart]
Chart object.
StockInfo
---------
symbol : str
The ticker symbol.
name : str
The name associated with the ticker symbol.
price : float
The last price of the stock.
open : Optional[float]
The opening price of the stock.
high : Optional[float]
The high price of the current trading day.
low : Optional[float]
The low price of the current trading day.
close : Optional[float]
The closing price of the stock.
change : Optional[float]
The change in price over the current trading period.
change_percent : Optional[float]
The % change in price over the current trading period.
previous_close : Optional[float]
The previous closing price of the stock.
cboe
====
Parameters
----------
All fields are standardized.
StockInfo
---------
type : Optional[str]
The type of asset.
tick : Optional[str]
Whether the last sale was an up or down tick.
bid : Optional[float]
The current bid price.
bid_size : Optional[float]
The bid lot size.
ask : Optional[float]
The current ask price.
ask_size : Optional[float]
The ask lot size.
volume : Optional[float]
The stock volume for the current trading day.
iv_thirty : Optional[float]
The 30-day implied volatility of the stock.
iv_thirty_change : Optional[float]
The change in 30-day implied volatility of the stock.
last_trade_timestamp : Optional[datetime]
The last trade timestamp for the stock.
iv_thirty_one_year_high : Optional[float]
The 1-year high of implied volatility.
hv_thirty_one_year_high : Optional[float]
The 1-year high of realized volatility.
iv_thirty_one_year_low : Optional[float]
The 1-year low of implied volatility.
hv_thirty_one_year_low : Optional[float]
The 1-year low of realized volatility.
iv_sixty_one_year_high : Optional[float]
The 60-day high of implied volatility.
hv_sixty_one_year_high : Optional[float]
The 60-day high of realized volatility.
iv_sixty_one_year_low : Optional[float]
The 60-day low of implied volatility.
hv_sixty_one_year_low : Optional[float]
The 60-day low of realized volatility.
iv_ninety_one_year_high : Optional[float]
The 90-day high of implied volatility.
hv_ninety_one_year_high : Optional[float]
The 90-day high of realized volatility.""" # noqa: E501
def search(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""Search a specific stock ticker for analysis."""
inputs = filter_inputs(
provider_choices={
"provider": provider,

View File

@@ -297,7 +297,7 @@ class CLASS_ta(Container):
def tv(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""TradingView.""" # noqa: E501
"""TradingView."""
inputs = filter_inputs(
chart=chart,
)
@@ -389,7 +389,7 @@ class CLASS_ta(Container):
def multi(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""Plot multiple indicators on the same chart.""" # noqa: E501
"""Plot multiple indicators on the same chart."""
inputs = filter_inputs(
chart=chart,
)
@@ -698,7 +698,7 @@ class CLASS_ta(Container):
def recom(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""Recommendation.""" # noqa: E501
"""Recommendation."""
inputs = filter_inputs(
chart=chart,
)
@@ -1280,7 +1280,7 @@ class CLASS_ta(Container):
def summary(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""Summary.""" # noqa: E501
"""Summary."""
inputs = filter_inputs(
chart=chart,
)
@@ -1356,7 +1356,7 @@ class CLASS_ta(Container):
def rsp(
self, chart: bool = False
) -> Obbject[openbb_core.app.model.results.empty.Empty]:
"""Relative Strength Performance.""" # noqa: E501
"""Relative Strength Performance."""
inputs = filter_inputs(
chart=chart,
)

View File

@@ -595,12 +595,7 @@ class MethodDefinition:
if hasattr(item_type, "__name__")
else item_type._name
)
result_type = f"{item_type.__module__}.{inner_type_name}"
if "pydantic.main" in result_type:
result_type = "BaseModel"
func_returns = f"Obbject[{result_type}]"
func_returns = f"Obbject[{item_type.__module__}.{inner_type_name}]"
return func_returns