@usherlabs/cex-broker 0.2.49 → 0.2.50
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.
- package/dist/commands/cex-canonical-orderbook-export.js +50 -16
- package/dist/commands/cex-canonical-orderbook-export.js.map +4 -4
- package/dist/commands/cli.js +124 -32
- package/dist/commands/market-data-vendor-backfill.js +74 -18
- package/dist/commands/market-data-vendor-backfill.js.map +7 -7
- package/dist/helpers/market-data-vendor-backfill/cryptohftdata.d.ts +1 -0
- package/dist/helpers/market-data-vendor-backfill/manifests.d.ts +31 -4
- package/dist/helpers/trace-context.d.ts +8 -0
- package/dist/index.js +125 -33
- package/dist/index.js.map +6 -5
- package/dist/market-data-preparation/fixtures/conformance-v2.json +7 -7
- package/dist/market-data-preparation/policies/capability-policy.json +12 -1
- package/dist/market-data-preparation/policies/resource-policy-v1.json +16 -0
- package/dist/market-data-preparation/policies/resource-policy.json +3 -3
- package/dist/market-data-preparation.js +45 -13
- package/dist/market-data-preparation.js.map +6 -6
- package/dist/market-data-vendor-backfill/policies/capability-policy-v2.json +12 -1
- package/dist/market-data-vendor-backfill/policies/resource-policy-v2.json +16 -0
- package/dist/market-data-vendor-backfill.d.ts +2 -2
- package/dist/market-data-vendor-backfill.js +74 -18
- package/dist/market-data-vendor-backfill.js.map +7 -7
- package/package.json +1 -1
|
@@ -22,7 +22,18 @@
|
|
|
22
22
|
"construction_modes": ["sampled_top_n_snapshot"],
|
|
23
23
|
"source_policies": ["authoritative_window", "fill_gaps"],
|
|
24
24
|
"max_depth": 400
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"exchange": "okx",
|
|
28
|
+
"market_type": "spot",
|
|
29
|
+
"feed": "ORDERBOOK",
|
|
30
|
+
"canonical_trading_pair": "ARB-USDC",
|
|
31
|
+
"provider_exchange_id": "okx_spot",
|
|
32
|
+
"resolved_symbol": "ARB-USDC",
|
|
33
|
+
"construction_modes": ["sampled_top_n_snapshot"],
|
|
34
|
+
"source_policies": ["authoritative_window", "fill_gaps"],
|
|
35
|
+
"max_depth": 400
|
|
25
36
|
}
|
|
26
37
|
],
|
|
27
|
-
"policy_sha256": "
|
|
38
|
+
"policy_sha256": "1dc3f918c6de98d4f65dc1439e16e8c8e0269b5eb9063e3617a52e457fdc24d1"
|
|
28
39
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"policy_id": "market-data-vendor-backfill-resources/v2",
|
|
3
|
+
"limits": {
|
|
4
|
+
"max_files": 10000,
|
|
5
|
+
"max_bytes": 107374182400,
|
|
6
|
+
"max_rows": 1000000000,
|
|
7
|
+
"max_duration_ms": 86400000,
|
|
8
|
+
"max_boundary_lookback_ms": 604800000
|
|
9
|
+
},
|
|
10
|
+
"request_bounds": {
|
|
11
|
+
"max_depth": 500,
|
|
12
|
+
"max_window_ms": 2678400000,
|
|
13
|
+
"max_required_events": 100000
|
|
14
|
+
},
|
|
15
|
+
"policy_sha256": "5c095c9af4450a0dd110cae04215b9188c6522ab16f4524a41b6122b154160a2"
|
|
16
|
+
}
|
|
@@ -7,12 +7,12 @@ export { ARCHIVE_SELECTION_SCHEMA_ID, archiveSelectionCodec, BACKFILL_REQUEST_SC
|
|
|
7
7
|
export type { ArchiveClusterIdentity, ArchivePreflightResolution, BackfillDependencies, BackfillDomainOutcome, CandidateVerification, ForwarderPreflightResolution, NormalizedBackfill, ProductionForwarderAuthorization, ProviderDataset, } from "./helpers/market-data-vendor-backfill/core";
|
|
8
8
|
export { createMarketDataVendorBackfillDependencies, runMarketDataVendorBackfill, } from "./helpers/market-data-vendor-backfill/core";
|
|
9
9
|
export type { CryptoHftDataCapabilityProfile, CryptoHftDataOrderBookRow, ReconstructedCryptoHftBook, } from "./helpers/market-data-vendor-backfill/cryptohftdata";
|
|
10
|
-
export { CRYPTOHFTDATA_ADAPTER_VERSION, CRYPTOHFTDATA_API_URL, CRYPTOHFTDATA_BINANCE_SPOT_BTCUSDT_PROFILE, CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE, CryptoHftDataAdapter, CryptoHftDataError, cryptoHftDataCapabilityFor, decodeCryptoHftParquetZstd, enumerateCryptoHftDataObjects, reconstructCryptoHftDataOrderBooks, } from "./helpers/market-data-vendor-backfill/cryptohftdata";
|
|
10
|
+
export { CRYPTOHFTDATA_ADAPTER_VERSION, CRYPTOHFTDATA_API_URL, CRYPTOHFTDATA_BINANCE_SPOT_BTCUSDT_PROFILE, CRYPTOHFTDATA_OKX_SPOT_ARBUSDC_PROFILE, CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE, CryptoHftDataAdapter, CryptoHftDataError, cryptoHftDataCapabilityFor, decodeCryptoHftParquetZstd, enumerateCryptoHftDataObjects, reconstructCryptoHftDataOrderBooks, } from "./helpers/market-data-vendor-backfill/cryptohftdata";
|
|
11
11
|
export type { ArchiveForwarderClient, ArchiveForwarderClientOptions, } from "./helpers/market-data-vendor-backfill/forwarder-client";
|
|
12
12
|
export { ArchiveForwarderSubmissionError, createArchiveForwarderClient, } from "./helpers/market-data-vendor-backfill/forwarder-client";
|
|
13
13
|
export type { JsonPrimitive, JsonValue, } from "./helpers/market-data-vendor-backfill/identity";
|
|
14
14
|
export { assertDocumentSha256, documentSha256, jcsCanonicalize, jcsSha256, withoutOwnDigest, } from "./helpers/market-data-vendor-backfill/identity";
|
|
15
15
|
export type { PolicyPin } from "./helpers/market-data-vendor-backfill/manifests";
|
|
16
|
-
export { ACQUISITION_POLICY_ID, ADAPTER_POLICY_ID, assertPolicyDocumentIdentity, CAPABILITY_POLICY, CAPABILITY_POLICY_ID, EFFECTIVE_ACQUISITION_POLICY_PIN, EFFECTIVE_ADAPTER_POLICY_PIN, RESOURCE_POLICY, RESOURCE_POLICY_ID, SCHEMA_ARTIFACTS, SCHEMA_MANIFEST, } from "./helpers/market-data-vendor-backfill/manifests";
|
|
16
|
+
export { ACQUISITION_POLICY_ID, ADAPTER_POLICY_ID, assertPolicyDocumentIdentity, CAPABILITY_POLICY, CAPABILITY_POLICY_ID, EFFECTIVE_ACQUISITION_POLICY_PIN, EFFECTIVE_ADAPTER_POLICY_PIN, LEGACY_RESOURCE_POLICY, LEGACY_RESOURCE_POLICY_ID, RESOURCE_POLICY, RESOURCE_POLICY_ID, SCHEMA_ARTIFACTS, SCHEMA_MANIFEST, } from "./helpers/market-data-vendor-backfill/manifests";
|
|
17
17
|
export type { ArchiveBundleEvidence, ArchiveQualificationEvidence, ArchiveSupportAnchorEvidence, } from "./helpers/market-data-vendor-backfill/selection";
|
|
18
18
|
export { archiveSelectionFromArchiveRow, archiveSelectionToArchiveRow, resolveArchiveSelection, } from "./helpers/market-data-vendor-backfill/selection";
|
|
@@ -11754,7 +11754,8 @@ var result_schema_default = {
|
|
|
11754
11754
|
// src/helpers/market-data-vendor-backfill/manifests.ts
|
|
11755
11755
|
var LEGACY_CAPABILITY_POLICY_ID = "market-data-vendor-backfill-capabilities/v1";
|
|
11756
11756
|
var CAPABILITY_POLICY_ID = "market-data-vendor-backfill-capabilities/v2";
|
|
11757
|
-
var
|
|
11757
|
+
var LEGACY_RESOURCE_POLICY_ID = "market-data-vendor-backfill-resources/v1";
|
|
11758
|
+
var RESOURCE_POLICY_ID = "market-data-vendor-backfill-resources/v2";
|
|
11758
11759
|
var ADAPTER_POLICY_ID = "cryptohftdata-orderbook-adapter/v1";
|
|
11759
11760
|
var ACQUISITION_POLICY_ID = "cryptohftdata-hourly-acquisition/v1";
|
|
11760
11761
|
var legacyCapabilityPolicyContent = {
|
|
@@ -11791,17 +11792,30 @@ var LEGACY_CAPABILITY_POLICY = Object.freeze({
|
|
|
11791
11792
|
var capabilityPolicyContent = {
|
|
11792
11793
|
...legacyCapabilityPolicyContent,
|
|
11793
11794
|
policy_id: CAPABILITY_POLICY_ID,
|
|
11794
|
-
profiles:
|
|
11795
|
-
...profile
|
|
11796
|
-
|
|
11797
|
-
|
|
11795
|
+
profiles: [
|
|
11796
|
+
...legacyCapabilityPolicyContent.profiles.map((profile) => ({
|
|
11797
|
+
...profile,
|
|
11798
|
+
source_policies: ["authoritative_window", "fill_gaps"]
|
|
11799
|
+
})),
|
|
11800
|
+
{
|
|
11801
|
+
exchange: "okx",
|
|
11802
|
+
market_type: "spot",
|
|
11803
|
+
feed: "ORDERBOOK",
|
|
11804
|
+
canonical_trading_pair: "ARB-USDC",
|
|
11805
|
+
provider_exchange_id: "okx_spot",
|
|
11806
|
+
resolved_symbol: "ARB-USDC",
|
|
11807
|
+
construction_modes: ["sampled_top_n_snapshot"],
|
|
11808
|
+
source_policies: ["authoritative_window", "fill_gaps"],
|
|
11809
|
+
max_depth: 400
|
|
11810
|
+
}
|
|
11811
|
+
]
|
|
11798
11812
|
};
|
|
11799
11813
|
var CAPABILITY_POLICY = Object.freeze({
|
|
11800
11814
|
...capabilityPolicyContent,
|
|
11801
11815
|
policy_sha256: jcsSha256(capabilityPolicyContent)
|
|
11802
11816
|
});
|
|
11803
|
-
var
|
|
11804
|
-
policy_id:
|
|
11817
|
+
var legacyResourcePolicyContent = {
|
|
11818
|
+
policy_id: LEGACY_RESOURCE_POLICY_ID,
|
|
11805
11819
|
limits: {
|
|
11806
11820
|
max_files: 1e4,
|
|
11807
11821
|
max_bytes: 100 * 1024 * 1024 * 1024,
|
|
@@ -11815,6 +11829,18 @@ var resourcePolicyContent = {
|
|
|
11815
11829
|
max_required_events: 1e5
|
|
11816
11830
|
}
|
|
11817
11831
|
};
|
|
11832
|
+
var LEGACY_RESOURCE_POLICY = Object.freeze({
|
|
11833
|
+
...legacyResourcePolicyContent,
|
|
11834
|
+
policy_sha256: jcsSha256(legacyResourcePolicyContent)
|
|
11835
|
+
});
|
|
11836
|
+
var resourcePolicyContent = {
|
|
11837
|
+
...legacyResourcePolicyContent,
|
|
11838
|
+
policy_id: RESOURCE_POLICY_ID,
|
|
11839
|
+
request_bounds: {
|
|
11840
|
+
...legacyResourcePolicyContent.request_bounds,
|
|
11841
|
+
max_window_ms: 31 * 24 * 60 * 60 * 1000
|
|
11842
|
+
}
|
|
11843
|
+
};
|
|
11818
11844
|
var RESOURCE_POLICY = Object.freeze({
|
|
11819
11845
|
...resourcePolicyContent,
|
|
11820
11846
|
policy_sha256: jcsSha256(resourcePolicyContent)
|
|
@@ -12009,7 +12035,11 @@ var backfillRequestCodec = {
|
|
|
12009
12035
|
CAPABILITY_POLICY,
|
|
12010
12036
|
LEGACY_CAPABILITY_POLICY
|
|
12011
12037
|
].some((policy) => request.product_pins.capability_policy.policy_id === policy.policy_id && request.product_pins.capability_policy.policy_sha256 === policy.policy_sha256);
|
|
12012
|
-
|
|
12038
|
+
const resourcePolicyMatches = [
|
|
12039
|
+
RESOURCE_POLICY,
|
|
12040
|
+
LEGACY_RESOURCE_POLICY
|
|
12041
|
+
].some((policy) => request.product_pins.resource_policy.policy_id === policy.policy_id && request.product_pins.resource_policy.policy_sha256 === policy.policy_sha256);
|
|
12042
|
+
if (!capabilityPolicyMatches || !resourcePolicyMatches) {
|
|
12013
12043
|
throw new Error("request policy pins do not match the effective package policies");
|
|
12014
12044
|
}
|
|
12015
12045
|
if (request.required_clock.clock_id !== request.initial_selection.required_clock.clock_id || request.required_clock.clock_sha256 !== request.initial_selection.required_clock.clock_sha256 || request.required_clock.event_count !== request.initial_selection.required_clock.event_count) {
|
|
@@ -12137,6 +12167,10 @@ function decodeBackfillRunDocuments(input) {
|
|
|
12137
12167
|
return targetTimeMs;
|
|
12138
12168
|
});
|
|
12139
12169
|
const capabilityProfile = CAPABILITY_POLICY.profiles.find((profile) => profile.exchange === wire.scope.exchange && profile.market_type === wire.scope.market_type && profile.feed === wire.scope.feed && profile.canonical_trading_pair === wire.scope.trading_pair);
|
|
12170
|
+
const resourcePolicy = [RESOURCE_POLICY, LEGACY_RESOURCE_POLICY].find((policy) => wire.product_pins.resource_policy.policy_id === policy.policy_id && wire.product_pins.resource_policy.policy_sha256 === policy.policy_sha256);
|
|
12171
|
+
if (!resourcePolicy) {
|
|
12172
|
+
throw new Error("request resource policy pin is unsupported");
|
|
12173
|
+
}
|
|
12140
12174
|
return {
|
|
12141
12175
|
schemaVersion: BACKFILL_REQUEST_SCHEMA_VERSION,
|
|
12142
12176
|
requestId: wire.request_id,
|
|
@@ -12161,11 +12195,11 @@ function decodeBackfillRunDocuments(input) {
|
|
|
12161
12195
|
maxPriorAsOfLagMs: wire.coverage_policy.max_asof_lag_ms,
|
|
12162
12196
|
sourcePolicy: wire.source_policy,
|
|
12163
12197
|
budgets: {
|
|
12164
|
-
maxFiles:
|
|
12165
|
-
maxBytes:
|
|
12166
|
-
maxRows:
|
|
12167
|
-
maxDurationMs:
|
|
12168
|
-
maxBoundaryLookbackMs: Math.min(
|
|
12198
|
+
maxFiles: resourcePolicy.limits.max_files,
|
|
12199
|
+
maxBytes: resourcePolicy.limits.max_bytes,
|
|
12200
|
+
maxRows: resourcePolicy.limits.max_rows,
|
|
12201
|
+
maxDurationMs: resourcePolicy.limits.max_duration_ms,
|
|
12202
|
+
maxBoundaryLookbackMs: Math.min(resourcePolicy.limits.max_boundary_lookback_ms, CAPABILITY_POLICY.acquisition_policy.initialization_lookback_ms)
|
|
12169
12203
|
},
|
|
12170
12204
|
expectedProduct: {
|
|
12171
12205
|
packageName: "@usherlabs/cex-broker",
|
|
@@ -13302,8 +13336,8 @@ var requestContent = {
|
|
|
13302
13336
|
policy_sha256: LEGACY_CAPABILITY_POLICY.policy_sha256
|
|
13303
13337
|
},
|
|
13304
13338
|
resource_policy: {
|
|
13305
|
-
policy_id:
|
|
13306
|
-
policy_sha256:
|
|
13339
|
+
policy_id: LEGACY_RESOURCE_POLICY.policy_id,
|
|
13340
|
+
policy_sha256: LEGACY_RESOURCE_POLICY.policy_sha256
|
|
13307
13341
|
}
|
|
13308
13342
|
},
|
|
13309
13343
|
production_authorization_id: authorizationId
|
|
@@ -13453,7 +13487,7 @@ var CONFORMANCE_FIXTURES = Object.freeze({
|
|
|
13453
13487
|
receipt_id: promotionReceipt.receipt_id,
|
|
13454
13488
|
result_sha256: result.result_sha256,
|
|
13455
13489
|
capability_policy_sha256: LEGACY_CAPABILITY_POLICY.policy_sha256,
|
|
13456
|
-
resource_policy_sha256:
|
|
13490
|
+
resource_policy_sha256: LEGACY_RESOURCE_POLICY.policy_sha256
|
|
13457
13491
|
},
|
|
13458
13492
|
jcs_edge_vector: jcsEdgeVector,
|
|
13459
13493
|
hashes: { jcs_edge_vector_sha256: jcsSha256(jcsEdgeVector) }
|
|
@@ -17460,6 +17494,22 @@ var CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE = Object.freeze({
|
|
|
17460
17494
|
constructionModes: ["sampled_top_n_snapshot"],
|
|
17461
17495
|
sourcePolicies: ["authoritative_window", "fill_gaps"]
|
|
17462
17496
|
});
|
|
17497
|
+
var CRYPTOHFTDATA_OKX_SPOT_ARBUSDC_PROFILE = Object.freeze({
|
|
17498
|
+
profileId: "cryptohftdata/okx_spot/ARB-USDC/v1",
|
|
17499
|
+
exchange: "okx",
|
|
17500
|
+
tradingPair: "ARB-USDC",
|
|
17501
|
+
sourceSymbol: "ARB-USDC",
|
|
17502
|
+
marketType: "spot",
|
|
17503
|
+
providerExchangeId: "okx_spot",
|
|
17504
|
+
historyStartMs: CRYPTOHFTDATA_HISTORY_START_MS,
|
|
17505
|
+
maxDepth: 400,
|
|
17506
|
+
eventTimeUnit: "milliseconds",
|
|
17507
|
+
receivedTimeUnit: "nanoseconds",
|
|
17508
|
+
snapshotGrouping: "event_time_final_update_id_object",
|
|
17509
|
+
sequenceSemantics: "okx_seq_id_prev_seq_id",
|
|
17510
|
+
constructionModes: ["sampled_top_n_snapshot"],
|
|
17511
|
+
sourcePolicies: ["authoritative_window", "fill_gaps"]
|
|
17512
|
+
});
|
|
17463
17513
|
|
|
17464
17514
|
class CryptoHftDataError extends Error {
|
|
17465
17515
|
reason;
|
|
@@ -18234,7 +18284,10 @@ function assertForwarderPreflight(request2, resolution, nowMs) {
|
|
|
18234
18284
|
}
|
|
18235
18285
|
}
|
|
18236
18286
|
function resourcePolicyScopeExceeded(request2) {
|
|
18237
|
-
|
|
18287
|
+
const policy = [RESOURCE_POLICY, LEGACY_RESOURCE_POLICY].find((candidate) => request2.productPins?.resource_policy.policy_id === candidate.policy_id && request2.productPins.resource_policy.policy_sha256 === candidate.policy_sha256);
|
|
18288
|
+
if (!policy)
|
|
18289
|
+
return true;
|
|
18290
|
+
return request2.depth > policy.request_bounds.max_depth || request2.window.endTimeMs - request2.window.startTimeMs > policy.request_bounds.max_window_ms || request2.requiredClockTargetsMs.length > policy.request_bounds.max_required_events;
|
|
18238
18291
|
}
|
|
18239
18292
|
function storedReceiptForSelection(resolution) {
|
|
18240
18293
|
const receiptId = resolution.selection.receipt_ids[0];
|
|
@@ -18547,12 +18600,15 @@ export {
|
|
|
18547
18600
|
REQUIRED_CLOCK_SCHEMA_ID,
|
|
18548
18601
|
QualifiedOrderBookArchiveReader,
|
|
18549
18602
|
PROMOTION_RECEIPT_SCHEMA_ID,
|
|
18603
|
+
LEGACY_RESOURCE_POLICY_ID,
|
|
18604
|
+
LEGACY_RESOURCE_POLICY,
|
|
18550
18605
|
FINAL_BACKFILL_STATUSES,
|
|
18551
18606
|
EFFECTIVE_ADAPTER_POLICY_PIN,
|
|
18552
18607
|
EFFECTIVE_ACQUISITION_POLICY_PIN,
|
|
18553
18608
|
CryptoHftDataError,
|
|
18554
18609
|
CryptoHftDataAdapter,
|
|
18555
18610
|
CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE,
|
|
18611
|
+
CRYPTOHFTDATA_OKX_SPOT_ARBUSDC_PROFILE,
|
|
18556
18612
|
CRYPTOHFTDATA_BINANCE_SPOT_BTCUSDT_PROFILE,
|
|
18557
18613
|
CRYPTOHFTDATA_API_URL,
|
|
18558
18614
|
CRYPTOHFTDATA_ADAPTER_VERSION,
|
|
@@ -18569,4 +18625,4 @@ export {
|
|
|
18569
18625
|
ACQUISITION_POLICY_ID
|
|
18570
18626
|
};
|
|
18571
18627
|
|
|
18572
|
-
//# debugId=
|
|
18628
|
+
//# debugId=352683EF086D61EB64756E2164756E21
|