openqdata 0.3.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 (75) hide show
  1. openqdata/README.md +5 -0
  2. openqdata/__init__.py +15 -0
  3. openqdata/arbfree/README.md +5 -0
  4. openqdata/arbfree/__init__.py +9 -0
  5. openqdata/arbfree/arbfree.py +1494 -0
  6. openqdata/arbfree/sanos.py +316 -0
  7. openqdata/arbfree/sanos_tools.py +958 -0
  8. openqdata/arbfree/tridiag.py +85 -0
  9. openqdata/benchmark/README.md +5 -0
  10. openqdata/benchmark/__init__.py +4 -0
  11. openqdata/biz_calendar.py +506 -0
  12. openqdata/cli.py +91 -0
  13. openqdata/env.py +112 -0
  14. openqdata/fred/README.md +5 -0
  15. openqdata/fred/__init__.py +14 -0
  16. openqdata/fred/client.py +57 -0
  17. openqdata/fred/rates.py +162 -0
  18. openqdata/massive/README.md +5 -0
  19. openqdata/massive/__init__.py +15 -0
  20. openqdata/massive/client.py +1183 -0
  21. openqdata/massive/expiries.py +242 -0
  22. openqdata/massive/options/README.md +5 -0
  23. openqdata/massive/options/__init__.py +6 -0
  24. openqdata/massive/options/contracts.py +610 -0
  25. openqdata/massive/processing.py +447 -0
  26. openqdata/massive/testing/README.md +5 -0
  27. openqdata/massive/testing/__init__.py +8 -0
  28. openqdata/massive/testing/generate.py +61 -0
  29. openqdata/massive/testing/scope.py +8 -0
  30. openqdata/massive/tickers/README.md +5 -0
  31. openqdata/massive/tickers/__init__.py +5 -0
  32. openqdata/massive/tickers/basics.py +66 -0
  33. openqdata/massive/tickers/data.py +362 -0
  34. openqdata/massive/tickers/filtered_history.py +260 -0
  35. openqdata/massive/trade_conds.py +324 -0
  36. openqdata/models/README.md +5 -0
  37. openqdata/models/__init__.py +4 -0
  38. openqdata/pool.py +34 -0
  39. openqdata/tickers/README.md +5 -0
  40. openqdata/tickers/__init__.py +13 -0
  41. openqdata/tickers/ticker_calendar.py +370 -0
  42. openqdata/utils/README.md +3 -0
  43. openqdata/utils/__init__.py +35 -0
  44. openqdata/utils/cvxpy.py +47 -0
  45. openqdata/utils/pd.py +125 -0
  46. openqdata/utils/pl.py +114 -0
  47. openqdata/vixdata/README.md +5 -0
  48. openqdata/vixdata/__init__.py +6 -0
  49. openqdata/vixdata/cboe.py +119 -0
  50. openqdata/vixdata/client.py +44 -0
  51. openqdata/vixdata/formula.py +132 -0
  52. openqdata/widb/README.md +5 -0
  53. openqdata/widb/__init__.py +25 -0
  54. openqdata/widb/arbfree.py +581 -0
  55. openqdata/widb/bad.py +69 -0
  56. openqdata/widb/client.py +517 -0
  57. openqdata/widb/connection.py +72 -0
  58. openqdata/widb/day.py +1098 -0
  59. openqdata/widb/fitstats.py +328 -0
  60. openqdata/widb/options_filter.py +338 -0
  61. openqdata/widb/sanos.py +96 -0
  62. openqdata/widb/testing/README.md +5 -0
  63. openqdata/widb/testing/__init__.py +0 -0
  64. openqdata/widb/testing/generate.py +45 -0
  65. openqdata/widb/testing/scope.py +8 -0
  66. openqdata/widb/timeseries.py +434 -0
  67. openqdata/yahoo/README.md +5 -0
  68. openqdata/yahoo/__init__.py +8 -0
  69. openqdata/yahoo/client.py +229 -0
  70. openqdata-0.3.0.dist-info/METADATA +103 -0
  71. openqdata-0.3.0.dist-info/RECORD +75 -0
  72. openqdata-0.3.0.dist-info/WHEEL +5 -0
  73. openqdata-0.3.0.dist-info/licenses/LICENSE +131 -0
  74. openqdata-0.3.0.dist-info/licenses/NOTICE +1 -0
  75. openqdata-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,324 @@
