|
25 | 25 | from webull.data.request.get_futures_products_request import GetFuturesProductsRequest |
26 | 26 | from webull.data.request.get_futures_instruments_by_code_request import GetFuturesInstrumentsByCodeRequest |
27 | 27 | from webull.data.request.get_futures_product_class import GetFuturesProductClassRequest |
| 28 | +from webull.data.request.get_option_contracts_request import GetOptionContractsRequest |
28 | 29 |
|
29 | 30 |
|
30 | 31 | class Instrument: |
@@ -218,6 +219,48 @@ def get_event_instrument(self, series_symbol, event_symbol=None, symbols=None, e |
218 | 219 | response = self.client.get_response(event_instrument_request) |
219 | 220 | return response |
220 | 221 |
|
| 222 | + def get_option_contracts(self, category=Category.US_OPTION.name, underlying_symbols=None, status=None, |
| 223 | + start_date=None, end_date=None, root_symbol=None, option_symbol=None, |
| 224 | + option_type=None, style=None, strike_price_gte=None, strike_price_lte=None, |
| 225 | + ppind=None, show_deliverables=None, page_size=10, last_instrument_id=None): |
| 226 | + """ |
| 227 | + Query option contracts list by conditions such as underlying_symbols, status, expiration date, etc. |
| 228 | +
|
| 229 | + :param category: Market category. Value: US_OPTION. |
| 230 | + :param underlying_symbols: Underlying symbol(s), comma-separated for multiple, e.g. AAPL,MSFT. |
| 231 | + :param status: Contract status: LISTING (default), DELISTING. |
| 232 | + :param start_date: Exact expiration date, format YYYY-MM-DD. |
| 233 | + :param end_date: Expiration date lower bound (inclusive), format YYYY-MM-DD. |
| 234 | + :param root_symbol: Root symbol filter (series symbol, e.g. SPXW), mainly for index options and non-standard contracts after CA. |
| 235 | + :param option_symbol: Option symbol, e.g. AAPL250620C00150000. |
| 236 | + :param option_type: Contract type: CALL / PUT. |
| 237 | + :param style: Exercise style: AMERICAN / EUROPEAN. |
| 238 | + :param strike_price_gte: Strike price lower bound (inclusive). |
| 239 | + :param strike_price_lte: Strike price upper bound (inclusive). |
| 240 | + :param ppind: Penny Program Indicator: true = Penny Pilot, false = non-Penny Pilot. |
| 241 | + :param show_deliverables: Whether to return deliverables array in response: true / false, default false. |
| 242 | + :param page_size: Page size, default 10, max 1000. |
| 243 | + :param last_instrument_id: Last instrument_id from previous page for pagination. |
| 244 | + """ |
| 245 | + request = GetOptionContractsRequest() |
| 246 | + request.set_category(category) |
| 247 | + request.set_underlying_symbols(underlying_symbols) |
| 248 | + request.set_status(status) |
| 249 | + request.set_start_date(start_date) |
| 250 | + request.set_end_date(end_date) |
| 251 | + request.set_root_symbol(root_symbol) |
| 252 | + request.set_option_symbol(option_symbol) |
| 253 | + request.set_option_type(option_type) |
| 254 | + request.set_style(style) |
| 255 | + request.set_strike_price_gte(strike_price_gte) |
| 256 | + request.set_strike_price_lte(strike_price_lte) |
| 257 | + request.set_ppind(ppind) |
| 258 | + request.set_show_deliverables(show_deliverables) |
| 259 | + request.set_page_size(page_size) |
| 260 | + request.set_last_instrument_id(last_instrument_id) |
| 261 | + response = self.client.get_response(request) |
| 262 | + return response |
| 263 | + |
221 | 264 | def get_company_profile(self, symbol, category=Category.US_STOCK.name): |
222 | 265 | """ |
223 | 266 | Get company profile for one instrument. |
|
0 commit comments