diff options
Diffstat (limited to 'openbb_platform/openbb/package/index.py')
-rw-r--r-- | openbb_platform/openbb/package/index.py | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index a65de36b82a..0d945611d79 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -27,7 +27,14 @@ class ROUTER_index(Container): @exception_handler @validate def available( - self, provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["fmp", "yfinance"]], + OpenBBCustomParameter( + 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. @@ -67,10 +74,11 @@ class ROUTER_index(Container): symbol : Optional[str] Symbol for the index. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb - >>> obb.index.available(provider="yfinance").to_df() + >>> obb.index.available(provider='fmp') + >>> obb.index.available(provider='yfinance') """ # noqa: E501 return self._run( @@ -95,7 +103,12 @@ class ROUTER_index(Container): symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + 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: """Index Constituents. @@ -142,12 +155,10 @@ class ROUTER_index(Container): founded : Optional[Union[str, date]] Founding year of the constituent company in the index. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb - >>> obb.index.constituents("dowjones", provider="fmp").to_df() - >>> #### Providers other than FMP will use the ticker symbol. #### - >>> obb.index.constituents("BEP50P", provider="cboe").to_df() + >>> obb.index.constituents(symbol='dowjones', provider='fmp') """ # noqa: E501 return self._run( @@ -178,7 +189,7 @@ class ROUTER_index(Container): symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, polygon, yfinance." ), ], start_date: Annotated[ @@ -193,7 +204,16 @@ class ROUTER_index(Container): description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + interval: Annotated[ + Optional[str], + OpenBBCustomParameter(description="Time interval of the data to return."), + ] = "1d", + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]], + OpenBBCustomParameter( + 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: """Historical Market Indices. @@ -201,41 +221,21 @@ class ROUTER_index(Container): Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): yfinance. + Symbol to get data for. Multiple 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. - timeseries : Optional[Annotated[int, Ge(ge=0)]] - Number of days to look back. (provider: fmp) - interval : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1W', '1M', '1Q']]] - Data granularity. (provider: fmp, yfinance) - sort : Literal['asc', 'desc'] - Sort the data in ascending or descending order. (provider: fmp); - Sort order. (provider: intrinio); - Sort order of the data. (provider: polygon) - tag : Optional[str] - Index tag. (provider: intrinio) - type : Optional[str] - Index type. (provider: intrinio) - limit : int + limit : Optional[int] The number of data entries to return. (provider: intrinio, polygon) - timespan : Literal['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'] - Timespan of the data. (provider: polygon) - adjusted : bool - Whether the data is adjusted. (provider: polygon) - multiplier : int - Multiplier of the timespan. (provider: polygon) - period : Optional[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']] - Time period of the data to return. (provider: yfinance) - prepost : bool - Include Pre and Post market data. (provider: yfinance) - rounding : bool - Round prices to two decimals? (provider: yfinance) + 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 ------- @@ -253,7 +253,7 @@ class ROUTER_index(Container): MarketIndices ------------- - date : datetime + date : Union[date, datetime] The date of the data. open : Optional[Annotated[float, Strict(strict=True)]] The open price. @@ -265,25 +265,19 @@ class ROUTER_index(Container): The close price. volume : Optional[int] The trading volume. - adj_close : Optional[float] - The adjusted close price. (provider: fmp) - unadjusted_volume : Optional[float] - Unadjusted volume of the symbol. (provider: fmp) + vwap : Optional[float] + Volume Weighted Average Price over the period. (provider: fmp) change : Optional[float] - Change in the price of the symbol from the previous day. (provider: fmp) + Change in the price from the previous close. (provider: fmp) change_percent : Optional[float] - Change % in the price of the symbol. (provider: fmp) - label : Optional[str] - Human readable format of the date. (provider: fmp) - change_over_time : Optional[float] - Change % in the price of the symbol over a period of time. (provider: fmp) + 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) - Example - ------- + Examples + -------- >>> from openbb import obb - >>> obb.index.market(symbol="SPX") + >>> obb.index.market(symbol='^IBEX', provider='fmp') """ # noqa: E501 simplefilter("always", DeprecationWarning) @@ -307,9 +301,19 @@ class ROUTER_index(Container): "symbol": symbol, "start_date": start_date, "end_date": end_date, + "interval": interval, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["yfinance"]}}, + extra_info={ + "symbol": { + "multiple_items_allowed": [ + "fmp", + "intrinio", + "polygon", + "yfinance", + ] + } + }, ) ) |