mxm-refdata 0.3.0__tar.gz → 0.5.0__tar.gz

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 (92) hide show
  1. mxm_refdata-0.5.0/PKG-INFO +398 -0
  2. mxm_refdata-0.5.0/README.md +369 -0
  3. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/pyproject.toml +15 -4
  4. mxm_refdata-0.5.0/src/mxm/refdata/__init__.py +12 -0
  5. mxm_refdata-0.5.0/src/mxm/refdata/cli.py +488 -0
  6. mxm_refdata-0.5.0/src/mxm/refdata/composition.py +92 -0
  7. mxm_refdata-0.5.0/src/mxm/refdata/diagnostics.py +414 -0
  8. mxm_refdata-0.5.0/src/mxm/refdata/generation/futures_contracts.py +169 -0
  9. mxm_refdata-0.5.0/src/mxm/refdata/generation/periods.py +436 -0
  10. mxm_refdata-0.5.0/src/mxm/refdata/materialisation.py +457 -0
  11. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/__init__.py +0 -8
  12. mxm_refdata-0.5.0/src/mxm/refdata/models/products/futures_product.py +103 -0
  13. mxm_refdata-0.5.0/src/mxm/refdata/models/units.py +60 -0
  14. mxm_refdata-0.5.0/src/mxm/refdata/preflight.py +111 -0
  15. mxm_refdata-0.5.0/src/mxm/refdata/reader.py +454 -0
  16. mxm_refdata-0.5.0/src/mxm/refdata/runtime.py +71 -0
  17. mxm_refdata-0.5.0/src/mxm/refdata/sources/futures_product.py +949 -0
  18. mxm_refdata-0.5.0/src/mxm/refdata/sql/__init__.py +0 -0
  19. mxm_refdata-0.5.0/src/mxm/refdata/sql/diagnostics.py +200 -0
  20. mxm_refdata-0.5.0/src/mxm/refdata/sql/futures_contracts.py +786 -0
  21. mxm_refdata-0.5.0/src/mxm/refdata/sql/futures_products.py +1615 -0
  22. mxm_refdata-0.5.0/src/mxm/refdata/sql/migration_runner.py +633 -0
  23. mxm_refdata-0.5.0/src/mxm/refdata/sql/migrations/000_bootstrap.sql +13 -0
  24. mxm_refdata-0.5.0/src/mxm/refdata/sql/migrations/001_initial_refdata.sql +288 -0
  25. mxm_refdata-0.5.0/src/mxm/refdata/sql/migrations/__init__.py +0 -0
  26. mxm_refdata-0.5.0/src/mxm/refdata/sql/period_cycles.py +864 -0
  27. mxm_refdata-0.5.0/src/mxm/refdata/sql/periods.py +476 -0
  28. mxm_refdata-0.5.0/src/mxm/refdata/sql/postgres.py +323 -0
  29. mxm_refdata-0.5.0/src/mxm/refdata/trading_calendars/__init__.py +0 -0
  30. mxm_refdata-0.5.0/src/mxm/refdata/trading_calendars/first_day_of_interest.py +113 -0
  31. mxm_refdata-0.5.0/src/mxm/refdata/trading_calendars/last_trading_day.py +108 -0
  32. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/trading_calendars/trading_calendar.py +50 -14
  33. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/utils/cache_manager.py +31 -1
  34. mxm_refdata-0.3.0/PKG-INFO +0 -228
  35. mxm_refdata-0.3.0/README.md +0 -202
  36. mxm_refdata-0.3.0/src/mxm/refdata/__init__.py +0 -1
  37. mxm_refdata-0.3.0/src/mxm/refdata/api/__init__.py +0 -1
  38. mxm_refdata-0.3.0/src/mxm/refdata/api/ref_data_api.py +0 -607
  39. mxm_refdata-0.3.0/src/mxm/refdata/cli.py +0 -218
  40. mxm_refdata-0.3.0/src/mxm/refdata/data/first_day_of_interest_rule.json +0 -88
  41. mxm_refdata-0.3.0/src/mxm/refdata/data/futures_products.csv +0 -6
  42. mxm_refdata-0.3.0/src/mxm/refdata/data/last_trading_rule.json +0 -34
  43. mxm_refdata-0.3.0/src/mxm/refdata/database/__init__.py +0 -1
  44. mxm_refdata-0.3.0/src/mxm/refdata/database/sql_session_manager.py +0 -135
  45. mxm_refdata-0.3.0/src/mxm/refdata/mappings/__init__.py +0 -31
  46. mxm_refdata-0.3.0/src/mxm/refdata/mappings/futures_contract_vs_orm.py +0 -51
  47. mxm_refdata-0.3.0/src/mxm/refdata/mappings/futures_product_vs_orm.py +0 -56
  48. mxm_refdata-0.3.0/src/mxm/refdata/mappings/period_cycles_vs_orm.py +0 -102
  49. mxm_refdata-0.3.0/src/mxm/refdata/mappings/period_vs_orm.py +0 -40
  50. mxm_refdata-0.3.0/src/mxm/refdata/models/orm/__init__.py +0 -16
  51. mxm_refdata-0.3.0/src/mxm/refdata/models/orm/base.py +0 -3
  52. mxm_refdata-0.3.0/src/mxm/refdata/models/orm/futures_contracts.py +0 -53
  53. mxm_refdata-0.3.0/src/mxm/refdata/models/orm/futures_products.py +0 -61
  54. mxm_refdata-0.3.0/src/mxm/refdata/models/orm/period_cycles.py +0 -84
  55. mxm_refdata-0.3.0/src/mxm/refdata/models/orm/periods.py +0 -30
  56. mxm_refdata-0.3.0/src/mxm/refdata/models/products/futures_product.py +0 -38
  57. mxm_refdata-0.3.0/src/mxm/refdata/models/units.py +0 -28
  58. mxm_refdata-0.3.0/src/mxm/refdata/parsing/__init__.py +0 -1
  59. mxm_refdata-0.3.0/src/mxm/refdata/parsing/futures_products_from_csv.py +0 -76
  60. mxm_refdata-0.3.0/src/mxm/refdata/scripts/__init__.py +0 -1
  61. mxm_refdata-0.3.0/src/mxm/refdata/scripts/db_utils.py +0 -61
  62. mxm_refdata-0.3.0/src/mxm/refdata/scripts/manage_static_ref_data.py +0 -73
  63. mxm_refdata-0.3.0/src/mxm/refdata/services/bootstrap.py +0 -84
  64. mxm_refdata-0.3.0/src/mxm/refdata/services/futures_contract_factory.py +0 -127
  65. mxm_refdata-0.3.0/src/mxm/refdata/services/futures_product_factory.py +0 -132
  66. mxm_refdata-0.3.0/src/mxm/refdata/services/period_factory.py +0 -315
  67. mxm_refdata-0.3.0/src/mxm/refdata/services/ref_data_service.py +0 -322
  68. mxm_refdata-0.3.0/src/mxm/refdata/services/smokecheck.py +0 -326
  69. mxm_refdata-0.3.0/src/mxm/refdata/trading_calendars/first_day_of_interest.py +0 -74
  70. mxm_refdata-0.3.0/src/mxm/refdata/trading_calendars/last_trading_day.py +0 -117
  71. mxm_refdata-0.3.0/src/mxm/refdata/utils/config.py +0 -32
  72. mxm_refdata-0.3.0/src/mxm/refdata/utils/resources.py +0 -29
  73. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/LICENSE +0 -0
  74. {mxm_refdata-0.3.0/src/mxm/refdata/models/contracts → mxm_refdata-0.5.0/src/mxm/refdata/generation}/__init__.py +0 -0
  75. {mxm_refdata-0.3.0/src/mxm/refdata/services → mxm_refdata-0.5.0/src/mxm/refdata/models/contracts}/__init__.py +0 -0
  76. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/contracts/futures_contract.py +0 -0
  77. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/currencies.py +0 -0
  78. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/months.py +0 -0
  79. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/period_cycles.py +0 -0
  80. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/periods.py +0 -0
  81. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/products/__init__.py +0 -0
  82. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/products/settlement.py +0 -0
  83. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/reference_events.py +0 -0
  84. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/models/weekdays.py +0 -0
  85. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/py.typed +0 -0
  86. {mxm_refdata-0.3.0/src/mxm/refdata/trading_calendars → mxm_refdata-0.5.0/src/mxm/refdata/sources}/__init__.py +0 -0
  87. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/trading_calendars/nth_business_day.py +0 -0
  88. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/trading_calendars/nth_calendar_day_of_period.py +0 -0
  89. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/trading_calendars/nth_weekday_of_period.py +0 -0
  90. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/utils/__init__.py +0 -0
  91. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/utils/period_types_codec.py +0 -0
  92. {mxm_refdata-0.3.0 → mxm_refdata-0.5.0}/src/mxm/refdata/utils/regex_patterns.py +0 -0
