diff options
Diffstat (limited to 'openbb_platform/openbb/package')
-rw-r--r-- | openbb_platform/openbb/package/derivatives_options.py | 168 | ||||
-rw-r--r-- | openbb_platform/openbb/package/fixedincome.py | 127 |
2 files changed, 286 insertions, 9 deletions
diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index 01765d5355a..8ee07ea3a21 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -13,6 +13,7 @@ from typing_extensions import Annotated class ROUTER_derivatives_options(Container): """/derivatives/options chains + snapshots unusual """ @@ -42,6 +43,28 @@ class ROUTER_derivatives_options(Container): The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio, yfinance. date : Optional[datetime.date] The end-of-day date for options chains data. (provider: intrinio) + option_type : Literal[None, Union[ForwardRef('call'), ForwardRef('put')]] + The option type, call or put, 'None' is both (default). (provider: intrinio) + moneyness : Literal['otm', 'itm', 'all'] + Return only contracts that are in or out of the money, default is 'all'. Parameter is ignored when a date is supplied. (provider: intrinio) + strike_gt : Optional[int] + Return options with a strike price greater than the given value. Parameter is ignored when a date is supplied. (provider: intrinio) + strike_lt : Optional[int] + Return options with a strike price less than the given value. Parameter is ignored when a date is supplied. (provider: intrinio) + volume_gt : Optional[int] + Return options with a volume greater than the given value. Parameter is ignored when a date is supplied. (provider: intrinio) + volume_lt : Optional[int] + Return options with a volume less than the given value. Parameter is ignored when a date is supplied. (provider: intrinio) + oi_gt : Optional[int] + Return options with an open interest greater than the given value. Parameter is ignored when a date is supplied. (provider: intrinio) + oi_lt : Optional[int] + Return options with an open interest less than the given value. Parameter is ignored when a date is supplied. (provider: intrinio) + model : Literal['black_scholes', 'bjerk'] + The pricing model to use for options chains data, default is 'black_scholes'. Parameter is ignored when a date is supplied. (provider: intrinio) + show_extended_price : bool + Whether to include OHLC type fields, default is True. Parameter is ignored when a date is supplied. (provider: intrinio) + include_related_symbols : bool + Include related symbols that end in a 1 or 2 because of a corporate action, default is False. (provider: intrinio) Returns ------- @@ -59,14 +82,18 @@ class ROUTER_derivatives_options(Container): OptionsChains ------------- - symbol : Optional[str] - Symbol representing the entity requested in the data. Here, it is the underlying symbol for the option. + underlying_symbol : Optional[str] + Underlying symbol for the option. + underlying_price : Optional[float] + Price of the underlying stock. contract_symbol : str Contract symbol for the option. eod_date : Optional[date] Date for which the options chains are returned. expiration : date Expiration date of the contract. + dte : Optional[int] + Days to expiration of the contract. strike : float Strike price of the contract. option_type : str @@ -79,16 +106,28 @@ class ROUTER_derivatives_options(Container): Theoretical value of the option. last_trade_price : Optional[float] Last trade price of the option. + last_trade_size : Optional[int] + Last trade size of the option. + last_trade_time : Optional[datetime] + The timestamp of the last trade. tick : Optional[str] Whether the last tick was up or down in price. bid : Optional[float] Current bid price for the option. bid_size : Optional[int] Bid size for the option. + bid_time : Optional[datetime] + The timestamp of the bid price. + bid_exchange : Optional[str] + The exchange of the bid price. ask : Optional[float] Current ask price for the option. ask_size : Optional[int] Ask size for the option. + ask_time : Optional[datetime] + The timestamp of the ask price. + ask_exchange : Optional[str] + The exchange of the ask price. mark : Optional[float] The mid-price between the latest bid and ask. open : Optional[float] @@ -132,7 +171,7 @@ class ROUTER_derivatives_options(Container): change : Optional[float] The change in the price of the option. change_percent : Optional[float] - Change, in normalizezd percentage points, of the option. + Change, in normalized percentage points, of the option. implied_volatility : Optional[float] Implied volatility of the option. delta : Optional[float] @@ -145,14 +184,10 @@ class ROUTER_derivatives_options(Container): Vega of the option. rho : Optional[float] Rho of the option. - exercise_style : Optional[str] - The exercise style of the option, American or European. (provider: intrinio) - dte : Optional[int] - Days to expiration. (provider: yfinance) in_the_money : Optional[bool] Whether the option is in the money. (provider: yfinance) - last_trade_timestamp : Optional[datetime] - Timestamp for when the option was last traded. (provider: yfinance) + currency : Optional[str] + Currency of the option. (provider: yfinance) Examples -------- @@ -181,6 +216,121 @@ class ROUTER_derivatives_options(Container): @exception_handler @validate + def snapshots( + self, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBField( + description="The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio." + ), + ] = None, + **kwargs + ) -> OBBject: + """Get a snapshot of the options market universe. + + Parameters + ---------- + provider : Optional[Literal['intrinio']] + The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio. + date : Optional[Union[datetime.date, datetime.datetime, str]] + The date of the data. Can be a datetime or an ISO datetime string. Data appears to go back to around 2022-06-01 Example: '2024-03-08T12:15:00+0400' (provider: intrinio) + only_traded : bool + Only include options that have been traded during the session, default is True. Setting to false will dramatically increase the size of the response - use with caution. (provider: intrinio) + + Returns + ------- + OBBject + results : List[OptionsSnapshots] + Serializable results. + provider : Optional[Literal['intrinio']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + OptionsSnapshots + ---------------- + underlying_symbol : str + Ticker symbol of the underlying asset. + contract_symbol : str + Symbol of the options contract. + expiration : date + Expiration date of the options contract. + dte : Optional[int] + Number of days to expiration of the options contract. + strike : float + Strike price of the options contract. + option_type : str + The type of option. + volume : Optional[int] + Total trade volume from the beginning of the session. + open_interest : Optional[int] + Open interest at the time. + last_price : Optional[float] + Last trade price at the time. + last_size : Optional[int] + Lot size of the last trade. + last_timestamp : Optional[datetime] + Timestamp of the last price. + open : Optional[float] + The open price. + high : Optional[float] + The high price. + low : Optional[float] + The low price. + close : Optional[float] + The close price. + bid : Optional[float] + The last bid price at the time. (provider: intrinio) + bid_size : Optional[int] + The size of the last bid price. (provider: intrinio) + bid_timestamp : Optional[datetime] + The timestamp of the last bid price. (provider: intrinio) + ask : Optional[float] + The last ask price at the time. (provider: intrinio) + ask_size : Optional[int] + The size of the last ask price. (provider: intrinio) + ask_timestamp : Optional[datetime] + The timestamp of the last ask price. (provider: intrinio) + total_bid_volume : Optional[int] + Total volume of bids. (provider: intrinio) + bid_high : Optional[float] + The highest bid price. (provider: intrinio) + bid_low : Optional[float] + The lowest bid price. (provider: intrinio) + total_ask_volume : Optional[int] + Total volume of asks. (provider: intrinio) + ask_high : Optional[float] + The highest ask price. (provider: intrinio) + ask_low : Optional[float] + The lowest ask price. (provider: intrinio) + + Examples + -------- + >>> from openbb import obb + >>> obb.derivatives.options.snapshots(provider='intrinio') + """ # noqa: E501 + + return self._run( + "/derivatives/options/snapshots", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "derivatives.options.snapshots", + ("intrinio",), + ) + }, + standard_params={}, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate def unusual( self, symbol: Annotated[ diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 456845abcf0..6f5dbb27f60 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -16,6 +16,7 @@ class ROUTER_fixedincome(Container): bond_indices /corporate /government + mortgage_indices /rate sofr /spreads @@ -184,6 +185,132 @@ class ROUTER_fixedincome(Container): command_runner=self._command_runner ) + @exception_handler + @validate + def mortgage_indices( + self, + 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, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBField( + description="The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fred." + ), + ] = None, + **kwargs + ) -> OBBject: + """Mortgage Indices. + + Parameters + ---------- + 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. + provider : Optional[Literal['fred']] + The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fred. + index : Union[Literal['primary', 'ltv_lte_80', 'ltv_gt_80', 'conforming_30y', 'conforming_30y_na', 'jumbo_30y', 'fha_30y', 'va_30y', 'usda_30y', 'conforming_15y', 'ltv_lte80_fico_ge740', 'ltv_lte80_fico_a720b739', 'ltv_lte80_fico_a700b719', 'ltv_lte80_fico_a680b699', 'ltv_lte80_fico_lt680', 'ltv_gt80_fico_ge740', 'ltv_gt80_fico_a720b739', 'ltv_gt80_fico_a700b719', 'ltv_gt80_fico_a680b699', 'ltv_gt80_fico_lt680'], str] + The specific index, or index group, to query. Default is the 'primary' group. Multiple comma separated items allowed. (provider: fred) + frequency : Optional[Literal['a', 'q', 'm', 'w', 'd', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] + + Frequency aggregation to convert daily data to lower frequency. + None = No change + a = Annual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) + aggregation_method : Literal['avg', 'sum', 'eop'] + + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set, default is 'avg'. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) + transform : Optional[Literal['chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log']] + + Transformation type + None = No transformation + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) + + Returns + ------- + OBBject + results : List[MortgageIndices] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + MortgageIndices + --------------- + date : date + The date of the data. + symbol : Optional[str] + Symbol representing the entity requested in the data. + name : Optional[str] + Name of the index. + rate : float + Mortgage rate. + + Examples + -------- + >>> from openbb import obb + >>> # The default state for FRED are the primary mortgage indices from Optimal Blue. + >>> obb.fixedincome.mortgage_indices(provider='fred') + >>> # Multiple indices can be requested. + >>> obb.fixedincome.mortgage_indices(index='jumbo_30y,conforming_30y,conforming_15y', provider='fred') + """ # noqa: E501 + + return self._run( + "/fixedincome/mortgage_indices", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "fixedincome.mortgage_indices", + ("fred",), + ) + }, + standard_params={ + "start_date": start_date, + "end_date": end_date, + }, + extra_params=kwargs, + info={"index": {"fred": {"multiple_items_allowed": True}}}, + ) + ) + @property def rate(self): # pylint: disable=import-outside-toplevel |