mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
* LLM mode * Docstring truncation * Preferences * Output type * use settings instead? (#6314) * Refactor with @montezdesousa * fix test * fix: max length type * field descriptions * try with FieldInfo * ugly... * partial * override FieldInfo __repr__ * typing * separate model_config * rename OpenBBCustomParameter to OpenBBField * lint * pydocstyle * don't include choices if no choices --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
320 lines
12 KiB
Python
320 lines
12 KiB
Python
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###
|
|
|
|
import datetime
|
|
from typing import List, Literal, Optional, Union
|
|
from warnings import simplefilter, warn
|
|
|
|
from openbb_core.app.deprecation import OpenBBDeprecationWarning
|
|
from openbb_core.app.model.field import OpenBBField
|
|
from openbb_core.app.model.obbject import OBBject
|
|
from openbb_core.app.static.container import Container
|
|
from openbb_core.app.static.utils.decorators import exception_handler, validate
|
|
from openbb_core.app.static.utils.filters import filter_inputs
|
|
from typing_extensions import Annotated, deprecated
|
|
|
|
|
|
class ROUTER_index(Container):
|
|
"""/index
|
|
available
|
|
constituents
|
|
market
|
|
/price
|
|
"""
|
|
|
|
def __repr__(self) -> str:
|
|
return self.__doc__ or ""
|
|
|
|
@exception_handler
|
|
@validate
|
|
def available(
|
|
self,
|
|
provider: Annotated[
|
|
Optional[Literal["fmp", "yfinance"]],
|
|
OpenBBField(
|
|
description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default."
|
|
),
|
|
] = None,
|
|
**kwargs
|
|
) -> OBBject:
|
|
"""All indices available from a given provider.
|
|
|
|
Parameters
|
|
----------
|
|
provider : Optional[Literal['fmp', 'yfinance']]
|
|
The provider to use for the query, by default None.
|
|
If None, the provider specified in defaults is selected or 'fmp' if there is
|
|
no default.
|
|
|
|
Returns
|
|
-------
|
|
OBBject
|
|
results : List[AvailableIndices]
|
|
Serializable results.
|
|
provider : Optional[Literal['fmp', 'yfinance']]
|
|
Provider name.
|
|
warnings : Optional[List[Warning_]]
|
|
List of warnings.
|
|
chart : Optional[Chart]
|
|
Chart object.
|
|
extra : Dict[str, Any]
|
|
Extra info.
|
|
|
|
AvailableIndices
|
|
----------------
|
|
name : Optional[str]
|
|
Name of the index.
|
|
currency : Optional[str]
|
|
Currency the index is traded in.
|
|
stock_exchange : Optional[str]
|
|
Stock exchange where the index is listed. (provider: fmp)
|
|
exchange_short_name : Optional[str]
|
|
Short name of the stock exchange where the index is listed. (provider: fmp)
|
|
code : Optional[str]
|
|
ID code for keying the index in the OpenBB Terminal. (provider: yfinance)
|
|
symbol : Optional[str]
|
|
Symbol for the index. (provider: yfinance)
|
|
|
|
Examples
|
|
--------
|
|
>>> from openbb import obb
|
|
>>> obb.index.available(provider='fmp')
|
|
>>> obb.index.available(provider='yfinance')
|
|
""" # noqa: E501
|
|
|
|
return self._run(
|
|
"/index/available",
|
|
**filter_inputs(
|
|
provider_choices={
|
|
"provider": self._get_provider(
|
|
provider,
|
|
"/index/available",
|
|
("fmp", "yfinance"),
|
|
)
|
|
},
|
|
standard_params={},
|
|
extra_params=kwargs,
|
|
)
|
|
)
|
|
|
|
@exception_handler
|
|
@validate
|
|
def constituents(
|
|
self,
|
|
symbol: Annotated[str, OpenBBField(description="Symbol to get data for.")],
|
|
provider: Annotated[
|
|
Optional[Literal["fmp"]],
|
|
OpenBBField(
|
|
description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default."
|
|
),
|
|
] = None,
|
|
**kwargs
|
|
) -> OBBject:
|
|
"""Get Index Constituents.
|
|
|
|
Parameters
|
|
----------
|
|
symbol : str
|
|
Symbol to get data for.
|
|
provider : Optional[Literal['fmp']]
|
|
The provider to use for the query, by default None.
|
|
If None, the provider specified in defaults is selected or 'fmp' if there is
|
|
no default.
|
|
|
|
Returns
|
|
-------
|
|
OBBject
|
|
results : List[IndexConstituents]
|
|
Serializable results.
|
|
provider : Optional[Literal['fmp']]
|
|
Provider name.
|
|
warnings : Optional[List[Warning_]]
|
|
List of warnings.
|
|
chart : Optional[Chart]
|
|
Chart object.
|
|
extra : Dict[str, Any]
|
|
Extra info.
|
|
|
|
IndexConstituents
|
|
-----------------
|
|
symbol : str
|
|
Symbol representing the entity requested in the data.
|
|
name : Optional[str]
|
|
Name of the constituent company in the index.
|
|
sector : Optional[str]
|
|
Sector the constituent company in the index belongs to. (provider: fmp)
|
|
sub_sector : Optional[str]
|
|
Sub-sector the constituent company in the index belongs to. (provider: fmp)
|
|
headquarter : Optional[str]
|
|
Location of the headquarter of the constituent company in the index. (provider: fmp)
|
|
date_first_added : Optional[Union[str, date]]
|
|
Date the constituent company was added to the index. (provider: fmp)
|
|
cik : Optional[int]
|
|
Central Index Key (CIK) for the requested entity. (provider: fmp)
|
|
founded : Optional[Union[str, date]]
|
|
Founding year of the constituent company in the index. (provider: fmp)
|
|
|
|
Examples
|
|
--------
|
|
>>> from openbb import obb
|
|
>>> obb.index.constituents(symbol='dowjones', provider='fmp')
|
|
""" # noqa: E501
|
|
|
|
return self._run(
|
|
"/index/constituents",
|
|
**filter_inputs(
|
|
provider_choices={
|
|
"provider": self._get_provider(
|
|
provider,
|
|
"/index/constituents",
|
|
("fmp",),
|
|
)
|
|
},
|
|
standard_params={
|
|
"symbol": symbol,
|
|
},
|
|
extra_params=kwargs,
|
|
)
|
|
)
|
|
|
|
@exception_handler
|
|
@validate
|
|
@deprecated(
|
|
"This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.",
|
|
category=OpenBBDeprecationWarning,
|
|
)
|
|
def market(
|
|
self,
|
|
symbol: Annotated[
|
|
Union[str, List[str]],
|
|
OpenBBField(
|
|
description="Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp, intrinio, polygon, yfinance."
|
|
),
|
|
],
|
|
start_date: Annotated[
|
|
Union[datetime.date, None, str],
|
|
OpenBBField(description="Start date of the data, in YYYY-MM-DD format."),
|
|
] = None,
|
|
end_date: Annotated[
|
|
Union[datetime.date, None, str],
|
|
OpenBBField(description="End date of the data, in YYYY-MM-DD format."),
|
|
] = None,
|
|
interval: Annotated[
|
|
Optional[str],
|
|
OpenBBField(description="Time interval of the data to return."),
|
|
] = "1d",
|
|
provider: Annotated[
|
|
Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]],
|
|
OpenBBField(
|
|
description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default."
|
|
),
|
|
] = None,
|
|
**kwargs
|
|
) -> OBBject:
|
|
"""Get Historical Market Indices.
|
|
|
|
Parameters
|
|
----------
|
|
symbol : Union[str, List[str]]
|
|
Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp, intrinio, polygon, yfinance.
|
|
start_date : Union[datetime.date, None, str]
|
|
Start date of the data, in YYYY-MM-DD format.
|
|
end_date : Union[datetime.date, None, str]
|
|
End date of the data, in YYYY-MM-DD format.
|
|
interval : Optional[str]
|
|
Time interval of the data to return.
|
|
provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']]
|
|
The provider to use for the query, by default None.
|
|
If None, the provider specified in defaults is selected or 'fmp' if there is
|
|
no default.
|
|
limit : Optional[int]
|
|
The number of data entries to return. (provider: intrinio, polygon)
|
|
sort : Literal['asc', 'desc']
|
|
Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon)
|
|
|
|
Returns
|
|
-------
|
|
OBBject
|
|
results : List[MarketIndices]
|
|
Serializable results.
|
|
provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']]
|
|
Provider name.
|
|
warnings : Optional[List[Warning_]]
|
|
List of warnings.
|
|
chart : Optional[Chart]
|
|
Chart object.
|
|
extra : Dict[str, Any]
|
|
Extra info.
|
|
|
|
MarketIndices
|
|
-------------
|
|
date : Union[date, datetime]
|
|
The date of the data.
|
|
open : Optional[Annotated[float, Strict(strict=True)]]
|
|
The open price.
|
|
high : Optional[Annotated[float, Strict(strict=True)]]
|
|
The high price.
|
|
low : Optional[Annotated[float, Strict(strict=True)]]
|
|
The low price.
|
|
close : Optional[Annotated[float, Strict(strict=True)]]
|
|
The close price.
|
|
volume : Optional[int]
|
|
The trading volume.
|
|
vwap : Optional[float]
|
|
Volume Weighted Average Price over the period. (provider: fmp)
|
|
change : Optional[float]
|
|
Change in the price from the previous close. (provider: fmp)
|
|
change_percent : Optional[float]
|
|
Change in the price from the previous close, as a normalized percent. (provider: fmp)
|
|
transactions : Optional[Annotated[int, Gt(gt=0)]]
|
|
Number of transactions for the symbol in the time period. (provider: polygon)
|
|
|
|
Examples
|
|
--------
|
|
>>> from openbb import obb
|
|
>>> obb.index.market(symbol='^IBEX', provider='fmp')
|
|
""" # noqa: E501
|
|
|
|
simplefilter("always", DeprecationWarning)
|
|
warn(
|
|
"This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.",
|
|
category=DeprecationWarning,
|
|
stacklevel=2,
|
|
)
|
|
|
|
return self._run(
|
|
"/index/market",
|
|
**filter_inputs(
|
|
provider_choices={
|
|
"provider": self._get_provider(
|
|
provider,
|
|
"/index/market",
|
|
("fmp", "intrinio", "polygon", "yfinance"),
|
|
)
|
|
},
|
|
standard_params={
|
|
"symbol": symbol,
|
|
"start_date": start_date,
|
|
"end_date": end_date,
|
|
"interval": interval,
|
|
},
|
|
extra_params=kwargs,
|
|
info={
|
|
"symbol": {
|
|
"multiple_items_allowed": [
|
|
"fmp",
|
|
"intrinio",
|
|
"polygon",
|
|
"yfinance",
|
|
]
|
|
}
|
|
},
|
|
)
|
|
)
|
|
|
|
@property
|
|
def price(self):
|
|
# pylint: disable=import-outside-toplevel
|
|
from . import index_price
|
|
|
|
return index_price.ROUTER_index_price(command_runner=self._command_runner)
|