@@ -0,0 +1,398 @@
1
+ Metadata-Version: 2.4
2
+ Name: mxm-refdata
3
+ Version: 0.5.0
4
+ Summary: Canonical reference data for Money Ex Machina.
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Author: mxm
8
+ Author-email: contact@moneyexmachina.com
9
+ Requires-Python: >=3.13,<3.15
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: cachetools (>=7.1.1,<8.0.0)
15
+ Requires-Dist: exchange-calendars (>=4.11.1,<5.0.0)
16
+ Requires-Dist: mxm-config (>=0.6.2,<0.7)
17
+ Requires-Dist: mxm-runtime (>=0.1.2,<0.2)
18
+ Requires-Dist: mxm-types (>=0.3.1,<0.4)
19
+ Requires-Dist: pandas (>=2.3.3,<3.0.0)
20
+ Requires-Dist: psycopg[binary] (>=3.3.4,<4.0.0)
21
+ Requires-Dist: pydantic-settings (>=2.14.1,<3.0.0)
22
+ Requires-Dist: rich (>=15.0.0,<16.0.0)
23
+ Requires-Dist: typer (>=0.25.1,<0.26.0)
24
+ Project-URL: Homepage, https://github.com/moneyexmachina/mxm-refdata
25
+ Project-URL: Issues, https://github.com/moneyexmachina/mxm-refdata/issues
26
+ Project-URL: Repository, https://github.com/moneyexmachina/mxm-refdata
27
+ Description-Content-Type: text/markdown
28
+
29
+ # mxm-refdata
30
+
31
+ ![Version](https://img.shields.io/github/v/release/moneyexmachina/mxm-refdata)
32
+ ![License](https://img.shields.io/github/license/moneyexmachina/mxm-refdata)
33
+ ![Python](https://img.shields.io/badge/python-3.13+-blue)
34
+ [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
35
+
36
+ Reference-data generation, materialisation, and read access for the Money Ex Machina (MXM) ecosystem.
37
+
38
+ `mxm-refdata` defines deterministic futures products, contracts, periods, lifecycle dates, and trading-calendar relationships. It materialises the resulting operational reference state into PostgreSQL and exposes it through typed application and read-only interfaces.
39
+
40
+ It is intended to answer questions such as:
41
+
42
+ ```text
43
+ What futures products exist?
44
+
45
+ What contracts exist for a product?
46
+
47
+ When does a contract become active?
48
+
49
+ When is its last trading day?
50
+
51
+ Which contracts are active on a given date?
52
+
53
+ Which source specification produced this operational state?
54
+ ```
55
+
56
+ without depending on any market-data vendor.
57
+
58
+ For the full architectural specification, see [`docs/design.md`](docs/design.md).
59
+
60
+ ## Purpose
61
+
62
+ Reference data describes the identity and lifecycle of financial instruments.
63
+
64
+ For example:
65
+
66
+ ```text
67
+ cme_eurusd_futures.Mar-2032
68
+ ```
69
+
70
+ is deterministically derived from:
71
+
72
+ - a futures-product specification;
73
+ - period definitions;
74
+ - valid contract months;
75
+ - trading-calendar semantics;
76
+ - first-day-of-interest rules;
77
+ - last-trading-day rules.
78
+
79
+ Observed prices, quotes, trades, settlements, and vendor histories are separate concerns and belong in packages such as `mxm-marketdata`.
80
+
81
+ ## Architecture
82
+
83
+ The principal reference-data path is:
84
+
85
+ ```text
86
+ mxm-refdata-source
87
+
88
+ source adapter
89
+
90
+ FuturesProduct + provenance
91
+
92
+ deterministic generation
93
+
94
+ desired reference-data state
95
+
96
+ plain-SQL PostgreSQL materialisation
97
+
98
+ RefDataReader
99
+
100
+ downstream MXM applications
101
+ ```
102
+
103
+ Runtime construction is explicit:
104
+
105
+ ```text
106
+ RuntimeIdentity
107
+
108
+ RuntimeContext
109
+
110
+ composition
111
+
112
+ RefData
113
+ ```
114
+
115
+ ### Authoritative source
116
+
117
+ Curated futures-product specifications live in the Git-controlled `mxm-refdata-source` repository.
118
+
119
+ PostgreSQL stores the operational materialised state together with provenance such as source identity, digest, metadata, and source-repository revision.
120
+
121
+ The canonical source specification remains in `mxm-refdata-source`; it is not duplicated as a second canonical copy inside PostgreSQL.
122
+
123
+ ### Generation
124
+
125
+ Period and futures-contract generation is deterministic and stateless where practical.
126
+
127
+ Contract identity follows:
128
+
129
+ ```text
130
+ {product_id}.{period_id}
131
+ ```
132
+
133
+ for example:
134
+
135
+ ```text
136
+ cbot_10_year_us_treasury_note_futures.Dec-2046
137
+ ```
138
+
139
+ ### Application capabilities
140
+
141
+ `RefData` is the complete composed application capability. It exposes:
142
+
143
+ ```text
144
+ build()
145
+ rebuild()
146
+ diagnostics()
147
+ reader
148
+ ```
149
+
150
+ `RefDataReader` is the restricted read-only capability intended for downstream consumers.
151
+
152
+ ### Persistence
153
+
154
+ Operational structured reference data is stored in PostgreSQL using:
155
+
156
+ ```text
157
+ Psycopg 3
158
+ + explicit SQL
159
+ + version-controlled SQL migrations
160
+ ```
161
+
162
+ `mxm-refdata` owns the PostgreSQL schema:
163
+
164
+ ```text
165
+ refdata
166
+ ```
167
+
168
+ There is no SQLAlchemy ORM or SQLite persistence path in the accepted runtime architecture.
169
+
170
+ ## Materialisation lifecycle
171
+
172
+ Reference data is deterministic derived state.
173
+
174
+ ### Build
175
+
176
+ ```text
177
+ construct desired state
178
+ → migrate if required
179
+ → persist non-destructively
180
+ ```
181
+
182
+ Equivalent repeated builds are idempotent and do not create duplicate authoritative state.
183
+
184
+ ### Rebuild
185
+
186
+ ```text
187
+ construct desired state
188
+ → validate owned schema
189
+ → drop owned schema
190
+ → apply migrations
191
+ → rematerialise
192
+ ```
193
+
194
+ `rebuild` is intentionally destructive only within the owned reference-data schema.
195
+
196
+ Desired state is constructed before destructive reset.
197
+
198
+ ## CLI
199
+
200
+ The CLI operates through the resolved MXM runtime context. Database credentials, source roots, and operational configuration are not passed as ad hoc command-line overrides.
201
+
202
+ Check prerequisites:
203
+
204
+ ```bash
205
+ mxm-refdata preflight
206
+ ```
207
+
208
+ Materialise reference data non-destructively:
209
+
210
+ ```bash
211
+ mxm-refdata build
212
+ ```
213
+
214
+ Recreate the owned reference-data schema from deterministic source state:
215
+
216
+ ```bash
217
+ mxm-refdata rebuild
218
+ ```
219
+
220
+ Run operational readiness checks:
221
+
222
+ ```bash
223
+ mxm-refdata smokecheck
224
+ ```
225
+
226
+ Inspect the materialised universe:
227
+
228
+ ```bash
229
+ mxm-refdata products
230
+ mxm-refdata product cme_eurusd_futures
231
+ mxm-refdata contracts cme_eurusd_futures
232
+ mxm-refdata coverage
233
+ ```
234
+
235
+ Inspect active contracts using the supported `active` command:
236
+
237
+ ```bash
238
+ mxm-refdata active --help
239
+ ```
240
+
241
+ ## Python usage
242
+
243
+ Applications should obtain reference data through the normal MXM composition boundary.
244
+
245
+ Conceptually:
246
+
247
+ ```text
248
+ from mxm.refdata import RefData, build_refdata
249
+
250
+ refdata: RefData = build_refdata(ctx)
251
+ ```
252
+
253
+ Downstream code that needs read access only should depend on:
254
+
255
+ ```text
256
+ RefDataReader
257
+ ```
258
+
259
+ rather than constructing database or configuration dependencies independently.
260
+
261
+ The detailed application and composition boundaries are documented in [`docs/design.md`](docs/design.md).
262
+
263
+ ## Runtime configuration
264
+
265
+ Runtime configuration is resolved through the MXM runtime and configuration systems.
266
+
267
+ The composition root resolves:
268
+
269
+ - the `mxm_refdata` configuration view;
270
+ - the authoritative futures-product source root;
271
+ - the configured contract horizon;
272
+ - the `operational_state` PostgreSQL target;
273
+ - database credentials through the runtime secrets capability.
274
+
275
+ Lower application layers receive concrete resolved dependencies and do not resolve runtime secrets or deployment configuration themselves.
276
+
277
+ ## Current V1 operational scope
278
+
279
+ The current configured V1 deployment covers futures on:
280
+
281
+ ```text
282
+ CBOT
283
+ CME
284
+ COMEX
285
+ NYMEX
286
+ ```
287
+
288
+ The accepted V1 materialisation currently contains:
289
+
290
+ ```text
291
+ products: 86
292
+ product_sources: 86
293
+ periods: 799
294
+ contracts: 31,490
295
+ cycles: 2
296
+ memberships: 752
297
+ ```
298
+
299
+ The configured contract horizon is:
300
+
301
+ ```text
302
+ 2000–2046 inclusive
303
+ ```
304
+
305
+ These counts describe the currently accepted MXM V1 deployment rather than universal package constants.
306
+
307
+ ## Development
308
+
309
+ Install dependencies:
310
+
311
+ ```bash
312
+ poetry install
313
+ ```
314
+
315
+ Run the standard validation suite:
316
+
317
+ ```bash
318
+ make check
319
+ ```
320
+
321
+ This runs the tests that require neither PostgreSQL nor the private product-source repository.
322
+
323
+ ### PostgreSQL integration
324
+
325
+ On `monolith`:
326
+
327
+ ```bash
328
+ poetry run pytest -q -m postgres
329
+ ```
330
+
331
+ These tests use real PostgreSQL, disposable schemas, and synthetic public fixtures.
332
+
333
+ They verify:
334
+
335
+ - migrations;
336
+ - schema constraints;
337
+ - SQL adapters;
338
+ - materialisation;
339
+ - Reader behaviour;
340
+ - diagnostics;
341
+ - lifecycle semantics.
342
+
343
+ ### Private deployment acceptance
344
+
345
+ On `monolith`:
346
+
347
+ ```bash
348
+ poetry run pytest -q -m acceptance
349
+ ```
350
+
351
+ This uses the real MXM runtime, configuration, secrets, private `mxm-refdata-source`, and PostgreSQL target while materialising into a disposable acceptance schema.
352
+
353
+ It verifies the complete configured V1 universe independently from the operational `refdata` schema.
354
+
355
+ Repository compliance:
356
+
357
+ ```bash
358
+ mxm-foundry check .
359
+ ```
360
+
361
+ ## Package boundaries
362
+
363
+ `mxm-refdata` owns:
364
+
365
+ - reference-data domain models;
366
+ - futures-product source interpretation;
367
+ - deterministic period and contract generation;
368
+ - trading-calendar lifecycle calculations;
369
+ - PostgreSQL reference-data persistence;
370
+ - materialisation lifecycle;
371
+ - read semantics;
372
+ - readiness diagnostics;
373
+ - runtime composition;
374
+ - the reference-data CLI.
375
+
376
+ It does not own:
377
+
378
+ - market data;
379
+ - broker or exchange acquisition clients;
380
+ - portfolio construction;
381
+ - signals;
382
+ - risk;
383
+ - execution;
384
+ - workflow orchestration;
385
+ - the broader MXM operation-level provenance system.
386
+
387
+ See [`docs/design.md`](docs/design.md) for the detailed boundary definitions and design principles.
388
+
389
+ ## Documentation
390
+
391
+ - [`docs/design.md`](docs/design.md) — current architecture and design principles
392
+ - [`CHANGELOG.md`](CHANGELOG.md) — repository changes by release / unreleased state
393
+
394
+ ## License
395
+
396
+ MIT License. See `LICENSE`.
397
+
398
+