@usherlabs/cex-broker 0.2.49 → 0.2.51

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 (55) hide show
  1. package/dist/commands/cex-canonical-orderbook-export.js +7747 -883
  2. package/dist/commands/cex-canonical-orderbook-export.js.map +41 -10
  3. package/dist/commands/cli.js +127 -34
  4. package/dist/commands/market-data-vendor-backfill.js +8284 -6391
  5. package/dist/commands/market-data-vendor-backfill.js.map +16 -15
  6. package/dist/helpers/canonical-orderbook-export/parquet-projection.d.ts +19 -0
  7. package/dist/helpers/market-data-archive/canonical-orderbook.d.ts +1 -1
  8. package/dist/helpers/market-data-preparation/conformance-fixtures.d.ts +114 -2
  9. package/dist/helpers/market-data-preparation/contracts.d.ts +1298 -18
  10. package/dist/helpers/market-data-preparation/required-clock-qualification.d.ts +43 -0
  11. package/dist/helpers/market-data-preparation/source-tape-dependencies.d.ts +19 -0
  12. package/dist/helpers/market-data-preparation/source-tape-operation.d.ts +109 -0
  13. package/dist/helpers/market-data-source-forensics.d.ts +400 -0
  14. package/dist/helpers/market-data-vendor-backfill/conformance-fixtures.d.ts +3 -5
  15. package/dist/helpers/market-data-vendor-backfill/contracts.d.ts +21 -56
  16. package/dist/helpers/market-data-vendor-backfill/core.d.ts +1 -0
  17. package/dist/helpers/market-data-vendor-backfill/cryptohftdata.d.ts +45 -5
  18. package/dist/helpers/market-data-vendor-backfill/manifests.d.ts +31 -1083
  19. package/dist/helpers/market-data-vendor-backfill/promotion.d.ts +1 -0
  20. package/dist/helpers/source-tape-sandbox.d.ts +82 -0
  21. package/dist/helpers/source-tape.d.ts +165 -0
  22. package/dist/helpers/trace-context.d.ts +8 -0
  23. package/dist/index.js +128 -35
  24. package/dist/index.js.map +7 -6
  25. package/dist/market-data-preparation/fixtures/{conformance-v2.json → conformance-v3.json} +257 -60
  26. package/dist/market-data-preparation/policies/capability-policy.json +15 -4
  27. package/dist/market-data-preparation/policies/resource-policy.json +3 -3
  28. package/dist/market-data-preparation/policies/source-tape-capability-v1.json +35 -0
  29. package/dist/market-data-preparation/schema-manifest.json +30 -10
  30. package/dist/market-data-preparation/schemas/canonical-orderbook-export-request-v1.schema.json +5 -1
  31. package/dist/market-data-preparation/schemas/{canonical-orderbook-export-result-v1.schema.json → canonical-orderbook-export-result-v2.schema.json} +20 -6
  32. package/dist/market-data-preparation/schemas/order-book-depth-summary-parquet-projection-v1.schema.json +256 -0
  33. package/dist/market-data-preparation/schemas/order-book-levels-parquet-projection-v1.schema.json +220 -0
  34. package/dist/market-data-preparation/schemas/{preparation-product-pin-v1.schema.json → preparation-product-pin-v2.schema.json} +59 -9
  35. package/dist/market-data-preparation/schemas/promotion-receipt-v1.schema.json +5 -1
  36. package/dist/market-data-preparation/schemas/source-forensics-ledger-v1.schema.json +463 -0
  37. package/dist/market-data-preparation/schemas/source-qualification-record-v1.schema.json +394 -0
  38. package/dist/market-data-preparation.d.ts +7 -0
  39. package/dist/market-data-preparation.js +35443 -25203
  40. package/dist/market-data-preparation.js.map +118 -78
  41. package/dist/market-data-vendor-backfill.d.ts +8 -5
  42. package/dist/market-data-vendor-backfill.js +19444 -15553
  43. package/dist/market-data-vendor-backfill.js.map +65 -60
  44. package/package.json +1 -5
  45. package/dist/market-data-preparation/policies/capability-policy-v1.json +0 -28
  46. package/dist/market-data-vendor-backfill/fixtures/conformance-v1.json +0 -448
  47. package/dist/market-data-vendor-backfill/policies/capability-policy-v2.json +0 -28
  48. package/dist/market-data-vendor-backfill/policies/capability-policy.json +0 -28
  49. package/dist/market-data-vendor-backfill/policies/resource-policy.json +0 -16
  50. package/dist/market-data-vendor-backfill/schema-manifest.json +0 -31
  51. package/dist/market-data-vendor-backfill/schemas/archive-selection.schema.json +0 -224
  52. package/dist/market-data-vendor-backfill/schemas/promotion-receipt.schema.json +0 -171
  53. package/dist/market-data-vendor-backfill/schemas/request.schema.json +0 -166
  54. package/dist/market-data-vendor-backfill/schemas/required-clock.schema.json +0 -47
  55. package/dist/market-data-vendor-backfill/schemas/result.schema.json +0 -198
