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,148 @@
1
+ from enum import Enum
2
+
3
+
4
+ class classproperty(property):
5
+ """Allows us to create decorator of stacked classmethod and property decorators
6
+
7
+ Args:
8
+ property (property): the property decorator class
9
+ """
10
+
11
+ def __get__(self, cls, owner):
12
+ return classmethod(self.fget).__get__(None, owner)()
13
+
14
+
15
+ class TimeFrameUnit(str, Enum):
16
+ """Quantity of time used as unit"""
17
+
18
+ Minute: str = "Min"
19
+ Hour: str = "Hour"
20
+ Day: str = "Day"
21
+ Week: str = "Week"
22
+ Month: str = "Month"
23
+
24
+
25
+ class TimeFrame:
26
+ """A time interval specified in multiples of defined units (minute, day, etc)
27
+
28
+ Attributes:
29
+ amount_value (int): The number of multiples of the TimeFrameUnit interval
30
+ unit_value (TimeFrameUnit): The base unit of time interval that is used to measure the TimeFrame
31
+
32
+ Raises:
33
+ ValueError: Raised if the amount_value and unit_value are not consistent with each other
34
+ """
35
+
36
+ amount_value: int
37
+ unit_value: TimeFrameUnit
38
+
39
+ def __init__(self, amount: int, unit: TimeFrameUnit) -> None:
40
+ self.validate_timeframe(amount, unit)
41
+ self.amount_value = amount
42
+ self.unit_value = unit
43
+
44
+ @property
45
+ def amount(self) -> int:
46
+ """Returns the amount_value field
47
+
48
+ Returns:
49
+ int: amount_value field
50
+ """
51
+ return self.amount_value
52
+
53
+ @property
54
+ def unit(self) -> TimeFrameUnit:
55
+ """Returns the TimeFrameUnit field value of this TimeFrame object
56
+
57
+ Returns:
58
+ TimeFrameUnit: unit_value field
59
+ """
60
+ return self.unit_value
61
+
62
+ @property
63
+ def value(self) -> str:
64
+ """Returns a string representation of this TimeFrame object for API consumption
65
+
66
+ Returns:
67
+ str: string representation of this timeframe
68
+ """
69
+ return f"{self.amount}{self.unit.value}"
70
+
71
+ @staticmethod
72
+ def validate_timeframe(amount: int, unit: TimeFrameUnit):
73
+ """Validates the amount value against the TimeFrameUnit value for consistency
74
+
75
+ Args:
76
+ amount (int): The number of multiples of unit
77
+ unit (TimeFrameUnit): The base unit of time interval the TimeFrame is measured by
78
+
79
+ Raises:
80
+ ValueError: Raised if the values of amount and unit are not consistent with each other
81
+ """
82
+ if amount <= 0:
83
+ raise ValueError("Amount must be a positive integer value.")
84
+
85
+ if unit == TimeFrameUnit.Minute and amount > 59:
86
+ raise ValueError(
87
+ "Second or Minute units can only be "
88
+ + "used with amounts between 1-59."
89
+ )
90
+
91
+ if unit == TimeFrameUnit.Hour and amount > 23:
92
+ raise ValueError("Hour units can only be used with amounts 1-23")
93
+
94
+ if unit in (TimeFrameUnit.Day, TimeFrameUnit.Week) and amount != 1:
95
+ raise ValueError("Day and Week units can only be used with amount 1")
96
+
97
+ if unit == TimeFrameUnit.Month and amount not in (1, 2, 3, 6, 12):
98
+ raise ValueError(
99
+ "Month units can only be used with amount 1, 2, 3, 6 and 12"
100
+ )
101
+
102
+ def __str__(self):
103
+ return self.value
104
+
105
+ @classproperty
106
+ def Minute(cls):
107
+ """Helper method to quickly access a 1 minute timeframe
108
+
109
+ Returns:
110
+ TimeFrame: A 1-minute TimeFrame
111
+ """
112
+ return TimeFrame(amount=1, unit=TimeFrameUnit.Minute)
113
+
114
+ @classproperty
115
+ def Hour(cls):
116
+ """Helper method to quickly access a 1 hour timeframe
117
+
118
+ Returns:
119
+ TimeFrame: A 1-hour TimeFrame
120
+ """
121
+ return TimeFrame(amount=1, unit=TimeFrameUnit.Hour)
122
+
123
+ @classproperty
124
+ def Day(cls):
125
+ """Helper method to quickly access a 1 day timeframe
126
+
127
+ Returns:
128
+ TimeFrame: A 1-day TimeFrame
129
+ """
130
+ return TimeFrame(amount=1, unit=TimeFrameUnit.Day)
131
+
132
+ @classproperty
133
+ def Week(cls):
134
+ """Helper method to quickly access a 1 week timeframe
135
+
136
+ Returns:
137
+ TimeFrame: A 1-week TimeFrame
138
+ """
139
+ return TimeFrame(amount=1, unit=TimeFrameUnit.Week)
140
+
141
+ @classproperty
142
+ def Month(cls):
143
+ """Helper method to quickly access a 1 month timeframe
144
+
145
+ Returns:
146
+ TimeFrame: A 1-month TimeFrame
147
+ """
148
+ return TimeFrame(amount=1, unit=TimeFrameUnit.Month)
alpaca/py.typed ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ from alpaca.trading.client import *
2
+ from alpaca.trading.models import *
3
+ from alpaca.trading.enums import *
4
+ from alpaca.trading.requests import *
5
+ from alpaca.trading.stream import *