alpaca-py-nopandas 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. alpaca/__init__.py +2 -0
  2. alpaca/broker/__init__.py +8 -0
  3. alpaca/broker/client.py +2360 -0
  4. alpaca/broker/enums.py +528 -0
  5. alpaca/broker/models/__init__.py +7 -0
  6. alpaca/broker/models/accounts.py +347 -0
  7. alpaca/broker/models/cip.py +265 -0
  8. alpaca/broker/models/documents.py +159 -0
  9. alpaca/broker/models/funding.py +114 -0
  10. alpaca/broker/models/journals.py +71 -0
  11. alpaca/broker/models/rebalancing.py +80 -0
  12. alpaca/broker/models/trading.py +13 -0
  13. alpaca/broker/requests.py +1135 -0
  14. alpaca/common/__init__.py +6 -0
  15. alpaca/common/constants.py +13 -0
  16. alpaca/common/enums.py +64 -0
  17. alpaca/common/exceptions.py +47 -0
  18. alpaca/common/models.py +21 -0
  19. alpaca/common/requests.py +82 -0
  20. alpaca/common/rest.py +438 -0
  21. alpaca/common/types.py +7 -0
  22. alpaca/common/utils.py +89 -0
  23. alpaca/data/__init__.py +5 -0
  24. alpaca/data/enums.py +184 -0
  25. alpaca/data/historical/__init__.py +13 -0
  26. alpaca/data/historical/corporate_actions.py +76 -0
  27. alpaca/data/historical/crypto.py +299 -0
  28. alpaca/data/historical/news.py +63 -0
  29. alpaca/data/historical/option.py +230 -0
  30. alpaca/data/historical/screener.py +72 -0
  31. alpaca/data/historical/stock.py +226 -0
  32. alpaca/data/historical/utils.py +30 -0
  33. alpaca/data/live/__init__.py +11 -0
  34. alpaca/data/live/crypto.py +168 -0
  35. alpaca/data/live/news.py +62 -0
  36. alpaca/data/live/option.py +88 -0
  37. alpaca/data/live/stock.py +199 -0
  38. alpaca/data/live/websocket.py +390 -0
  39. alpaca/data/mappings.py +84 -0
  40. alpaca/data/models/__init__.py +7 -0
  41. alpaca/data/models/bars.py +83 -0
  42. alpaca/data/models/base.py +45 -0
  43. alpaca/data/models/corporate_actions.py +309 -0
  44. alpaca/data/models/news.py +90 -0
  45. alpaca/data/models/orderbooks.py +59 -0
  46. alpaca/data/models/quotes.py +78 -0
  47. alpaca/data/models/screener.py +68 -0
  48. alpaca/data/models/snapshots.py +132 -0
  49. alpaca/data/models/trades.py +204 -0
  50. alpaca/data/requests.py +580 -0
  51. alpaca/data/timeframe.py +148 -0
  52. alpaca/py.typed +0 -0
  53. alpaca/trading/__init__.py +5 -0
  54. alpaca/trading/client.py +784 -0
  55. alpaca/trading/enums.py +412 -0
  56. alpaca/trading/models.py +697 -0
  57. alpaca/trading/requests.py +604 -0
  58. alpaca/trading/stream.py +225 -0
  59. alpaca_py_nopandas-0.1.0.dist-info/LICENSE +201 -0
  60. alpaca_py_nopandas-0.1.0.dist-info/METADATA +299 -0
  61. alpaca_py_nopandas-0.1.0.dist-info/RECORD +62 -0
  62. alpaca_py_nopandas-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,580 @@
