|
6 | 6 | from enum import unique |
7 | 7 | from typing import Callable, TypeVar |
8 | 8 |
|
9 | | -from databento_dbn import ImbalanceMsg |
10 | | -from databento_dbn import InstrumentDefMsg |
11 | | -from databento_dbn import MBOMsg |
12 | | -from databento_dbn import MBP1Msg |
13 | | -from databento_dbn import MBP10Msg |
14 | | -from databento_dbn import OHLCVMsg |
15 | | -from databento_dbn import StatMsg |
16 | | -from databento_dbn import TradeMsg |
17 | | - |
18 | | -from databento.live import DBNRecord |
19 | | - |
20 | 9 |
|
21 | 10 | M = TypeVar("M", bound=Enum) |
22 | 11 |
|
@@ -71,7 +60,7 @@ def _cast_str(value: object) -> str: |
71 | 60 |
|
72 | 61 | def coerced_new(enum: type[M], value: object) -> M: |
73 | 62 | if value is None: |
74 | | - raise TypeError( |
| 63 | + raise ValueError( |
75 | 64 | f"value `{value}` is not coercible to {enum_type.__name__}.", |
76 | 65 | ) |
77 | 66 | try: |
@@ -111,7 +100,6 @@ def __str__(self) -> str: |
111 | 100 | return getattr(self, "name").lower() |
112 | 101 | return getattr(self, "value") |
113 | 102 |
|
114 | | - |
115 | 103 | @unique |
116 | 104 | @coercible |
117 | 105 | class HistoricalGateway(StringyMixin, str, Enum): |
@@ -145,77 +133,6 @@ class Dataset(StringyMixin, str, Enum): |
145 | 133 | XNAS_ITCH = "XNAS.ITCH" |
146 | 134 |
|
147 | 135 |
|
148 | | -@unique |
149 | | -@coercible |
150 | | -class Schema(StringyMixin, str, Enum): |
151 | | - """ |
152 | | - Represents a data record schema. |
153 | | - """ |
154 | | - |
155 | | - MBO = "mbo" |
156 | | - MBP_1 = "mbp-1" |
157 | | - MBP_10 = "mbp-10" |
158 | | - TBBO = "tbbo" |
159 | | - TRADES = "trades" |
160 | | - OHLCV_1S = "ohlcv-1s" |
161 | | - OHLCV_1M = "ohlcv-1m" |
162 | | - OHLCV_1H = "ohlcv-1h" |
163 | | - OHLCV_1D = "ohlcv-1d" |
164 | | - DEFINITION = "definition" |
165 | | - IMBALANCE = "imbalance" |
166 | | - STATISTICS = "statistics" |
167 | | - |
168 | | - def get_record_type(self) -> type[DBNRecord]: |
169 | | - if self == Schema.MBO: |
170 | | - return MBOMsg |
171 | | - if self == Schema.MBP_1: |
172 | | - return MBP1Msg |
173 | | - if self == Schema.MBP_10: |
174 | | - return MBP10Msg |
175 | | - if self == Schema.TBBO: |
176 | | - return MBP1Msg |
177 | | - if self == Schema.TRADES: |
178 | | - return TradeMsg |
179 | | - if self == Schema.OHLCV_1S: |
180 | | - return OHLCVMsg |
181 | | - if self == Schema.OHLCV_1M: |
182 | | - return OHLCVMsg |
183 | | - if self == Schema.OHLCV_1H: |
184 | | - return OHLCVMsg |
185 | | - if self == Schema.OHLCV_1D: |
186 | | - return OHLCVMsg |
187 | | - if self == Schema.DEFINITION: |
188 | | - return InstrumentDefMsg |
189 | | - if self == Schema.IMBALANCE: |
190 | | - return ImbalanceMsg |
191 | | - if self == Schema.STATISTICS: |
192 | | - return StatMsg |
193 | | - raise NotImplementedError(f"No message type for {self}") |
194 | | - |
195 | | - |
196 | | -@unique |
197 | | -@coercible |
198 | | -class Encoding(StringyMixin, str, Enum): |
199 | | - """ |
200 | | - Represents a data output encoding. |
201 | | - """ |
202 | | - |
203 | | - DBN = "dbn" |
204 | | - CSV = "csv" |
205 | | - JSON = "json" |
206 | | - |
207 | | - |
208 | | -@unique |
209 | | -@coercible |
210 | | -class Compression(StringyMixin, str, Enum): |
211 | | - """ |
212 | | - Represents a data compression format (if any). |
213 | | - """ |
214 | | - |
215 | | - NONE = "none" |
216 | | - ZSTD = "zstd" |
217 | | - |
218 | | - |
219 | 136 | @unique |
220 | 137 | @coercible |
221 | 138 | class SplitDuration(StringyMixin, str, Enum): |
@@ -253,19 +170,6 @@ class Delivery(StringyMixin, str, Enum): |
253 | 170 | DISK = "disk" |
254 | 171 |
|
255 | 172 |
|
256 | | -@unique |
257 | | -@coercible |
258 | | -class SType(StringyMixin, str, Enum): |
259 | | - """ |
260 | | - Represents a symbology type. |
261 | | - """ |
262 | | - |
263 | | - INSTRUMENT_ID = "instrument_id" |
264 | | - RAW_SYMBOL = "raw_symbol" |
265 | | - PARENT = "parent" |
266 | | - CONTINUOUS = "continuous" |
267 | | - |
268 | | - |
269 | 173 | @unique |
270 | 174 | @coercible |
271 | 175 | class RollRule(StringyMixin, str, Enum): |
|
0 commit comments