|
| 1 | +from polygon.rest.models.dividends import DividendType |
1 | 2 | from .base import BaseClient |
2 | 3 | from typing import Optional, Any, Dict, List, Union, Iterator |
3 | 4 | from .models import ( |
|
12 | 13 | AssetClass, |
13 | 14 | Locale, |
14 | 15 | Split, |
| 16 | + Dividend, |
| 17 | + Frequency, |
15 | 18 | ) |
16 | 19 | from urllib3 import HTTPResponse |
17 | 20 |
|
@@ -187,10 +190,10 @@ def list_splits( |
187 | 190 | ticker_gt: Optional[str] = None, |
188 | 191 | ticker_gte: Optional[str] = None, |
189 | 192 | execution_date: Optional[str] = None, |
190 | | - execution_lt: Optional[str] = None, |
191 | | - execution_lte: Optional[str] = None, |
192 | | - execution_gt: Optional[str] = None, |
193 | | - execution_gte: Optional[str] = None, |
| 193 | + execution_date_lt: Optional[str] = None, |
| 194 | + execution_date_lte: Optional[str] = None, |
| 195 | + execution_date_gt: Optional[str] = None, |
| 196 | + execution_date_gte: Optional[str] = None, |
194 | 197 | reverse_split: Optional[bool] = None, |
195 | 198 | limit: Optional[int] = None, |
196 | 199 | sort: Optional[Union[str, Sort]] = None, |
@@ -227,3 +230,92 @@ def list_splits( |
227 | 230 | raw=raw, |
228 | 231 | deserializer=Split.from_dict, |
229 | 232 | ) |
| 233 | + |
| 234 | + |
| 235 | +class DividendsClient(BaseClient): |
| 236 | + def list_dividends( |
| 237 | + self, |
| 238 | + ticker: Optional[str] = None, |
| 239 | + ticker_lt: Optional[str] = None, |
| 240 | + ticker_lte: Optional[str] = None, |
| 241 | + ticker_gt: Optional[str] = None, |
| 242 | + ticker_gte: Optional[str] = None, |
| 243 | + ex_dividend_date: Optional[str] = None, |
| 244 | + ex_dividend_date_lt: Optional[str] = None, |
| 245 | + ex_dividend_date_lte: Optional[str] = None, |
| 246 | + ex_dividend_date_gt: Optional[str] = None, |
| 247 | + ex_dividend_date_gte: Optional[str] = None, |
| 248 | + record_date: Optional[str] = None, |
| 249 | + record_date_lt: Optional[str] = None, |
| 250 | + record_date_lte: Optional[str] = None, |
| 251 | + record_date_gt: Optional[str] = None, |
| 252 | + record_date_gte: Optional[str] = None, |
| 253 | + declaration_date: Optional[str] = None, |
| 254 | + declaration_date_lt: Optional[str] = None, |
| 255 | + declaration_date_lte: Optional[str] = None, |
| 256 | + declaration_date_gt: Optional[str] = None, |
| 257 | + declaration_date_gte: Optional[str] = None, |
| 258 | + pay_date: Optional[str] = None, |
| 259 | + pay_date_lt: Optional[str] = None, |
| 260 | + pay_date_lte: Optional[str] = None, |
| 261 | + pay_date_gt: Optional[str] = None, |
| 262 | + pay_date_gte: Optional[str] = None, |
| 263 | + frequency: Optional[Frequency] = None, |
| 264 | + cash_amount: Optional[float] = None, |
| 265 | + cash_amount_lt: Optional[float] = None, |
| 266 | + cash_amount_lte: Optional[float] = None, |
| 267 | + cash_amount_gt: Optional[float] = None, |
| 268 | + cash_amount_gte: Optional[float] = None, |
| 269 | + dividend_type: Optional[DividendType] = None, |
| 270 | + limit: Optional[int] = None, |
| 271 | + sort: Optional[Union[str, Sort]] = None, |
| 272 | + order: Optional[Union[str, Order]] = None, |
| 273 | + params: Optional[Dict[str, Any]] = None, |
| 274 | + raw: bool = False, |
| 275 | + ) -> Union[Iterator[Dividend], HTTPResponse]: |
| 276 | + """ |
| 277 | + Get a list of historical cash dividends, including the ticker symbol, declaration date, ex-dividend date, record date, pay date, frequency, and amount. |
| 278 | +
|
| 279 | + :param ticker: Return the dividends that contain this ticker. |
| 280 | + :param ticker_lt: Ticker less than |
| 281 | + :param ticker_lte: Ticker less than or equal to |
| 282 | + :param ticker_gt: Ticker greater than |
| 283 | + :param ticker_gte: Ticker greater than or equal to |
| 284 | + :param ex_dividend_date: Query by ex-dividend date with the format YYYY-MM-DD. |
| 285 | + :param ex_dividend_date_lt: Ex-dividend date less than |
| 286 | + :param ex_dividend_date_lte: Ex-dividend date less than or equal to |
| 287 | + :param ex_dividend_date_gt: Ex-dividend date greater than |
| 288 | + :param ex_dividend_date_gte: Ex-dividend date greater than or equal to |
| 289 | + :param record_date: Query by record date with the format YYYY-MM-DD. |
| 290 | + :param record_date_lt: Record date less than |
| 291 | + :param record_date_lte: Record date less than or equal to |
| 292 | + :param record_date_gt: Record date greater than |
| 293 | + :param record_date_gte: Record date greater than or equal to |
| 294 | + :param declaration_date: Query by declaration date with the format YYYY-MM-DD. |
| 295 | + :param declaration_date_lt: Declaration date less than |
| 296 | + :param declaration_date_lte: Declaration date less than or equal to |
| 297 | + :param declaration_date_gt: Declaration date greater than |
| 298 | + :param declaration_date_gte: Declaration date greater than or equal to |
| 299 | + :param pay_date: Query by pay date with the format YYYY-MM-DD. |
| 300 | + :param pay_date_lt: Pay date less than |
| 301 | + :param pay_date_lte: Pay date less than or equal to |
| 302 | + :param pay_date_gt: Pay date greater than |
| 303 | + :param pay_date_gte: Pay date greater than or equal to |
| 304 | + :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). |
| 305 | + :param cash_amount: Query by the cash amount of the dividend. |
| 306 | + :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. |
| 307 | + :param limit: Limit the number of results returned, default is 10 and max is 1000. |
| 308 | + :param sort: Sort field used for ordering. |
| 309 | + :param order: Order results based on the sort field. |
| 310 | + :param params: Any additional query params |
| 311 | + :param raw: Return raw object instead of results object |
| 312 | + :return: List of dividends |
| 313 | + """ |
| 314 | + url = "/v3/reference/dividends" |
| 315 | + |
| 316 | + return self._paginate( |
| 317 | + path=url, |
| 318 | + params=self._get_params(self.list_dividends, locals()), |
| 319 | + raw=raw, |
| 320 | + deserializer=Dividend.from_dict, |
| 321 | + ) |
0 commit comments