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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###

from typing import Literal, Optional

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


class ROUTER_derivatives_options(Container):
    """/derivatives/options
    chains
    snapshots
    unusual
    """

    def __repr__(self) -> str:
        return self.__doc__ or ""

    @exception_handler
    @validate
    def chains(
        self,
        symbol: Annotated[str, OpenBBField(description="Symbol to get data for.")],
        provider: Annotated[
            Optional[Literal["intrinio", "yfinance"]],
            OpenBBField(
                description="The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio, yfinance."
            ),
        ] = None,
        **kwargs
    ) -> OBBject:
        """Get the complete options chain for a ticker.

        Parameters
        ----------
        provider : str
            The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio, yfinance.
        symbol : str
            Symbol to get data for.
        delay : Literal['eod', 'realtime', 'delayed']
            Whether to return delayed, realtime, or eod data. (provider: intrinio)
        date : Optional[date]
            The end-of-day date for options chains data. (provider: intrinio)
        option_type : Optional[Literal['call', '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
        -------
        OBBject
            results : OptionsChains
                Serializable results.
            provider : Optional[str]
                Provider name.
            warnings : Optional[list[Warning_]]
                list of warnings.
            chart : Optional[Chart]
                Chart object.
            extra : Dict[str, Any]
                Extra info.

        OptionsChains
        -------------
        underlying_symbol : list[Optional[str]]
            Underlying symbol for the option.
        underlying_price : list[Optional[float]]
            Price of the underlying stock.
        contract_symbol : list[str]
            Contract symbol for the option.
        eod_date : list[Optional[date]]
            Date for which the options chains are returned.
        expiration : list[date]
            Expiration date of the contract.
        dte : list[Optional[int]]
            Days to expiration of the contract.
        strike : list[float]
            Strike price of the contract.
        option_type : list[str]
            Call or Put.
        contract_size : list[Union[int, float]]
            Number of underlying units per contract.
        open_interest : list[Union[int, float]]
            Open interest on the contract.
        volume : list[Union[int, float]]
            The trading volume.
        theoretical_price : list[Optional[float]]
            Theoretical value of the option.
        last_trade_price : list[Optional[float]]
            Last trade price of the option.
        last_trade_size : list[Union[int, float]]
            Last trade size of the option.
        last_trade_time : list[Optional[datetime]]
            The timestamp of the last trade.
        tick : list[Optional[str]]
            Whether the last tick was up or down in price.
        bid : list[Optional[float]]
            Current bid price for the option.
        bid_size : list[Union[int, float]]
            Bid size for the option.
        bid_time : list[Optional[datetime]]
            The timestamp of the bid price.
        bid_exchange : list[Optional[str]]
            The exchange of the bid price.
        ask : list[Optional[float]]
            Current ask price for the option.
        ask_size : list[Union[int, float]]
            Ask size for the option.
        ask_time : list[Optional[datetime]]
            The timestamp of the ask price.
        ask_exchange : list[Optional[str]]
            The exchange of the ask price.
        mark : list[Optional[float]]
            The mid-price between the latest bid and ask.
        open : list[Optional[float]]
            The open price.
        open_bid : list[Optional[float]]
            The opening bid price for the option that day.
        open_ask : list[Optional[float]]
            The opening ask price for the option that day.
        high : list[Optional[float]]
            The high price.
        bid_high : list[Optional[float]]
            The highest bid price for the option that day.
        ask_high : list[Optional[float]]
            The highest ask price for the option that day.
        low : list[Optional[float]]
            The low price.
        bid_low : list[Optional[float]]
            The lowest bid price for the option that day.
        ask_low : list[Optional[float]]
            The lowest ask price for the option that day.
        close : list[Optional[float]]
            The close price.
        close_size : list[Union[int, float]]
            The closing trade size for the option that day.
        close_time : list[Optional[datetime]]
            The time of the closing price for the option that day.
        close_bid : list[Optional[float]]
            The closing bid price for the option that day.
        close_bid_size : list[Union[int, float]]
            The closing bid size for the option that day.
        close_bid_time : list[Optional[datetime]]
            The time of the bid closing price for the option that day.
        close_ask : list[Optional[float]]
            The closing ask price for the option that day.
        close_ask_size : list[Union[int, float]]
            The closing ask size for the option that day.
        close_ask_time : list[Optional[datetime]]
            The time of the ask closing price for the option that day.
        prev_close : list[Optional[float]]
            The previous close price.
        change : list[Optional[float]]
            The change in the price of the option.
        change_percent : list[Optional[float]]
            Change, in normalized percentage points, of the option.
        implied_volatility : list[Optional[float]]
            Implied volatility of the option.
        delta : list[Optional[float]]
            Delta of the option.
        gamma : list[Optional[float]]
            Gamma of the option.
        theta : list[Optional[float]]
            Theta of the option.
        vega : list[Optional[float]]
            Vega of the option.
        rho : list[Optional[float]]
            Rho of the option.
        in_the_money : list[Optional[bool]]
            Whether the option is in the money. (provider: yfinance)
        currency : list[Optional[str]]
            Currency of the option. (provider: yfinance)

        Examples
        --------
        >>> from openbb import obb
        >>> obb.derivatives.options.chains(symbol='AAPL', provider='intrinio')
        >>> # Use the "date" parameter to get the end-of-day-data for a specific date, where supported.
        >>> obb.derivatives.options.chains(symbol='AAPL', date='2023-01-25', provider='intrinio')
        """  # noqa: E501

        return self._run(
            "/derivatives/options/chains",
            **filter_inputs(
                provider_choices={
                    "provider": self._get_provider(
                        provider,
                        "derivatives.options.chains",
                        ("intrinio", "yfinance"),
                    )
                },
                standard_params={
                    "symbol": symbol,
                },
                extra_params=kwargs,
                info={
                    "delay": {
                        "intrinio": {
                            "multiple_items_allowed": False,
                            "choices": ["eod", "realtime", "delayed"],
                        }
                    },
                    "option_type": {
                        "intrinio": {
                            "multiple_items_allowed": False,
                            "choices": ["call", "put"],
                        }
                    },
                    "moneyness": {
                        "intrinio": {
                            "multiple_items_allowed": False,
                            "choices": ["otm", "itm", "all"],
                        }
                    },
                    "model": {
                        "intrinio": {
                            "multiple_items_allowed": False,
                            "choices": ["black_scholes", "bjerk"],
                        }
                    },
                },
            )
        )

    @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 : str
            The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio.
        date : Union[date, datetime, str, None]
            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[str]
                Provider name.
            warnings : Optional[list[Warning_]]
                list of warnings.
            chart : Optional[Chart]
                Chart object.
            extra : Dict[str, Any]
                Extra info.

        OptionsSnapshots
        ----------------
        underlying_symbol : list[str]
            Ticker symbol of the underlying asset.
        contract_symbol : list[str]
            Symbol of the options contract.
        expiration : list[date]
            Expiration date of the options contract.
        dte : list[Optional[int]]
            Number of days to expiration of the options contract.
        strike : list[float]
            Strike price of the options contract.
        option_type : list[str]
            The type of option.
        volume : list[Optional[int]]
            The trading volume.
        open_interest : list[Optional[int]]
            Open interest at the time.
        last_price : list[Optional[float]]
            Last trade price at the time.
        last_size : list[Optional[int]]
            Lot size of the last trade.
        last_timestamp : list[Optional[datetime]]
            Timestamp of the last price.
        open : list[Optional[float]]
            The open price.
        high : list[Optional[float]]
            The high price.
        low : list[Optional[float]]
            The low price.
        close : list[Optional[float]]
            The close price.
        bid : list[Optional[float]]
            The last bid price at the time. (provider: intrinio)
        bid_size : list[Optional[int]]
            The size of the last bid price. (provider: intrinio)
        bid_timestamp : list[Optional[datetime]]
            The timestamp of the last bid price. (provider: intrinio)
        ask : list[Optional[float]]
            The last ask price at the time. (provider: intrinio)
        ask_size : list[Optional[int]]
            The size of the last ask price. (provider: intrinio)
        ask_timestamp : list[Optional[datetime]]
            The timestamp of the last ask price. (provider: intrinio)
        total_bid_volume : list[Optional[int]]
            Total volume of bids. (provider: intrinio)
        bid_high : list[Optional[float]]
            The highest bid price. (provider: intrinio)
        bid_low : list[Optional[float]]
            The lowest bid price. (provider: intrinio)
        total_ask_volume : list[Optional[int]]
            Total volume of asks. (provider: intrinio)
        ask_high : list[Optional[float]]
            The highest ask price. (provider: intrinio)
        ask_low : list[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[
            Optional[str],
            OpenBBField(description="Symbol to get data for. (the underlying symbol)"),
        ] = None,
        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 the complete options chain for a ticker.

        Parameters
        ----------
        provider : str
            The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: intrinio.
        symbol : Optional[str]
            Symbol to get data for. (the underlying symbol)
        start_date : Optional[date]
            Start date of the data, in YYYY-MM-DD format. If no symbol is supplied, requests are only allowed for a single date. Use the start_date for the target date. Intrinio appears to have data beginning Feb/2022, but is unclear when it actually began. (provider: intrinio)
        end_date : Optional[date]
            End date of the data, in YYYY-MM-DD format. If a symbol is not supplied, do not include an end date. (provider: intrinio)
        trade_type : Optional[Literal['block', 'sweep', 'large']]
            The type of unusual activity to query for. (provider: intrinio)
        sentiment : Optional[Literal['bullish', 'bearish', 'neutral']]
            The sentiment type to query for. (provider: intrinio)
        min_value : Union[int, float, None]
            The inclusive minimum total value for the unusual activity. (provider: intrinio)
        max_value : Union[int, float, None]
            The inclusive maximum total value for the unusual activity. (provider: intrinio)
        limit : int
            The number of data entries to return. A typical day for all symbols will yield 50-80K records. The API will paginate at 1000 records. The high default limit (100K) is to be able to reliably capture the most days. The high absolute limit (1.25M) is to allow for outlier days. Queries at the absolute limit will take a long time, and might be unreliable. Apply filters to improve performance. (provider: intrinio)
        source : Literal['delayed', 'realtime']
            The source of the data. Either realtime or delayed. (provider: intrinio)

        Returns
        -------
        OBBject
            results : list[OptionsUnusual]
                Serializable results.
            provider : Optional[str]
                Provider name.
            warnings : Optional[list[Warning_]]
                list of warnings.
            chart : Optional[Chart]
                Chart object.
            extra : Dict[str, Any]
                Extra info.

        OptionsUnusual
        --------------
        underlying_symbol : Optional[str]
            Symbol representing the entity requested in the data. (the underlying symbol)
        contract_symbol : str
            Contract symbol for the option.
        trade_timestamp : Optional[datetime]
            The datetime of order placement. (provider: intrinio)
        trade_type : Optional[Literal['block', 'sweep', 'large']]
            The type of unusual trade. (provider: intrinio)
        sentiment : Optional[Literal['bullish', 'bearish', 'neutral']]
            Bullish, Bearish, or Neutral Sentiment is estimated based on whether the trade was executed at the bid, ask, or mark price. (provider: intrinio)
        bid_at_execution : Optional[float]
            Bid price at execution. (provider: intrinio)
        ask_at_execution : Optional[float]
            Ask price at execution. (provider: intrinio)
        average_price : Optional[float]
            The average premium paid per option contract. (provider: intrinio)
        underlying_price_at_execution : Optional[float]
            Price of the underlying security at execution of trade. (provider: intrinio)
        total_size : Optional[int]
            The total number of contracts involved in a single transaction. (provider: intrinio)
        total_value : Optional[Union[int, float]]
            The aggregated value of all option contract premiums included in the trade. (provider: intrinio)

        Examples
        --------
        >>> from openbb import obb
        >>> obb.derivatives.options.unusual(symbol='TSLA', provider='intrinio')
        >>> # Use the 'symbol' parameter to get the most recent activity for a specific symbol.
        >>> obb.derivatives.options.unusual(symbol='TSLA', provider='intrinio')
        """  # noqa: E501

        return self._run(
            "/derivatives/options/unusual",
            **filter_inputs(
                provider_choices={
                    "provider": self._get_provider(
                        provider,
                        "derivatives.options.unusual",
                        ("intrinio",),
                    )
                },
                standard_params={
                    "symbol": symbol,
                },
                extra_params=kwargs,
            )
        )