You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: polygon/rest/reference.py
+139-59
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@
19
19
DataType,
20
20
SIP,
21
21
Exchange,
22
+
OptionsContract,
22
23
)
23
24
fromurllib3importHTTPResponse
24
25
fromdatetimeimportdate
@@ -31,9 +32,9 @@ def get_market_holidays(
31
32
"""
32
33
Get upcoming market holidays and their open/close times.
33
34
34
-
:param params: Any additional query params
35
-
:param raw: Return HTTPResponse object instead of results object
36
-
:return: List of market holidays
35
+
:param params: Any additional query params.
36
+
:param raw: Return HTTPResponse object instead of results object.
37
+
:return: List of market holidays.
37
38
"""
38
39
url="/v1/marketstatus/upcoming"
39
40
@@ -51,9 +52,9 @@ def get_market_status(
51
52
"""
52
53
Get the current trading status of the exchanges and overall financial markets.
53
54
54
-
:param params: Any additional query params
55
-
:param raw: Return HTTPResponse object instead of results object
56
-
:return: Market status
55
+
:param params: Any additional query params.
56
+
:param raw: Return HTTPResponse object instead of results object.
57
+
:return: Market status.
57
58
"""
58
59
url="/v1/marketstatus/now"
59
60
@@ -88,10 +89,10 @@ def list_tickers(
88
89
Query all ticker symbols which are supported by Polygon.io. This API currently includes Stocks/Equities, Crypto, and Forex.
89
90
90
91
:param ticker: Specify a ticker symbol. Defaults to empty string which queries all tickers.
91
-
:param ticker_lt: Ticker less than
92
-
:param ticker_lte: Ticker less than or equal to
93
-
:param ticker_gt: Ticker greater than
94
-
:param ticker_gte: Ticker greater than or equal to
92
+
:param ticker_lt: Ticker less than.
93
+
:param ticker_lte: Ticker less than or equal to.
94
+
:param ticker_gt: Ticker greater than.
95
+
:param ticker_gte: Ticker greater than or equal to.
95
96
:param type: Specify the type of the tickers. Find the types that we support via our Ticker Types API. Defaults to empty string which queries all types.
96
97
:param market: Filter by market type. By default all markets are included.
97
98
:param exchange: Specify the primary exchange of the asset in the ISO code format. Find more information about the ISO codes at the ISO org website. Defaults to empty string which queries all exchanges.
@@ -103,9 +104,9 @@ def list_tickers(
103
104
:param limit: Limit the size of the response, default is 100 and max is 1000.
104
105
:param sort: The field to sort the results on. Default is ticker. If the search query parameter is present, sort is ignored and results are ordered by relevance.
105
106
:param order: The order to sort the results on. Default is asc (ascending).
106
-
:param params: Any additional query params
107
-
:param raw: Return raw object instead of results object
108
-
:return: List of tickers
107
+
:param params: Any additional query params.
108
+
:param raw: Return raw object instead of results object.
109
+
:return: List of tickers.
109
110
"""
110
111
url="/v3/reference/tickers"
111
112
@@ -168,9 +169,9 @@ def list_ticker_news(
168
169
:param limit: Limit the number of results returned, default is 10 and max is 1000.
169
170
:param sort: Sort field used for ordering.
170
171
:param order: Order results based on the sort field.
171
-
:param params: Any additional query params
172
-
:param raw: Return raw object instead of results object
173
-
:return: Ticker News
172
+
:param params: Any additional query params.
173
+
:param raw: Return raw object instead of results object.
174
+
:return: Ticker News.
174
175
"""
175
176
url="/v2/reference/news"
176
177
@@ -193,9 +194,9 @@ def get_ticker_types(
193
194
194
195
:param asset_class: Filter by asset class.
195
196
:param locale: Filter by locale.
196
-
:param params: Any additional query params
197
-
:param raw: Return raw object instead of results object
198
-
:return: Ticker Types
197
+
:param params: Any additional query params.
198
+
:param raw: Return raw object instead of results object.
199
+
:return: Ticker Types.
199
200
"""
200
201
url="/v3/reference/tickers/types"
201
202
@@ -232,22 +233,22 @@ def list_splits(
232
233
Get a list of historical stock splits, including the ticker symbol, the execution date, and the factors of the split ratio.
233
234
234
235
:param ticker: Return the stock splits that contain this ticker.
235
-
:param ticker_lt: Ticker less than
236
-
:param ticker_lte: Ticker less than or equal to
237
-
:param ticker_gt: Ticker greater than
238
-
:param ticker_gte: Ticker greater than or equal to
236
+
:param ticker_lt: Ticker less than.
237
+
:param ticker_lte: Ticker less than or equal to.
238
+
:param ticker_gt: Ticker greater than.
239
+
:param ticker_gte: Ticker greater than or equal to.
239
240
:param execution_date: Query by execution date with the format YYYY-MM-DD.
240
-
:param execution_date_lt: Execution date less than
241
-
:param execution_date_lte: Execution date less than or equal to
242
-
:param execution_date_gt: Execution date greater than
243
-
:param execution_date_gte: Execution date greater than or equal to
241
+
:param execution_date_lt: Execution date less than.
242
+
:param execution_date_lte: Execution date less than or equal to.
243
+
:param execution_date_gt: Execution date greater than.
244
+
:param execution_date_gte: Execution date greater than or equal to.
244
245
:param reverse_split: Query for reverse stock splits. A split ratio where split_from is greater than split_to represents a reverse split. By default this filter is not used.
245
246
:param limit: Limit the number of results returned, default is 10 and max is 1000.
246
247
:param sort: Sort field used for ordering.
247
248
:param order: Order results based on the sort field.
248
-
:param params: Any additional query params
249
-
:param raw: Return raw object instead of results object
250
-
:return: List of splits
249
+
:param params: Any additional query params.
250
+
:param raw: Return raw object instead of results object.
251
+
:return: List of splits.
251
252
"""
252
253
url="/v3/reference/splits"
253
254
@@ -304,39 +305,39 @@ def list_dividends(
304
305
Get a list of historical cash dividends, including the ticker symbol, declaration date, ex-dividend date, record date, pay date, frequency, and amount.
305
306
306
307
:param ticker: Return the dividends that contain this ticker.
307
-
:param ticker_lt: Ticker less than
308
-
:param ticker_lte: Ticker less than or equal to
309
-
:param ticker_gt: Ticker greater than
310
-
:param ticker_gte: Ticker greater than or equal to
308
+
:param ticker_lt: Ticker less than.
309
+
:param ticker_lte: Ticker less than or equal to.
310
+
:param ticker_gt: Ticker greater than.
311
+
:param ticker_gte: Ticker greater than or equal to.
311
312
:param ex_dividend_date: Query by ex-dividend date with the format YYYY-MM-DD.
312
-
:param ex_dividend_date_lt: Ex-dividend date less than
313
-
:param ex_dividend_date_lte: Ex-dividend date less than or equal to
314
-
:param ex_dividend_date_gt: Ex-dividend date greater than
315
-
:param ex_dividend_date_gte: Ex-dividend date greater than or equal to
313
+
:param ex_dividend_date_lt: Ex-dividend date less than.
314
+
:param ex_dividend_date_lte: Ex-dividend date less than or equal to.
315
+
:param ex_dividend_date_gt: Ex-dividend date greater than.
316
+
:param ex_dividend_date_gte: Ex-dividend date greater than or equal to.
316
317
:param record_date: Query by record date with the format YYYY-MM-DD.
317
-
:param record_date_lt: Record date less than
318
-
:param record_date_lte: Record date less than or equal to
319
-
:param record_date_gt: Record date greater than
320
-
:param record_date_gte: Record date greater than or equal to
318
+
:param record_date_lt: Record date less than.
319
+
:param record_date_lte: Record date less than or equal to.
320
+
:param record_date_gt: Record date greater than.
321
+
:param record_date_gte: Record date greater than or equal to.
321
322
:param declaration_date: Query by declaration date with the format YYYY-MM-DD.
322
-
:param declaration_date_lt: Declaration date less than
323
-
:param declaration_date_lte: Declaration date less than or equal to
324
-
:param declaration_date_gt: Declaration date greater than
325
-
:param declaration_date_gte: Declaration date greater than or equal to
323
+
:param declaration_date_lt: Declaration date less than.
324
+
:param declaration_date_lte: Declaration date less than or equal to.
325
+
:param declaration_date_gt: Declaration date greater than.
326
+
:param declaration_date_gte: Declaration date greater than or equal to.
326
327
:param pay_date: Query by pay date with the format YYYY-MM-DD.
327
-
:param pay_date_lt: Pay date less than
328
-
:param pay_date_lte: Pay date less than or equal to
329
-
:param pay_date_gt: Pay date greater than
330
-
:param pay_date_gte: Pay date greater than or equal to
328
+
:param pay_date_lt: Pay date less than.
329
+
:param pay_date_lte: Pay date less than or equal to.
330
+
:param pay_date_gt: Pay date greater than.
331
+
:param pay_date_gte: Pay date greater than or equal to.
331
332
:param frequency: Query by the number of times per year the dividend is paid out. Possible values are 0 (one-time), 1 (annually), 2 (bi-annually), 4 (quarterly), and 12 (monthly).
332
333
:param cash_amount: Query by the cash amount of the dividend.
333
334
:param dividend_type: Query by the type of dividend. Dividends that have been paid and/or are expected to be paid on consistent schedules are denoted as CD. Special Cash dividends that have been paid that are infrequent or unusual, and/or can not be expected to occur in the future are denoted as SC.
334
335
:param limit: Limit the number of results returned, default is 10 and max is 1000.
335
336
:param sort: Sort field used for ordering.
336
337
:param order: Order results based on the sort field.
337
-
:param params: Any additional query params
338
-
:param raw: Return raw object instead of results object
339
-
:return: List of dividends
338
+
:param params: Any additional query params.
339
+
:param raw: Return raw object instead of results object.
340
+
:return: List of dividends.
340
341
"""
341
342
url="/v3/reference/dividends"
342
343
@@ -371,9 +372,9 @@ def list_conditions(
371
372
:param limit: Limit the number of results returned, default is 10 and max is 1000.
372
373
:param sort: Sort field used for ordering.
373
374
:param order: Order results based on the sort field.
374
-
:param params: Any additional query params
375
-
:param raw: Return raw object instead of results object
376
-
:return: List of conditions
375
+
:param params: Any additional query params.
376
+
:param raw: Return raw object instead of results object.
377
+
:return: List of conditions.
377
378
"""
378
379
url="/v3/reference/conditions"
379
380
@@ -398,9 +399,9 @@ def get_exchanges(
398
399
399
400
:param asset_class: Filter by asset class.
400
401
:param locale: Filter by locale.
401
-
:param params: Any additional query params
402
-
:param raw: Return HTTPResponse object instead of results object
403
-
:return: List of exchanges
402
+
:param params: Any additional query params.
403
+
:param raw: Return HTTPResponse object instead of results object.
404
+
:return: List of exchanges.
404
405
"""
405
406
url="/v3/reference/exchanges"
406
407
@@ -411,3 +412,82 @@ def get_exchanges(
411
412
raw=raw,
412
413
result_key="results",
413
414
)
415
+
416
+
417
+
classContractsClient(BaseClient):
418
+
defget_options_contract(
419
+
self,
420
+
ticker: str,
421
+
as_of: Union[str, date] =None,
422
+
params: Optional[Dict[str, Any]] =None,
423
+
raw: bool=False,
424
+
) ->Union[OptionsContract, HTTPResponse]:
425
+
"""
426
+
Get the most recent trade for a ticker.
427
+
428
+
:param ticker: The ticker symbol of the asset
429
+
:param as_of: Specify a point in time for the contract as of this date with format YYYY-MM-DD.
430
+
:param params: Any additional query params.
431
+
:param raw: Return raw object instead of results object.
0 commit comments