1
+ from datetime import date, datetime
2
+ from typing import Any, List, Optional, Union
3
+
4
+ import pytz
5
+ from pydantic import ConfigDict
6
+
7
+ from alpaca.common.enums import Sort, SupportedCurrencies
8
+ from alpaca.common.requests import NonEmptyRequest
9
+ from alpaca.data.enums import (
10
+ Adjustment,
11
+ CorporateActionsType,
12
+ DataFeed,
13
+ MarketType,
14
+ MostActivesBy,
15
+ OptionsFeed,
16
+ )
17
+ from alpaca.data.timeframe import TimeFrame
18
+ from alpaca.trading.enums import ContractType
19
+
20
+
21
+ class BaseTimeseriesDataRequest(NonEmptyRequest):
22
+ """
23
+ A base class for requests for time series data between a start and an end. This shouldn't be
24
+ instantiated directly. Instead, you should use one of the data type specific classes.
25
+
26
+ Attributes:
27
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
28
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
29
+ end (Optional[datetime]): The end of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
30
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
31
+ currency (Optional[SupportedCurrencies]): The currency the data should be returned in. Default to USD.
32
+ sort: (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
33
+ """
34
+
35
+ symbol_or_symbols: Union[str, List[str]]
36
+ start: Optional[datetime] = None
37
+ end: Optional[datetime] = None
38
+ limit: Optional[int] = None
39
+ currency: Optional[SupportedCurrencies] = None # None = USD
40
+ sort: Optional[Sort] = None # None = asc
41
+
42
+ def __init__(self, **data: Any) -> None:
43
+ # convert timezone aware datetime to timezone naive UTC datetime
44
+ if (
45
+ "start" in data
46
+ and data["start"] is not None
47
+ and isinstance(data["start"], datetime)
48
+ and data["start"].tzinfo is not None
49
+ ):
50
+ data["start"] = data["start"].astimezone(pytz.utc).replace(tzinfo=None)
51
+
52
+ if (
53
+ "end" in data
54
+ and data["end"] is not None
55
+ and isinstance(data["end"], datetime)
56
+ and data["end"].tzinfo is not None
57
+ ):
58
+ data["end"] = data["end"].astimezone(pytz.utc).replace(tzinfo=None)
59
+
60
+ super().__init__(**data)
61
+
62
+
63
+ # ############################## Bars ################################# #
64
+
65
+
66
+ class BaseBarsRequest(BaseTimeseriesDataRequest):
67
+ """
68
+ A base request object for retrieving bar data for securities. You most likely should not use this directly and instead
69
+ use the asset class specific request objects.
70
+
71
+ Attributes:
72
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
73
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
74
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
75
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
76
+ timeframe (TimeFrame): The period over which the bars should be aggregated. (i.e. 5 Min bars, 1 Day bars)
77
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
78
+ """
79
+
80
+ timeframe: TimeFrame
81
+
82
+ # Allows TimeFrame as a non-pydantic BaseModel field
83
+ model_config = ConfigDict(arbitrary_types_allowed=True)
84
+
85
+
86
+ class StockBarsRequest(BaseBarsRequest):
87
+ """
88
+ The request model for retrieving bar data for equities.
89
+
90
+ See BaseBarsRequest for more information on available parameters.
91
+
92
+ Attributes:
93
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
94
+ timeframe (TimeFrame): The period over which the bars should be aggregated. (i.e. 5 Min bars, 1 Day bars)
95
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
96
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
97
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
98
+ adjustment (Optional[Adjustment]): The type of corporate action data normalization.
99
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
100
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
101
+ asof (Optional[str]): The asof date of the queried stock symbol(s) in YYYY-MM-DD format.
102
+ currency (Optional[SupportedCurrencies]): The currency of all prices in ISO 4217 format. Default is USD.
103
+ """
104
+
105
+ adjustment: Optional[Adjustment] = None
106
+ feed: Optional[DataFeed] = None
107
+ asof: Optional[str] = None
108
+
109
+
110
+ class CryptoBarsRequest(BaseBarsRequest):
111
+ """
112
+ The request model for retrieving bar data for cryptocurrencies.
113
+
114
+ See BaseBarsRequest for more information on available parameters.
115
+
116
+ Attributes:
117
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
118
+ timeframe (TimeFrame): The period over which the bars should be aggregated. (i.e. 5 Min bars, 1 Day bars)
119
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
120
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
121
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
122
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
123
+ """
124
+
125
+ pass
126
+
127
+
128
+ class OptionBarsRequest(BaseBarsRequest):
129
+ """
130
+ The request model for retrieving bar data for option contracts.
131
+
132
+ See BaseBarsRequest for more information on available parameters.
133
+
134
+ Attributes:
135
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
136
+ timeframe (TimeFrame): The length of time (also known as time interval) for which each Bar represents (i.e. 5 Min bars, 1 Day bars).
137
+ start (Optional[datetime]): The beginning of the time period for desired data. Timezone naive inputs assumed to be in UTC.
138
+ end (Optional[datetime]): The end of the time period for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
139
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
140
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
141
+ """
142
+
143
+
144
+ # ############################## Quotes ################################# #
145
+
146
+
147
+ class StockQuotesRequest(BaseTimeseriesDataRequest):
148
+ """
149
+ This request class is used to submit a request for stock quote data.
150
+
151
+ See BaseTimeseriesDataRequest for more information on available parameters.
152
+
153
+ Attributes:
154
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
155
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
156
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
157
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
158
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
159
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
160
+ asof (Optional[str]): The asof date of the queried stock symbol(s) in YYYY-MM-DD format.
161
+ currency (Optional[SupportedCurrencies]): The currency of all prices in ISO 4217 format. Default is USD.
162
+ """
163
+
164
+ feed: Optional[DataFeed] = None
165
+ asof: Optional[str] = None
166
+
167
+
168
+ class CryptoQuoteRequest(BaseTimeseriesDataRequest):
169
+ """
170
+ This request class is used to submit a request for crypto quote data.
171
+
172
+ See BaseTimeseriesDataRequest for more information on available parameters.
173
+
174
+ Attributes:
175
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
176
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
177
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
178
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
179
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
180
+
181
+ """
182
+
183
+ pass
184
+
185
+
186
+ # ############################## Trades ################################# #
187
+
188
+
189
+ class StockTradesRequest(BaseTimeseriesDataRequest):
190
+ """
191
+ This request class is used to submit a request for stock trade data.
192
+
193
+ See BaseTimeseriesDataRequest for more information on available parameters.
194
+
195
+ Attributes:
196
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
197
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
198
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
199
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
200
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
201
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
202
+ asof (Optional[str]): The asof date of the queried stock symbol(s) in YYYY-MM-DD format.
203
+ currency (Optional[SupportedCurrencies]): The currency of all prices in ISO 4217 format. Default is USD.
204
+ """
205
+
206
+ feed: Optional[DataFeed] = None
207
+ asof: Optional[str] = None
208
+
209
+
210
+ class CryptoTradesRequest(BaseTimeseriesDataRequest):
211
+ """
212
+ This request class is used to submit a request for crypto trade data.
213
+
214
+ See BaseTimeseriesDataRequest for more information on available parameters.
215
+
216
+ Attributes:
217
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
218
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
219
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
220
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
221
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
222
+ """
223
+
224
+ pass
225
+
226
+
227
+ class OptionTradesRequest(BaseTimeseriesDataRequest):
228
+ """
229
+ This request class is used to submit a request for option trade data.
230
+
231
+ See BaseTimeseriesDataRequest for more information on available parameters.
232
+
233
+ Attributes:
234
+ symbol_or_symbols (Union[str, List[str]]): The option identifier or list of option identifiers.
235
+ start (Optional[datetime]): The beginning of the time interval for desired data. Timezone naive inputs assumed to be in UTC.
236
+ end (Optional[datetime]): The end of the time interval for desired data. Defaults to now. Timezone naive inputs assumed to be in UTC.
237
+ limit (Optional[int]): Upper limit of number of data points to return. Defaults to None.
238
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
239
+ """
240
+
241
+ pass
242
+
243
+
244
+ # ############################## Latest Endpoints ################################# #
245
+
246
+
247
+ class BaseStockLatestDataRequest(NonEmptyRequest):
248
+ """
249
+ A base request object for retrieving the latest data for stocks. You most likely should not use this directly and
250
+ instead use the asset class specific request objects.
251
+
252
+ Attributes:
253
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
254
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
255
+ currency (Optional[SupportedCurrencies]): The currency the data should be returned in. Default to USD.
256
+ """
257
+
258
+ symbol_or_symbols: Union[str, List[str]]
259
+ feed: Optional[DataFeed] = None
260
+ currency: Optional[SupportedCurrencies] = None # None = USD
261
+
262
+
263
+ class StockLatestTradeRequest(BaseStockLatestDataRequest):
264
+ """
265
+ This request class is used to submit a request for the latest stock trade data.
266
+
267
+ See BaseStockLatestDataRequest for more information on available parameters.
268
+
269
+ Attributes:
270
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
271
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
272
+ currency (Optional[SupportedCurrencies]): The currency the data should be returned in. Default to USD.
273
+ """
274
+
275
+ pass
276
+
277
+
278
+ class StockLatestQuoteRequest(BaseStockLatestDataRequest):
279
+ """
280
+ This request class is used to submit a request for the latest stock quote data.
281
+
282
+ See BaseStockLatestDataRequest for more information on available parameters.
283
+
284
+ Attributes:
285
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
286
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
287
+ currency (Optional[SupportedCurrencies]): The currency the data should be returned in. Default to USD.
288
+ """
289
+
290
+ pass
291
+
292
+
293
+ class StockLatestBarRequest(BaseStockLatestDataRequest):
294
+ """
295
+ This request class is used to submit a request for the latest stock bar data.
296
+
297
+ See BaseStockLatestDataRequest for more information on available parameters.
298
+
299
+ Attributes:
300
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
301
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
302
+ currency (Optional[SupportedCurrencies]): The currency the data should be returned in. Default to USD.
303
+ """
304
+
305
+ pass
306
+
307
+
308
+ class BaseCryptoLatestDataRequest(NonEmptyRequest):
309
+ """
310
+ A base request object for retrieving the latest data for crypto. You most likely should not use this directly and
311
+ instead use the asset class specific request objects.
312
+
313
+ Attributes:
314
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
315
+ """
316
+
317
+ symbol_or_symbols: Union[str, List[str]]
318
+
319
+
320
+ class CryptoLatestTradeRequest(BaseCryptoLatestDataRequest):
321
+ """
322
+ This request class is used to submit a request for the latest crypto trade data.
323
+
324
+ See BaseCryptoLatestDataRequest for more information on available parameters.
325
+
326
+ Attributes:
327
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
328
+ """
329
+
330
+ pass
331
+
332
+
333
+ class CryptoLatestQuoteRequest(BaseCryptoLatestDataRequest):
334
+ """
335
+ This request class is used to submit a request for the latest crypto quote data.
336
+
337
+ See BaseCryptoLatestDataRequest for more information on available parameters.
338
+
339
+ Attributes:
340
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
341
+ """
342
+
343
+ pass
344
+
345
+
346
+ class CryptoLatestBarRequest(BaseCryptoLatestDataRequest):
347
+ """
348
+ This request class is used to submit a request for the latest crypto bar data.
349
+
350
+ See BaseCryptoLatestDataRequest for more information on available parameters.
351
+
352
+ Attributes:
353
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
354
+ """
355
+
356
+ pass
357
+
358
+
359
+ class BaseOptionLatestDataRequest(NonEmptyRequest):
360
+ """
361
+ A base request object for retrieving the latest data for options. You most likely should not use this directly and
362
+ instead use the asset class specific request objects.
363
+
364
+ Attributes:
365
+ symbol_or_symbols (Union[str, List[str]]): The option identifier or list of option identifiers.
366
+ feed (Optional[OptionsFeed]): The source feed of the data. `opra` or `indicative`. Default: `opra` if the user has the options subscription, `indicative` otherwise.
367
+ """
368
+
369
+ symbol_or_symbols: Union[str, List[str]]
370
+ feed: Optional[OptionsFeed] = None
371
+
372
+
373
+ class OptionLatestQuoteRequest(BaseOptionLatestDataRequest):
374
+ """
375
+ This request class is used to submit a request for the latest option quote data.
376
+
377
+ See BaseOptionLatestDataRequest for more information on available parameters.
378
+
379
+ Attributes:
380
+ symbol_or_symbols (Union[str, List[str]]): The option identifier or list of option identifiers.
381
+ feed (Optional[OptionsFeed]): The source feed of the data. `opra` or `indicative`. Default: `opra` if the user has the options subscription, `indicative` otherwise.
382
+ """
383
+
384
+ pass
385
+
386
+
387
+ class OptionLatestTradeRequest(BaseOptionLatestDataRequest):
388
+ """
389
+ This request class is used to submit a request for the latest option trade data.
390
+
391
+ See BaseOptionLatestDataRequest for more information on available parameters.
392
+
393
+ Attributes:
394
+ symbol_or_symbols (Union[str, List[str]]): The option identifier or list of option identifiers.
395
+ feed (Optional[OptionsFeed]): The source feed of the data. `opra` or `indicative`. Default: `opra` if the user has the options subscription, `indicative` otherwise.
396
+ """
397
+
398
+ pass
399
+
400
+
401
+ # ############################## Snapshots ################################# #
402
+
403
+
404
+ class StockSnapshotRequest(NonEmptyRequest):
405
+ """
406
+ This request class is used to submit a request for snapshot data for stocks.
407
+
408
+ Attributes:
409
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
410
+ feed (Optional[DataFeed]): The stock data feed to retrieve from.
411
+ currency (Optional[SupportedCurrencies]): The currency the data should be returned in. Default to USD.
412
+ """
413
+
414
+ symbol_or_symbols: Union[str, List[str]]
415
+ feed: Optional[DataFeed] = None
416
+ currency: Optional[SupportedCurrencies] = None # None = USD
417
+
418
+
419
+ class CryptoSnapshotRequest(NonEmptyRequest):
420
+ """
421
+ This request class is used to submit a request for snapshot data for crypto.
422
+
423
+ Attributes:
424
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
425
+ """
426
+
427
+ symbol_or_symbols: Union[str, List[str]]
428
+
429
+
430
+ class OptionSnapshotRequest(NonEmptyRequest):
431
+ """
432
+ This request class is used to submit a request for snapshot data for options.
433
+
434
+ Attributes:
435
+ symbol_or_symbols (Union[str, List[str]]): The option identifier or list of option identifiers.
436
+ feed (Optional[OptionsFeed]): The source feed of the data. `opra` or `indicative`. Default: `opra` if the user has the options subscription, `indicative` otherwise.
437
+ """
438
+
439
+ symbol_or_symbols: Union[str, List[str]]
440
+ feed: Optional[OptionsFeed] = None
441
+
442
+
443
+ class OptionChainRequest(NonEmptyRequest):
444
+ """
445
+ This request class is used to submit a request for option chain data for options.
446
+
447
+ Attributes:
448
+ underlying_symbol (str): The underlying_symbol for option contracts.
449
+ feed (Optional[OptionsFeed]): The source feed of the data. `opra` or `indicative`. Default: `opra` if the user has the options subscription, `indicative` otherwise.
450
+ type (Optional[ContractType]): Filter contracts by the type (call or put).
451
+ strike_price_gte (Optional[float]): Filter contracts with strike price greater than or equal to the specified value.
452
+ strike_price_lte (Optional[float]): Filter contracts with strike price less than or equal to the specified value.
453
+ expiration_date (Optional[Union[date, str]]): Filter contracts by the exact expiration date (format: YYYY-MM-DD).
454
+ expiration_date_gte (Optional[Union[date, str]]): Filter contracts with expiration date greater than or equal to the specified date.
455
+ expiration_date_lte (Optional[Union[date, str]]): Filter contracts with expiration date less than or equal to the specified date.
456
+ root_symbol (Optional[str]): Filter contracts by the root symbol.
457
+ updated_since (Optional[datetime]): Filter to snapshots that were updated since this timestamp.
458
+ """
459
+
460
+ underlying_symbol: str
461
+ feed: Optional[OptionsFeed] = None
462
+ type: Optional[ContractType] = None
463
+ strike_price_gte: Optional[float] = None
464
+ strike_price_lte: Optional[float] = None
465
+ expiration_date: Optional[Union[date, str]] = None
466
+ expiration_date_gte: Optional[Union[date, str]] = None
467
+ expiration_date_lte: Optional[Union[date, str]] = None
468
+ root_symbol: Optional[str] = None
469
+ updated_since: Optional[datetime] = None
470
+
471
+
472
+ # ############################## Orderbooks ################################# #
473
+
474
+
475
+ class CryptoLatestOrderbookRequest(NonEmptyRequest):
476
+ """
477
+ This request class is used to submit a request for latest orderbook data for crypto.
478
+
479
+ Attributes:
480
+ symbol_or_symbols (Union[str, List[str]]): The ticker identifier or list of ticker identifiers.
481
+ """
482
+
483
+ symbol_or_symbols: Union[str, List[str]]
484
+
485
+
486
+ # ############################## Screener #################################### #
487
+
488
+
489
+ class ScreenerRequest(NonEmptyRequest):
490
+ """
491
+ This request class is used to submit a request for screener endpoints.
492
+
493
+ Attributes:
494
+ top (int): Number of top most active stocks to fetch per day.
495
+ """
496
+
497
+ top: int = 10
498
+
499
+
500
+ class MostActivesRequest(ScreenerRequest):
501
+ """
502
+ This request class is used to submit a request for most actives screener endpoint.
503
+
504
+ Attributes:
505
+ by (MostActivesBy): The metric used for ranking the most active stocks.
506
+ top (int): Number of top most active stocks to fetch per day.
507
+ """
508
+
509
+ by: MostActivesBy = MostActivesBy.VOLUME.value
510
+
511
+
512
+ class MarketMoversRequest(ScreenerRequest):
513
+ """
514
+ This request class is used to submit a request for most actives screener endpoint.
515
+
516
+ Attributes:
517
+ market_type (MarketType): Screen specific market (stocks or crypto).
518
+ top (int): Number of top most active stocks to fetch per day.
519
+ """
520
+
521
+ market_type: MarketType = MarketType.STOCKS
522
+
523
+
524
+ # ############################## News #################################### #
525
+
526
+
527
+ class NewsRequest(NonEmptyRequest):
528
+ """
529
+ This request class is used to submit a request for most actives screener endpoint.
530
+
531
+ Attributes:
532
+ start (Optional[datetime]): The inclusive start of the interval. Format: RFC-3339 or YYYY-MM-DD.
533
+ If missing, the default value is the beginning of the current day.
534
+ end (Optional[datetime])): The inclusive end of the interval. Format: RFC-3339 or YYYY-MM-DD.
535
+ If missing, the default value is the current time.
536
+ sort (Optional[str]): Sort articles by updated date.
537
+ symbols (Optional[str]): The comma-separated list of symbols to query news for.
538
+ limit (Optional[int]): Limit of news items to be returned for given page.
539
+ include_content (Optional[bool]): Boolean indicator to include content for news articles (if available)
540
+ exclude_contentless (Optional[bool]): Boolean indicator to exclude news articles that do not contain content
541
+ page_token (Optional[str]): Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. This should not be used, pagination is handled automatically by the SDK.
542
+ """
543
+
544
+ start: Optional[datetime] = None
545
+ end: Optional[datetime] = None
546
+ sort: Optional[str] = None
547
+ symbols: Optional[str] = None
548
+ limit: Optional[int] = None
549
+ include_content: Optional[bool] = None
550
+ exclude_contentless: Optional[bool] = None
551
+ page_token: Optional[str] = None
552
+
553
+
554
+ # ############################## CorporateActions #################################### #
555
+
556
+
557
+ class CorporateActionsRequest(NonEmptyRequest):
558
+ """
559
+ This request class is used to submit a request for corporate actions data.
560
+ ref. https://docs.alpaca.markets/reference/corporateactions-1
561
+
562
+ Attributes:
563
+ symbols (Optional[List[str]]): The list of ticker identifiers.
564
+ cusips (Optional[List[str]]): The list of CUSIPs.
565
+ types (Optional[List[CorporateActionsType]]): The types of corporate actions to filter by. (default: all types)
566
+ start (Optional[date]): The inclusive start of the interval. Format: YYYY-MM-DD. (default: current day)
567
+ end (Optional[date])): The inclusive end of the interval. Format: YYYY-MM-DD. (default: current day)
568
+ ids (Optional[List[str]]): The list of corporate action IDs. This parameter is mutually exclusive with all other filters (symbols, types, start, end).
569
+ limit (Optional[int]): Upper limit of number of data points to return. (default: 1000)
570
+ sort (Optional[Sort]): The chronological order of response based on the timestamp. Defaults to ASC.
571
+ """
572
+
573
+ symbols: Optional[List[str]] = None
574
+ cusips: Optional[List[str]] = None
575
+ types: Optional[List[CorporateActionsType]] = None
576
+ start: Optional[date] = None
577
+ end: Optional[date] = None
578
+ ids: Optional[List[str]] = None
579
+ limit: Optional[int] = 1000
580
+ sort: Optional[Sort] = Sort.ASC