@@ -0,0 +1,463 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.usher.so/market-data-source-forensics-ledger/v1",
4
+ "title": "CEX market-data source-forensics ledger v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema_id",
9
+ "ledger_sha256",
10
+ "operation_kind",
11
+ "normalized_invocation_sha256",
12
+ "request_id",
13
+ "scope",
14
+ "window",
15
+ "effective_policies",
16
+ "provider_object_inventory",
17
+ "provider_objects",
18
+ "records",
19
+ "summary",
20
+ "limits",
21
+ "complete",
22
+ "incomplete_reason"
23
+ ],
24
+ "properties": {
25
+ "schema_id": {
26
+ "const": "https://schemas.usher.so/market-data-source-forensics-ledger/v1"
27
+ },
28
+ "ledger_sha256": { "$ref": "#/$defs/sha256" },
29
+ "operation_kind": {
30
+ "enum": ["required_clock_qualification", "source_tape"]
31
+ },
32
+ "normalized_invocation_sha256": { "$ref": "#/$defs/sha256" },
33
+ "request_id": { "$ref": "#/$defs/uuid" },
34
+ "scope": { "$ref": "#/$defs/scope" },
35
+ "window": { "$ref": "#/$defs/interval" },
36
+ "required_clock": { "$ref": "#/$defs/clock" },
37
+ "source_tape": { "$ref": "#/$defs/sourceTape" },
38
+ "effective_policies": { "$ref": "#/$defs/policies" },
39
+ "provider_object_inventory": { "$ref": "#/$defs/inventory" },
40
+ "provider_objects": {
41
+ "type": "array",
42
+ "items": { "$ref": "#/$defs/object" }
43
+ },
44
+ "records": {
45
+ "type": "array",
46
+ "maxItems": 100000,
47
+ "items": { "$ref": "#/$defs/record" }
48
+ },
49
+ "target_dispositions": {
50
+ "type": "array",
51
+ "maxItems": 100000,
52
+ "items": { "$ref": "#/$defs/disposition" }
53
+ },
54
+ "summary": { "type": "object" },
55
+ "limits": {
56
+ "type": "object",
57
+ "additionalProperties": false,
58
+ "required": ["max_records", "max_canonical_json_bytes"],
59
+ "properties": {
60
+ "max_records": { "const": 100000 },
61
+ "max_canonical_json_bytes": { "const": 67108864 }
62
+ }
63
+ },
64
+ "complete": { "type": "boolean" },
65
+ "incomplete_reason": {
66
+ "oneOf": [
67
+ { "type": "null" },
68
+ { "const": "forensics_evidence_bound_exceeded" }
69
+ ]
70
+ }
71
+ },
72
+ "oneOf": [
73
+ {
74
+ "properties": {
75
+ "operation_kind": { "const": "required_clock_qualification" },
76
+ "summary": { "$ref": "#/$defs/clockSummary" },
77
+ "required_clock": { "$ref": "#/$defs/clock" },
78
+ "target_dispositions": {
79
+ "type": "array",
80
+ "maxItems": 100000,
81
+ "items": { "$ref": "#/$defs/disposition" }
82
+ },
83
+ "source_tape": {}
84
+ },
85
+ "required": ["required_clock", "target_dispositions"],
86
+ "not": {
87
+ "properties": { "source_tape": {} },
88
+ "required": ["source_tape"]
89
+ }
90
+ },
91
+ {
92
+ "properties": {
93
+ "operation_kind": { "const": "source_tape" },
94
+ "summary": { "$ref": "#/$defs/recordSummary" },
95
+ "source_tape": { "$ref": "#/$defs/sourceTape" },
96
+ "required_clock": {},
97
+ "target_dispositions": {}
98
+ },
99
+ "required": ["source_tape"],
100
+ "not": {
101
+ "anyOf": [
102
+ {
103
+ "properties": { "required_clock": {} },
104
+ "required": ["required_clock"]
105
+ },
106
+ {
107
+ "properties": { "target_dispositions": {} },
108
+ "required": ["target_dispositions"]
109
+ }
110
+ ]
111
+ }
112
+ }
113
+ ],
114
+ "$defs": {
115
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
116
+ "uuid": {
117
+ "type": "string",
118
+ "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
119
+ },
120
+ "uint": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
121
+ "pin": {
122
+ "type": "object",
123
+ "additionalProperties": false,
124
+ "required": ["policy_id", "policy_sha256"],
125
+ "properties": {
126
+ "policy_id": { "type": "string", "minLength": 1, "maxLength": 256 },
127
+ "policy_sha256": { "$ref": "#/$defs/sha256" }
128
+ }
129
+ },
130
+ "scope": {
131
+ "type": "object",
132
+ "additionalProperties": false,
133
+ "required": ["exchange", "trading_pair", "market_type", "feed"],
134
+ "properties": {
135
+ "exchange": { "type": "string", "pattern": "^[a-z0-9_-]+$" },
136
+ "trading_pair": {
137
+ "type": "string",
138
+ "pattern": "^[A-Z0-9]+-[A-Z0-9]+$"
139
+ },
140
+ "market_type": { "enum": ["spot", "swap", "future"] },
141
+ "feed": { "const": "ORDERBOOK" }
142
+ }
143
+ },
144
+ "interval": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": ["start_time_ms", "end_time_ms_exclusive"],
148
+ "properties": {
149
+ "start_time_ms": { "$ref": "#/$defs/uint" },
150
+ "end_time_ms_exclusive": { "$ref": "#/$defs/uint" }
151
+ }
152
+ },
153
+ "clock": {
154
+ "type": "object",
155
+ "additionalProperties": false,
156
+ "required": ["clock_id", "clock_sha256", "event_count"],
157
+ "properties": {
158
+ "clock_id": { "$ref": "#/$defs/uuid" },
159
+ "clock_sha256": { "$ref": "#/$defs/sha256" },
160
+ "event_count": { "$ref": "#/$defs/uint" }
161
+ }
162
+ },
163
+ "sourceTape": {
164
+ "type": "object",
165
+ "additionalProperties": false,
166
+ "required": ["product_id", "product_version", "state_count"],
167
+ "properties": {
168
+ "product_id": { "const": "market-data-source-tape" },
169
+ "product_version": { "const": "market-data-source-tape/v1" },
170
+ "state_count": { "$ref": "#/$defs/uint" }
171
+ }
172
+ },
173
+ "policies": {
174
+ "type": "object",
175
+ "additionalProperties": false,
176
+ "required": [
177
+ "capability_policy",
178
+ "resource_policy",
179
+ "adapter_policy",
180
+ "acquisition_policy"
181
+ ],
182
+ "properties": {
183
+ "capability_policy": { "$ref": "#/$defs/pin" },
184
+ "resource_policy": { "$ref": "#/$defs/pin" },
185
+ "adapter_policy": { "$ref": "#/$defs/pin" },
186
+ "acquisition_policy": { "$ref": "#/$defs/pin" }
187
+ }
188
+ },
189
+ "inventory": {
190
+ "type": "object",
191
+ "additionalProperties": false,
192
+ "required": [
193
+ "expected_identities",
194
+ "observed_identities",
195
+ "expected_selected_intervals",
196
+ "observed_selected_intervals",
197
+ "complete"
198
+ ],
199
+ "properties": {
200
+ "expected_identities": {
201
+ "type": "array",
202
+ "maxItems": 10000,
203
+ "uniqueItems": true,
204
+ "items": { "type": "string", "minLength": 1, "maxLength": 1024 }
205
+ },
206
+ "observed_identities": {
207
+ "type": "array",
208
+ "maxItems": 10000,
209
+ "uniqueItems": true,
210
+ "items": { "type": "string", "minLength": 1, "maxLength": 1024 }
211
+ },
212
+ "expected_selected_intervals": {
213
+ "type": "array",
214
+ "maxItems": 10000,
215
+ "uniqueItems": true,
216
+ "items": { "$ref": "#/$defs/interval" }
217
+ },
218
+ "observed_selected_intervals": {
219
+ "type": "array",
220
+ "maxItems": 10000,
221
+ "uniqueItems": true,
222
+ "items": { "$ref": "#/$defs/interval" }
223
+ },
224
+ "complete": { "type": "boolean" }
225
+ }
226
+ },
227
+ "object": {
228
+ "type": "object",
229
+ "additionalProperties": false,
230
+ "required": ["identity", "checksums", "attempt_count", "quarantined"],
231
+ "properties": {
232
+ "identity": { "type": "string", "minLength": 1, "maxLength": 1024 },
233
+ "checksums": {
234
+ "type": "array",
235
+ "minItems": 1,
236
+ "uniqueItems": true,
237
+ "items": { "$ref": "#/$defs/sha256" }
238
+ },
239
+ "attempt_count": { "type": "integer", "minimum": 1, "maximum": 10 },
240
+ "quarantined": { "type": "boolean" }
241
+ }
242
+ },
243
+ "anchor": {
244
+ "type": "object",
245
+ "additionalProperties": false,
246
+ "required": [
247
+ "event_time_ms",
248
+ "sequence",
249
+ "object_identity",
250
+ "object_checksum"
251
+ ],
252
+ "properties": {
253
+ "event_time_ms": { "$ref": "#/$defs/uint" },
254
+ "sequence": { "type": "string", "pattern": "^[0-9]+$" },
255
+ "object_identity": {
256
+ "type": "string",
257
+ "minLength": 1,
258
+ "maxLength": 1024
259
+ },
260
+ "object_checksum": { "$ref": "#/$defs/sha256" }
261
+ }
262
+ },
263
+ "targetInterval": {
264
+ "type": "object",
265
+ "additionalProperties": false,
266
+ "required": [
267
+ "start_target_time_ms",
268
+ "end_target_time_ms_exclusive",
269
+ "target_count"
270
+ ],
271
+ "properties": {
272
+ "start_target_time_ms": { "$ref": "#/$defs/uint" },
273
+ "end_target_time_ms_exclusive": { "$ref": "#/$defs/uint" },
274
+ "target_count": { "$ref": "#/$defs/uint" }
275
+ }
276
+ },
277
+ "lagDistribution": {
278
+ "type": "object",
279
+ "additionalProperties": false,
280
+ "required": [
281
+ "lag_1000_ms",
282
+ "lag_2000_ms",
283
+ "lag_5000_ms",
284
+ "lag_10000_ms",
285
+ "lag_30000_ms",
286
+ "lag_60000_ms"
287
+ ],
288
+ "properties": {
289
+ "lag_1000_ms": { "$ref": "#/$defs/uint" },
290
+ "lag_2000_ms": { "$ref": "#/$defs/uint" },
291
+ "lag_5000_ms": { "$ref": "#/$defs/uint" },
292
+ "lag_10000_ms": { "$ref": "#/$defs/uint" },
293
+ "lag_30000_ms": { "$ref": "#/$defs/uint" },
294
+ "lag_60000_ms": { "$ref": "#/$defs/uint" }
295
+ }
296
+ },
297
+ "sequence": {
298
+ "type": "object",
299
+ "additionalProperties": false,
300
+ "required": [
301
+ "expected_previous",
302
+ "observed_previous",
303
+ "observed_final",
304
+ "event_time_ms"
305
+ ],
306
+ "properties": {
307
+ "expected_previous": { "type": "string", "pattern": "^[0-9]+$" },
308
+ "observed_previous": { "type": "string", "pattern": "^[0-9]+$" },
309
+ "observed_final": { "type": "string", "pattern": "^[0-9]+$" },
310
+ "event_time_ms": { "$ref": "#/$defs/uint" }
311
+ }
312
+ },
313
+ "record": {
314
+ "type": "object",
315
+ "additionalProperties": false,
316
+ "required": [
317
+ "record_sha256",
318
+ "kind",
319
+ "scope",
320
+ "provider_objects",
321
+ "previous_anchor",
322
+ "next_anchor",
323
+ "target_interval",
324
+ "lag_distribution",
325
+ "sequence",
326
+ "classification",
327
+ "adapter_version"
328
+ ],
329
+ "properties": {
330
+ "record_sha256": { "$ref": "#/$defs/sha256" },
331
+ "kind": {
332
+ "enum": [
333
+ "sequence_discontinuity",
334
+ "unanchored_target_interval",
335
+ "stale_target_interval",
336
+ "future_state_interval",
337
+ "provider_object_checksum_conflict"
338
+ ]
339
+ },
340
+ "scope": { "$ref": "#/$defs/scope" },
341
+ "provider_objects": {
342
+ "type": "array",
343
+ "items": { "$ref": "#/$defs/object" }
344
+ },
345
+ "previous_anchor": {
346
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/anchor" }]
347
+ },
348
+ "next_anchor": {
349
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/anchor" }]
350
+ },
351
+ "target_interval": {
352
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/targetInterval" }]
353
+ },
354
+ "lag_distribution": {
355
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/lagDistribution" }]
356
+ },
357
+ "sequence": {
358
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/sequence" }]
359
+ },
360
+ "classification": {
361
+ "oneOf": [
362
+ { "type": "null" },
363
+ {
364
+ "enum": [
365
+ "stable_object_corruption",
366
+ "mutable_provider_bytes",
367
+ "provider_row_loss",
368
+ "object_boundary_order_defect",
369
+ "valid_inactive_market_state",
370
+ "unresolved"
371
+ ]
372
+ }
373
+ ]
374
+ },
375
+ "adapter_version": {
376
+ "type": "string",
377
+ "minLength": 1,
378
+ "maxLength": 256
379
+ }
380
+ }
381
+ },
382
+ "disposition": {
383
+ "type": "object",
384
+ "additionalProperties": false,
385
+ "required": [
386
+ "target_id",
387
+ "target_time_ms",
388
+ "disposition",
389
+ "source_time_ms",
390
+ "asof_age_ms",
391
+ "record_sha256s"
392
+ ],
393
+ "properties": {
394
+ "target_id": { "$ref": "#/$defs/uuid" },
395
+ "target_time_ms": { "$ref": "#/$defs/uint" },
396
+ "disposition": {
397
+ "enum": [
398
+ "fresh_within_bound",
399
+ "valid_inactive_market_state",
400
+ "disqualifying"
401
+ ]
402
+ },
403
+ "source_time_ms": {
404
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/uint" }]
405
+ },
406
+ "asof_age_ms": {
407
+ "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/uint" }]
408
+ },
409
+ "record_sha256s": {
410
+ "type": "array",
411
+ "uniqueItems": true,
412
+ "items": { "$ref": "#/$defs/sha256" }
413
+ }
414
+ }
415
+ },
416
+ "recordSummary": {
417
+ "type": "object",
418
+ "additionalProperties": false,
419
+ "required": [
420
+ "retained_record_count",
421
+ "total_record_count",
422
+ "omitted_record_count",
423
+ "affected_target_count",
424
+ "unresolved_record_count"
425
+ ],
426
+ "properties": {
427
+ "retained_record_count": { "$ref": "#/$defs/uint" },
428
+ "total_record_count": { "$ref": "#/$defs/uint" },
429
+ "omitted_record_count": { "$ref": "#/$defs/uint" },
430
+ "affected_target_count": { "$ref": "#/$defs/uint" },
431
+ "unresolved_record_count": { "$ref": "#/$defs/uint" }
432
+ }
433
+ },
434
+ "clockSummary": {
435
+ "type": "object",
436
+ "additionalProperties": false,
437
+ "required": [
438
+ "retained_record_count",
439
+ "total_record_count",
440
+ "omitted_record_count",
441
+ "affected_target_count",
442
+ "unresolved_record_count",
443
+ "disposition_complete",
444
+ "fresh_target_count",
445
+ "inactive_target_count",
446
+ "disqualifying_target_count",
447
+ "omitted_target_disposition_count"
448
+ ],
449
+ "properties": {
450
+ "retained_record_count": { "$ref": "#/$defs/uint" },
451
+ "total_record_count": { "$ref": "#/$defs/uint" },
452
+ "omitted_record_count": { "$ref": "#/$defs/uint" },
453
+ "affected_target_count": { "$ref": "#/$defs/uint" },
454
+ "unresolved_record_count": { "$ref": "#/$defs/uint" },
455
+ "disposition_complete": { "type": "boolean" },
456
+ "fresh_target_count": { "$ref": "#/$defs/uint" },
457
+ "inactive_target_count": { "$ref": "#/$defs/uint" },
458
+ "disqualifying_target_count": { "$ref": "#/$defs/uint" },
459
+ "omitted_target_disposition_count": { "$ref": "#/$defs/uint" }
460
+ }
461
+ }
462
+ }
463
+ }