1
+ """
2
+ openqdata.massive.trade_conds
3
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4
+
5
+ OPRA (options) and spot (stocks) trade condition codes and bitmask flags.
6
+
7
+ Sources:
8
+ - https://massive.com/glossary/trade-conditions
9
+ - https://massive.com/glossary/conditions-indicators
10
+
11
+ Design:
12
+ - Keep the vendor condition IDs as IntEnum values (as returned in `conditions`).
13
+ - Provide IntFlag bitmasks for fast filtering/joins (int32).
14
+ - pack_conditions raises on unknown codes so vendor schema changes are explicit.
15
+
16
+ Use the function :func:`filter_valid_trades` in :mod:`openqdata.massive.processing` to filter out bad trades based
17
+ :data:`NORMAL_TRADE_EXCLUDE_FLAGS`.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from enum import IntEnum, IntFlag
23
+ from typing import Iterable
24
+
25
+
26
+ class ConditionCode(IntEnum):
27
+ """
28
+ Massive condition IDs (stocks 0..60-ish, options 201..248).
29
+
30
+ See https://massive.com/glossary/trade-conditions and https://massive.com/glossary/conditions-indicators
31
+ """
32
+
33
+ # ---------------------------------------------------------------------
34
+ # Stocks trade conditions (per Massive Conditions & Indicators)
35
+ # ---------------------------------------------------------------------
36
+ REGULAR_SALE = 0
37
+ ACQUISITION = 1
38
+ AVERAGE_PRICE_TRADE = 2
39
+ STOCK_AUTOMATIC_EXECUTION = 3
40
+ BUNCHED_TRADE = 4
41
+ BUNCHED_SOLD_TRADE = 5
42
+ CAP_ELECTION = 6
43
+ CASH_SALE = 7
44
+ CLOSING_PRINTS = 8
45
+ CROSS_TRADE = 9
46
+ DERIVATIVELY_PRICED = 10
47
+ DISTRIBUTION = 11
48
+ FORM_T_EXTENDED_HOURS = 12
49
+ EXTENDED_HOURS_OOS = 13
50
+ STOCK_INTERMARKET_SWEEP = 14
51
+ MARKET_CENTER_OFFICIAL_CLOSE = 15
52
+ MARKET_CENTER_OFFICIAL_OPEN = 16
53
+ MARKET_CENTER_OPENING_TRADE = 17
54
+ MARKET_CENTER_REOPENING_TRADE = 18
55
+ MARKET_CENTER_CLOSING_TRADE = 19
56
+ NEXT_DAY = 20
57
+ PRICE_VARIATION_TRADE = 21
58
+ PRIOR_REFERENCE_PRICE = 22
59
+ RULE_155_AMEX = 23
60
+ RULE_127_NYSE = 24
61
+ OPENING_PRINTS = 25
62
+ OPENED = 26
63
+ STOPPED_STOCK_REGULAR = 27
64
+ REOPENING_PRINTS = 28
65
+ SELLER = 29
66
+ SOLD_LAST = 30
67
+ SOLD_OUT = 32
68
+ SOLD_OUT_OF_SEQUENCE = 33
69
+ SPLIT_TRADE = 34
70
+ STOCK_OPTION_TRADE = 35
71
+ YELLOW_FLAG_REGULAR = 36
72
+ ODD_LOT_TRADE = 37
73
+ CORRECTED_CONSOLIDATED_CLOSE = 38
74
+ UNKNOWN = 39
75
+ HELD_TRADES = 40
76
+ TRADE_THRU_EXEMPT = 41
77
+ NON_ELIGIBLE = 42
78
+ NON_ELIGIBLE_EXTENDED = 43
79
+ CANCELLED = 44
80
+ RECOVERY = 45
81
+ CORRECTION = 46
82
+ AS_OF = 47
83
+ AS_OF_CORRECTION = 48
84
+ AS_OF_CANCEL = 49
85
+ OOB = 50
86
+ SUMMARY = 51
87
+ CONTINGENT_TRADE = 52
88
+ QUALIFIED_CONTINGENT_TRADE = 53
89
+ ERRORED = 54
90
+ OPENING_REOPENING_TRADE_DETAIL = 55
91
+ PLACEHOLDER_E_TBD = 56
92
+ PLACEHOLDER_611_EXEMPT = 59
93
+ SSR_IN_EFFECT = 60
94
+
95
+ # ---------------------------------------------------------------------
96
+ # Options / OPRA-like trade conditions (Massive numeric IDs)
97
+ # ---------------------------------------------------------------------
98
+ CANCEL = 201
99
+ LATE_AND_OOS = 202
100
+ LAST_AND_CANCELED = 203
101
+ LATE = 204
102
+ OPENING_AND_CANCELED = 205
103
+ OPENING_LATE_AND_OOS = 206
104
+ ONLY_TRADE_AND_CANCELED = 207
105
+ OPENING_LATE = 208
106
+
107
+ AUTOMATIC_EXECUTION = 209
108
+ REOPENING_TRADE = 210
109
+ INTERMARKET_SWEEP = 219 # (options ISO)
110
+
111
+ SINGLE_LEG_AUCTION_NON_ISO = 227
112
+ SINGLE_LEG_AUCTION_ISO = 228
113
+ SINGLE_LEG_CROSS_NON_ISO = 229
114
+ SINGLE_LEG_CROSS_ISO = 230
115
+ SINGLE_LEG_FLOOR_TRADE = 231
116
+
117
+ MULTI_LEG_AUTO = 232
118
+ MULTI_LEG_AUCTION = 233
119
+ MULTI_LEG_CROSS = 234
120
+ MULTI_LEG_FLOOR_TRADE = 235
121
+ MULTI_LEG_AUTO_AGAINST_SINGLE_LEG = 236
122
+
123
+ STOCK_OPTIONS_AUCTION = 237
124
+ MULTI_LEG_AUCTION_AGAINST_SINGLE_LEG = 238
125
+ MULTI_LEG_FLOOR_TRADE_AGAINST_SINGLE_LEG = 239
126
+ STOCK_OPTIONS_AUTO = 240
127
+ STOCK_OPTIONS_CROSS = 241
128
+ STOCK_OPTIONS_FLOOR_TRADE = 242
129
+ STOCK_OPTIONS_AUTO_AGAINST_SINGLE_LEG = 243
130
+ STOCK_OPTIONS_AUCTION_AGAINST_SINGLE_LEG = 244
131
+ STOCK_OPTIONS_FLOOR_TRADE_AGAINST_SINGLE_LEG = 245
132
+
133
+ MULTI_LEG_FLOOR_PROPRIETARY_3PLUS = 246
134
+ MULTILATERAL_COMPRESSION_PROPRIETARY = 247
135
+ EXTENDED_HOURS_TRADE = 248
136
+
137
+
138
+ class ConditionFlag(IntFlag):
139
+ """Semantic bitmask (int32)."""
140
+ NONE = 0
141
+
142
+ # reporting / data-quality
143
+ LATE = 1 << 0
144
+ OUT_OF_SEQUENCE = 1 << 1
145
+ CANCELLED = 1 << 2
146
+ CORRECTION = 1 << 3
147
+ AS_OF = 1 << 4
148
+ ERRORED = 1 << 5
149
+
150
+ # execution style / structure
151
+ ELECTRONIC = 1 << 6
152
+ FLOOR = 1 << 7
153
+ ISO = 1 << 8
154
+ AUCTION = 1 << 9
155
+ CROSS = 1 << 10
156
+ COMPLEX = 1 << 11
157
+ STOCK_OPTION = 1 << 12
158
+
159
+ # session / special
160
+ EXTENDED_HOURS = 1 << 13
161
+ COMPRESSION = 1 << 14
162
+ PROPRIETARY_PRODUCT = 1 << 15
163
+
164
+ # stock-specific structure
165
+ ODD_LOT = 1 << 16
166
+
167
+ # stock “print types”
168
+ OPENING_PRINT = 1 << 17
169
+ CLOSING_PRINT = 1 << 18
170
+ OFFICIAL_OPEN = 1 << 19
171
+ OFFICIAL_CLOSE = 1 << 20
172
+
173
+ # misc stock flags
174
+ CONTINGENT = 1 << 21
175
+ QCT = 1 << 22
176
+ TRADE_THRU_EXEMPT = 1 << 23
177
+ SSR = 1 << 24
178
+
179
+ CODE_TO_FLAG: dict[ConditionCode, ConditionFlag] = {
180
+ # ---------------- options: cancel/late/sequence ----------------
181
+ ConditionCode.CANCEL: ConditionFlag.CANCELLED,
182
+ ConditionCode.LATE_AND_OOS: ConditionFlag.LATE | ConditionFlag.OUT_OF_SEQUENCE,
183
+ ConditionCode.LAST_AND_CANCELED: ConditionFlag.CANCELLED,
184
+ ConditionCode.LATE: ConditionFlag.LATE,
185
+ ConditionCode.OPENING_AND_CANCELED: ConditionFlag.CANCELLED,
186
+ ConditionCode.OPENING_LATE_AND_OOS: ConditionFlag.LATE | ConditionFlag.OUT_OF_SEQUENCE,
187
+ ConditionCode.ONLY_TRADE_AND_CANCELED: ConditionFlag.CANCELLED,
188
+ ConditionCode.OPENING_LATE: ConditionFlag.LATE,
189
+
190
+ # options: execution/informational
191
+ ConditionCode.AUTOMATIC_EXECUTION: ConditionFlag.ELECTRONIC,
192
+ ConditionCode.REOPENING_TRADE: ConditionFlag.NONE,
193
+ ConditionCode.INTERMARKET_SWEEP: ConditionFlag.ISO,
194
+
195
+ # options: single-leg mechanisms
196
+ ConditionCode.SINGLE_LEG_AUCTION_NON_ISO: ConditionFlag.AUCTION | ConditionFlag.ELECTRONIC,
197
+ ConditionCode.SINGLE_LEG_AUCTION_ISO: ConditionFlag.AUCTION | ConditionFlag.ELECTRONIC | ConditionFlag.ISO,
198
+ ConditionCode.SINGLE_LEG_CROSS_NON_ISO: ConditionFlag.CROSS | ConditionFlag.ELECTRONIC,
199
+ ConditionCode.SINGLE_LEG_CROSS_ISO: ConditionFlag.CROSS | ConditionFlag.ELECTRONIC | ConditionFlag.ISO,
200
+ ConditionCode.SINGLE_LEG_FLOOR_TRADE: ConditionFlag.FLOOR,
201
+
202
+ # options: complex / multi-leg
203
+ ConditionCode.MULTI_LEG_AUTO: ConditionFlag.COMPLEX | ConditionFlag.ELECTRONIC,
204
+ ConditionCode.MULTI_LEG_AUCTION: ConditionFlag.COMPLEX | ConditionFlag.AUCTION | ConditionFlag.ELECTRONIC,
205
+ ConditionCode.MULTI_LEG_CROSS: ConditionFlag.COMPLEX | ConditionFlag.CROSS | ConditionFlag.ELECTRONIC,
206
+ ConditionCode.MULTI_LEG_FLOOR_TRADE: ConditionFlag.COMPLEX | ConditionFlag.FLOOR,
207
+ ConditionCode.MULTI_LEG_AUTO_AGAINST_SINGLE_LEG: ConditionFlag.COMPLEX | ConditionFlag.ELECTRONIC,
208
+
209
+ # options: stock/options combo
210
+ ConditionCode.STOCK_OPTIONS_AUCTION: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.AUCTION | ConditionFlag.ELECTRONIC,
211
+ ConditionCode.MULTI_LEG_AUCTION_AGAINST_SINGLE_LEG: ConditionFlag.COMPLEX | ConditionFlag.AUCTION | ConditionFlag.ELECTRONIC,
212
+ ConditionCode.MULTI_LEG_FLOOR_TRADE_AGAINST_SINGLE_LEG: ConditionFlag.COMPLEX | ConditionFlag.FLOOR,
213
+ ConditionCode.STOCK_OPTIONS_AUTO: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.ELECTRONIC,
214
+ ConditionCode.STOCK_OPTIONS_CROSS: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.CROSS | ConditionFlag.ELECTRONIC,
215
+ ConditionCode.STOCK_OPTIONS_FLOOR_TRADE: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.FLOOR,
216
+ ConditionCode.STOCK_OPTIONS_AUTO_AGAINST_SINGLE_LEG: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.ELECTRONIC,
217
+ ConditionCode.STOCK_OPTIONS_AUCTION_AGAINST_SINGLE_LEG: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.AUCTION | ConditionFlag.ELECTRONIC,
218
+ ConditionCode.STOCK_OPTIONS_FLOOR_TRADE_AGAINST_SINGLE_LEG: ConditionFlag.STOCK_OPTION | ConditionFlag.COMPLEX | ConditionFlag.FLOOR,
219
+
220
+ # options: product-specific contracts / compression / extended hours
221
+ ConditionCode.MULTI_LEG_FLOOR_PROPRIETARY_3PLUS: ConditionFlag.PROPRIETARY_PRODUCT | ConditionFlag.COMPLEX | ConditionFlag.FLOOR,
222
+ ConditionCode.MULTILATERAL_COMPRESSION_PROPRIETARY: ConditionFlag.PROPRIETARY_PRODUCT | ConditionFlag.COMPRESSION,
223
+ ConditionCode.EXTENDED_HOURS_TRADE: ConditionFlag.EXTENDED_HOURS,
224
+
225
+ # ---------------- stocks: session/sequence ----------------
226
+ ConditionCode.FORM_T_EXTENDED_HOURS: ConditionFlag.EXTENDED_HOURS,
227
+ ConditionCode.EXTENDED_HOURS_OOS: ConditionFlag.EXTENDED_HOURS | ConditionFlag.OUT_OF_SEQUENCE,
228
+ ConditionCode.SOLD_OUT_OF_SEQUENCE: ConditionFlag.OUT_OF_SEQUENCE,
229
+ ConditionCode.SOLD_OUT: ConditionFlag.NONE, # semantic “sold out” marker; keep as NONE unless you need it
230
+
231
+ # stocks: mechanisms
232
+ ConditionCode.CROSS_TRADE: ConditionFlag.CROSS,
233
+ ConditionCode.STOCK_INTERMARKET_SWEEP: ConditionFlag.ISO,
234
+ ConditionCode.ODD_LOT_TRADE: ConditionFlag.ODD_LOT,
235
+ ConditionCode.STOCK_OPTION_TRADE: ConditionFlag.STOCK_OPTION,
236
+
237
+ # stocks: opening/closing prints + official open/close
238
+ ConditionCode.OPENING_PRINTS: ConditionFlag.OPENING_PRINT,
239
+ ConditionCode.MARKET_CENTER_OPENING_TRADE: ConditionFlag.OPENING_PRINT,
240
+ ConditionCode.MARKET_CENTER_REOPENING_TRADE: ConditionFlag.OPENING_PRINT,
241
+ ConditionCode.CLOSING_PRINTS: ConditionFlag.CLOSING_PRINT,
242
+ ConditionCode.MARKET_CENTER_CLOSING_TRADE: ConditionFlag.CLOSING_PRINT,
243
+ ConditionCode.MARKET_CENTER_OFFICIAL_OPEN: ConditionFlag.OFFICIAL_OPEN,
244
+ ConditionCode.MARKET_CENTER_OFFICIAL_CLOSE: ConditionFlag.OFFICIAL_CLOSE,
245
+ ConditionCode.CORRECTED_CONSOLIDATED_CLOSE: ConditionFlag.OFFICIAL_CLOSE | ConditionFlag.CORRECTION,
246
+
247
+ # stocks: corrections / as-of / errors
248
+ ConditionCode.CORRECTION: ConditionFlag.CORRECTION,
249
+ ConditionCode.AS_OF: ConditionFlag.AS_OF,
250
+ ConditionCode.AS_OF_CORRECTION: ConditionFlag.AS_OF | ConditionFlag.CORRECTION,
251
+ ConditionCode.AS_OF_CANCEL: ConditionFlag.AS_OF | ConditionFlag.CANCELLED,
252
+ ConditionCode.CANCELLED: ConditionFlag.CANCELLED,
253
+ ConditionCode.ERRORED: ConditionFlag.ERRORED,
254
+
255
+ # stocks: contingent / QCT / exemptions / SSR
256
+ ConditionCode.CONTINGENT_TRADE: ConditionFlag.CONTINGENT,
257
+ ConditionCode.QUALIFIED_CONTINGENT_TRADE: ConditionFlag.CONTINGENT | ConditionFlag.QCT,
258
+ ConditionCode.TRADE_THRU_EXEMPT: ConditionFlag.TRADE_THRU_EXEMPT,
259
+ ConditionCode.SSR_IN_EFFECT: ConditionFlag.SSR,
260
+ }
261
+ """ Map from detailed condition codes to unified flags """
262
+
263
+ BAD_TRADE_CONDITIONS = (
264
+ ConditionFlag.CANCELLED
265
+ | ConditionFlag.LATE
266
+ | ConditionFlag.OUT_OF_SEQUENCE
267
+ )
268
+ """ Bad trade conditions: cancelled, late reporting, or out-of-sequence. These are the most common data quality issues and are often filtered out in analyses. """
269
+
270
+ MICROSTRUCTURE_HARD_EXCLUDE = (
271
+ BAD_TRADE_CONDITIONS
272
+ | ConditionFlag.COMPRESSION
273
+ | ConditionFlag.CORRECTION
274
+ | ConditionFlag.AS_OF
275
+ | ConditionFlag.ERRORED
276
+ )
277
+ """
278
+ Microstructure conditions to exclude for clean trade/quote analysis.
279
+ These include bad trade conditions compression, corrections, as-of trades, and errored trades.
280
+
281
+ We do *not* exclude ``ConditionFlag.EXTENDED_HOURS`` here as extended hours trades can be exluded
282
+ easily later based on their time stamp, see :func:`filter_valid_trades` in :mod:`openqdata.massive.processing`.
283
+ """
284
+
285
+ NORMAL_TRADE_EXCLUDE_FLAGS = (
286
+ MICROSTRUCTURE_HARD_EXCLUDE # data quality issues (late, cancelled, corrections, etc.)
287
+ | ConditionFlag.CROSS # cross trades are reported separately, not normal market trades
288
+ | ConditionFlag.OPENING_PRINT # opening prints are special print conditions, not regular trades
289
+ | ConditionFlag.CLOSING_PRINT # closing prints are special print conditions, not regular trades
290
+ | ConditionFlag.OFFICIAL_OPEN # official open prices are reference/index, not actual trades
291
+ | ConditionFlag.OFFICIAL_CLOSE # official close prices are reference/index, not actual trades
292
+ | ConditionFlag.CONTINGENT # contingent trades are conditional, not unconditional normal trades
293
+ | ConditionFlag.QCT # qualified contingent trades are special conditions
294
+ | ConditionFlag.TRADE_THRU_EXEMPT # exemptions indicate special trade handling
295
+ )
296
+ """
297
+ Flags for normal trade filtering: these conditions are commonly excluded when filtering for regular market trades. This includes all microstructure hard excludes plus cross trades, opening/closing prints, official open/closes, and contingent trades.
298
+
299
+ Closing prints (condition IDs 8 and 19), official closes (15), and corrected
300
+ consolidated closes (38) are excluded, regardless of session-hours filtering.
301
+ ``filter_valid_trades`` and both trade/quote alignment functions apply this mask.
302
+ Raw ``MassiveClient.fetch_trades`` and session-only trade/bar builders do not.
303
+ We do not exclude ``ConditionFlag.ODD_LOT`` here.
304
+ """
305
+
306
+ def pack_conditions(codes: Iterable[int]) -> int:
307
+ """
308
+ Pack Massive/Polygon `conditions` (iterable of ints) into an int32 semantic mask.
309
+ Unknown codes raise ValueError.
310
+ """
311
+ flags = ConditionFlag.NONE
312
+ for c in codes:
313
+ try:
314
+ cc = ConditionCode(int(c))
315
+ except ValueError:
316
+ raise ValueError(f"Unknown trade condition code: {c}") from None
317
+ flags |= CODE_TO_FLAG.get(cc, ConditionFlag.NONE)
318
+ return int(flags)
319
+
320
+
321
+ if __name__ == "__main__":
322
+ from openqdata.cli import run_module
323
+
324
+ run_module(globals())
@@ -0,0 +1,5 @@
1
+ # openqdata.models
2
+
3
+ Namespace for separately installed model packages.
4
+
5
+ Documentation: [extensions.md](https://github.com/hansbuehler/openqdata/blob/main/docs/extensions.md)
@@ -0,0 +1,4 @@
1
+ """Shared namespace for separately installed openqdata model packages."""
2
+ from pkgutil import extend_path
3
+
4
+ __path__ = extend_path(__path__, __name__)
openqdata/pool.py ADDED
@@ -0,0 +1,34 @@
1
+ """
2
+ Pool configuration
3
+ ^^^^^^^^^^^^^^^^^^
4
+
5
+ Simple utilities to manage multi-processing workflows. Uses :class:`cdxcore.jcpool.JCPool` under the hood.
6
+ Use the ``PoolConfig`` class to allow users to configure their pools. The ``pool()`` member function generates
7
+ a unique pool per process.
8
+
9
+ The main purpose is to support functions which may use pools as different levels::
10
+
11
+ def f( ..., pool_config : PoolConfig = PoolConfig.off(), ...):
12
+ ...
13
+ pool = pool_config.pool()
14
+ ...
15
+
16
+ def g( ..., pool_config : PoolConfig = PoolConfig.off(), ...):
17
+ ...
18
+ results = f( ..., pool_config=pool_config, ... )
19
+ ...
20
+
21
+ pool = pool_config.pool()
22
+ ..
23
+
24
+ **Memory leak detection.** The aggressive memory leak enforcement of the worker pool (see
25
+ `joblib <https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html>`__) is switched off: it restarts
26
+ workers too often for long fits.
27
+ """
28
+
29
+ from __future__ import annotations
30
+
31
+ from cdxcore.jcpool import JCPool
32
+ from cdxcore.jcpool import JCPoolConfig as PoolConfig # noqa: F401 (public re-export)
33
+
34
+ JCPool.DEFAULT_MEM_LEAK_ENFORCE = False
@@ -0,0 +1,5 @@
1
+ # openqdata.tickers
2
+
3
+ Ticker calendars built from Massive and Yahoo: standard expiries, dividend and split flags, earnings dates.
4
+
5
+ Documentation: [connectors/index.md](https://github.com/hansbuehler/openqdata/blob/main/docs/connectors/index.md)
@@ -0,0 +1,13 @@
1
+ """
2
+ Ticker Data Module
3
+ ^^^^^^^^^^^^^^^^^^
4
+
5
+ This module contains ticker specific analytics which collect data from a number of data classes.
6
+ You may need access to different data source to be able to use some of the functions contained
7
+ in this sub-module.
8
+ """
9
+
10
+ from openqdata import env, version, SubDir, Context#NOQA
11
+
12
+ _locations_tickers = env.locations.processed("tickers")
13
+