@usherlabs/cex-broker 0.2.36 → 0.2.38
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/README.md +11 -0
- package/dist/commands/cli.js +2644 -2116
- package/dist/helpers/binance-user-data-normalization.d.ts +3 -0
- package/dist/helpers/broker-execution-archive/index.d.ts +2 -2
- package/dist/helpers/broker-execution-archive/rows.d.ts +4 -1
- package/dist/helpers/broker-execution-archive/types.d.ts +4 -2
- package/dist/helpers/broker-execution-archive/writer.d.ts +6 -1
- package/dist/helpers/market-data-archive/canonical-orderbook.d.ts +20 -0
- package/dist/helpers/market-data-archive/capture-context.d.ts +32 -0
- package/dist/helpers/market-data-archive/capture-contract.d.ts +29 -0
- package/dist/helpers/market-data-archive/capture.d.ts +2 -0
- package/dist/helpers/market-data-archive/index.d.ts +6 -2
- package/dist/helpers/market-data-archive/legacy-migration.d.ts +37 -0
- package/dist/helpers/market-data-archive/rows.d.ts +7 -11
- package/dist/helpers/market-data-archive/types.d.ts +26 -2
- package/dist/index.js +2645 -2117
- package/dist/index.js.map +23 -19
- package/package.json +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Exchange } from "@usherlabs/ccxt";
|
|
2
|
+
export declare function normalizeBinanceSpotBalanceEvent(exchange: Exchange, event: Record<string, unknown>): Promise<unknown>;
|
|
3
|
+
export declare function normalizeBinanceExecutionReport(exchange: Exchange, event: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { archiveOrderExecutionInBackground, archiveSubscribeStreamInBackground, archiveTransferEventInBackground, archiveWithdrawalObservationsInBackground, captureMarketMetadataSnapshot, captureMarketMetadataSnapshotInBackground, } from "./capture";
|
|
2
2
|
export { hashMarketMetadata, redactErrorForArchive, redactSecretLiterals, redactStreamPayload, } from "./redact";
|
|
3
|
-
export { buildAccountBalanceSnapshotRow, buildCommonArchiveTags, buildFillEventArchiveRow, buildMarketMetadataSnapshotRow, buildOrderEventArchiveRow, buildSubscribeStreamArchiveRow, buildTransferEventArchiveRow, type FillArchiveFields, type NormalizedCcxtBalance, type NormalizedCcxtTransfer, normalizeCcxtBalanceForArchive, normalizeCcxtTradeForArchive, normalizeCcxtTransactionForArchive, type TransferArchiveFields, } from "./rows";
|
|
4
|
-
export { ACCOUNT_BALANCE_PRECISION_BASIS, ACCOUNT_BALANCE_SCOPE, ARCHIVE_SCHEMA_VERSION, BROKER_WRITE_SOURCE, type BrokerArchiveCommonTags, type BrokerArchiveRow, type BrokerArchiveTable, type OrderArchiveAction, type SubscribeArchiveType, type TransferEventKind, type TransferLifecycleAction, } from "./types";
|
|
3
|
+
export { buildAccountBalanceSnapshotRow, buildCommonArchiveTags, buildFillEventArchiveRow, buildMarketMetadataSnapshotRow, buildOrderEventArchiveRow, buildSubscribeStreamArchiveRow, buildTransferEventArchiveRow, extractBinanceInternalTransferId, type FillArchiveFields, type NormalizedCcxtBalance, type NormalizedCcxtTransfer, normalizeCcxtBalanceForArchive, normalizeCcxtTradeForArchive, normalizeCcxtTransactionForArchive, type TransferArchiveFields, } from "./rows";
|
|
4
|
+
export { ACCOUNT_BALANCE_PRECISION_BASIS, ACCOUNT_BALANCE_SCOPE, ARCHIVE_SCHEMA_VERSION, BROKER_READ_SOURCE, BROKER_WRITE_SOURCE, type BrokerArchiveCommonTags, type BrokerArchiveRow, type BrokerArchiveSource, type BrokerArchiveTable, type OrderArchiveAction, type SubscribeArchiveType, type TransferEventKind, type TransferLifecycleAction, } from "./types";
|
|
5
5
|
export { DEFAULT_WITHDRAWAL_OBSERVATION_TRACKER_MAX_ENTRIES, WithdrawalObservationTracker, } from "./withdrawal-observation-tracker";
|
|
6
6
|
export { BrokerExecutionArchiveDurabilityError, BrokerExecutionArchiver, type BrokerExecutionArchiverOptions, createBrokerExecutionArchiverFromEnv, isArchiveOtelLogsEnabled, isBrokerExecutionArchiveTable, resolveArchiveForwarderUrlFromEnv, rethrowArchiveDurabilityError, } from "./writer";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OrderExecutionTelemetry } from "../order-telemetry";
|
|
2
|
-
import { type BrokerArchiveCommonTags, type BrokerArchiveRow, type OrderArchiveAction, type SubscribeArchiveType, type TransferEventKind, type TransferLifecycleAction } from "./types";
|
|
2
|
+
import { type BrokerArchiveCommonTags, type BrokerArchiveRow, type BrokerArchiveSource, type OrderArchiveAction, type SubscribeArchiveType, type TransferEventKind, type TransferLifecycleAction } from "./types";
|
|
3
3
|
type BalanceQuantityMap = Record<string, string>;
|
|
4
4
|
export type NormalizedCcxtBalance = {
|
|
5
5
|
exchangeTimestamp?: string;
|
|
@@ -18,6 +18,7 @@ export declare function buildAccountBalanceSnapshotRow(input: {
|
|
|
18
18
|
balance: NormalizedCcxtBalance;
|
|
19
19
|
}): BrokerArchiveRow;
|
|
20
20
|
export declare function buildCommonArchiveTags(input: {
|
|
21
|
+
source?: BrokerArchiveSource;
|
|
21
22
|
deploymentId: string;
|
|
22
23
|
accountSelector?: string;
|
|
23
24
|
exchange: string;
|
|
@@ -39,6 +40,7 @@ export declare function buildSubscribeStreamArchiveRow(input: {
|
|
|
39
40
|
streamPayload: unknown;
|
|
40
41
|
secretLiterals?: readonly string[];
|
|
41
42
|
}): BrokerArchiveRow;
|
|
43
|
+
export declare function extractBinanceInternalTransferId(response: unknown): string | undefined;
|
|
42
44
|
export type TransferArchiveFields = {
|
|
43
45
|
eventKind: TransferEventKind;
|
|
44
46
|
lifecycleAction: TransferLifecycleAction;
|
|
@@ -62,6 +64,7 @@ export declare function buildTransferEventArchiveRow(input: {
|
|
|
62
64
|
}): BrokerArchiveRow;
|
|
63
65
|
export type NormalizedCcxtTransfer = {
|
|
64
66
|
externalId?: string;
|
|
67
|
+
clientWithdrawalId?: string;
|
|
65
68
|
txid?: string;
|
|
66
69
|
address?: string;
|
|
67
70
|
network?: string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
export declare const BROKER_READ_SOURCE: "broker_read";
|
|
1
2
|
export declare const BROKER_WRITE_SOURCE: "broker_write";
|
|
3
|
+
export type BrokerArchiveSource = typeof BROKER_READ_SOURCE | typeof BROKER_WRITE_SOURCE;
|
|
2
4
|
export declare const ARCHIVE_SCHEMA_VERSION: "1";
|
|
3
|
-
export type BrokerArchiveTable = "broker_execution.order_events" | "broker_execution.market_metadata_snapshots" | "broker_execution.transfer_events" | "broker_execution.fill_events" | "broker_account.balance_snapshots" | "market_data.orderbook_snapshots" | "market_data.candles" | "market_data.cex_stream_events" | "market_data.cex_ticker_events" | "market_data.cex_trades";
|
|
5
|
+
export type BrokerArchiveTable = "broker_execution.order_events" | "broker_execution.market_metadata_snapshots" | "broker_execution.transfer_events" | "broker_execution.fill_events" | "broker_account.balance_snapshots" | "market_data.orderbook_snapshots" | "market_data.candles" | "market_data.cex_stream_events" | "market_data.cex_ticker_events" | "market_data.cex_trades" | "market_data.cex_ohlcv" | "market_data.cex_order_book_levels" | "market_data.cex_order_book_depth_summary";
|
|
4
6
|
export type BrokerArchiveRow = {
|
|
5
7
|
table: BrokerArchiveTable;
|
|
6
8
|
row: Record<string, unknown>;
|
|
7
9
|
};
|
|
8
10
|
export type BrokerArchiveCommonTags = {
|
|
9
|
-
source:
|
|
11
|
+
source: BrokerArchiveSource;
|
|
10
12
|
deployment_id: string;
|
|
11
13
|
account_selector: string;
|
|
12
14
|
exchange: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { OtelLogs, OtelMetrics } from "../otel";
|
|
2
|
-
import type
|
|
2
|
+
import { type BrokerArchiveRow, type BrokerArchiveSource, type BrokerArchiveTable } from "./types";
|
|
3
3
|
export declare function isBrokerExecutionArchiveTable(table: BrokerArchiveTable): boolean;
|
|
4
4
|
export type BrokerExecutionArchiverOptions = {
|
|
5
|
+
source?: BrokerArchiveSource;
|
|
5
6
|
deploymentId?: string;
|
|
6
7
|
otelLogs?: OtelLogs;
|
|
7
8
|
otelMetrics?: OtelMetrics;
|
|
@@ -24,7 +25,9 @@ type ArchiverStats = {
|
|
|
24
25
|
};
|
|
25
26
|
export declare function isArchiveOtelLogsEnabled(): boolean;
|
|
26
27
|
export declare function resolveArchiveForwarderUrlFromEnv(): string | undefined;
|
|
28
|
+
export declare function resolveArchiveSourceFromEnv(value?: string | undefined): BrokerArchiveSource;
|
|
27
29
|
export declare class BrokerExecutionArchiver {
|
|
30
|
+
private readonly source;
|
|
28
31
|
private readonly deploymentId;
|
|
29
32
|
private readonly otelLogs?;
|
|
30
33
|
private readonly otelMetrics?;
|
|
@@ -40,6 +43,7 @@ export declare class BrokerExecutionArchiver {
|
|
|
40
43
|
private flushTimer;
|
|
41
44
|
private flushInFlight;
|
|
42
45
|
private lastShedWarnAtMs;
|
|
46
|
+
private closing;
|
|
43
47
|
private closed;
|
|
44
48
|
private readonly enabled;
|
|
45
49
|
private readonly forwarderAuthToken?;
|
|
@@ -47,6 +51,7 @@ export declare class BrokerExecutionArchiver {
|
|
|
47
51
|
static disabled(): BrokerExecutionArchiver;
|
|
48
52
|
static create(options: BrokerExecutionArchiverOptions): BrokerExecutionArchiver;
|
|
49
53
|
getDeploymentId(): string;
|
|
54
|
+
getSource(): BrokerArchiveSource;
|
|
50
55
|
isEnabled(): boolean;
|
|
51
56
|
canPersistMarketMetadataSnapshot(): boolean;
|
|
52
57
|
canPersistAccountBalanceSnapshots(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BrokerArchiveRow } from "../broker-execution-archive/types";
|
|
2
|
+
import type { NormalizedOrderBookSnapshot, OrderBookConstructionMode } from "../order-book";
|
|
3
|
+
import type { MarketCaptureContext, RawCapture } from "./types";
|
|
4
|
+
export declare class OrderBookValidationError extends Error {
|
|
5
|
+
readonly reason: string;
|
|
6
|
+
constructor(reason: string);
|
|
7
|
+
}
|
|
8
|
+
export type CanonicalOrderBookRows = {
|
|
9
|
+
snapshotId: string;
|
|
10
|
+
levels: BrokerArchiveRow[];
|
|
11
|
+
summary: BrokerArchiveRow;
|
|
12
|
+
};
|
|
13
|
+
export declare function buildCanonicalOrderBookRows(input: {
|
|
14
|
+
context: MarketCaptureContext;
|
|
15
|
+
snapshot: NormalizedOrderBookSnapshot;
|
|
16
|
+
rawCapture: RawCapture;
|
|
17
|
+
depthLimit: number;
|
|
18
|
+
measurementBandsBps?: readonly number[];
|
|
19
|
+
constructionMode?: OrderBookConstructionMode;
|
|
20
|
+
}): CanonicalOrderBookRows;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BrokerArchiveSource } from "../broker-execution-archive/types";
|
|
2
|
+
import type { BrokerMarketType } from "../market-type";
|
|
3
|
+
import type { CaptureFeed, CaptureSourceMode, MarketCaptureContext } from "./types";
|
|
4
|
+
export type CaptureEnvironment = "development" | "production";
|
|
5
|
+
export declare function createMarketCaptureContext(input: {
|
|
6
|
+
source: BrokerArchiveSource;
|
|
7
|
+
deploymentId: string;
|
|
8
|
+
captureBundleId?: string;
|
|
9
|
+
exchange: string;
|
|
10
|
+
symbol: string;
|
|
11
|
+
assetType: BrokerMarketType;
|
|
12
|
+
feed: CaptureFeed;
|
|
13
|
+
provider?: string;
|
|
14
|
+
sourceMode: CaptureSourceMode;
|
|
15
|
+
timeframe?: string;
|
|
16
|
+
accountSelector?: string;
|
|
17
|
+
environment?: CaptureEnvironment;
|
|
18
|
+
}): MarketCaptureContext;
|
|
19
|
+
export declare function validateProductionCollectorArchive(input: {
|
|
20
|
+
source: BrokerArchiveSource;
|
|
21
|
+
captureBundleId?: string;
|
|
22
|
+
}): void;
|
|
23
|
+
export declare function validateExternalFallbackContext(input: {
|
|
24
|
+
configuredExchange: string;
|
|
25
|
+
configuredSymbol: string;
|
|
26
|
+
rowExchange: string;
|
|
27
|
+
rowSymbol: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
sourceMode: "external_ccxt_fallback_v1" | "external_hummingbot_fallback_v1";
|
|
30
|
+
fallbackReason: string;
|
|
31
|
+
}): void;
|
|
32
|
+
export declare function captureEnvironmentFromEnv(value?: string | undefined): CaptureEnvironment;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MarketCaptureContext, RawCapture, RawCaptureScope } from "./types";
|
|
2
|
+
export declare const MARKET_CAPTURE_SCHEMA_VERSION: "1.0.0";
|
|
3
|
+
export declare const CHECKSUM_ALGORITHM: "sha256-canonical-json-v1";
|
|
4
|
+
export declare const ARCHIVE_SOURCES: readonly ["broker_read", "broker_write"];
|
|
5
|
+
export declare const CAPTURE_FEEDS: readonly ["ORDERBOOK", "TICKER", "TRADES", "OHLCV"];
|
|
6
|
+
export declare const SOURCE_MODES: readonly ["broker_live_stream_v1", "broker_live_sampling_v1", "broker_current_snapshot_v1", "broker_bootstrap_fetch_v1", "external_ccxt_fallback_v1", "external_hummingbot_fallback_v1", "legacy_migration_v1"];
|
|
7
|
+
export declare const CONSTRUCTION_MODES: readonly ["sampled_top_n_snapshot", "exact_l2_reconstruction"];
|
|
8
|
+
export declare const GAP_POLICIES: readonly ["record_gap", "ohlcv_catch_up", "fail_fast"];
|
|
9
|
+
export declare const RAW_CAPTURE_SCOPES: readonly ["ccxt_normalized_object", "broker_visible_payload", "exchange_wire_frame"];
|
|
10
|
+
export type CaptureFeed = (typeof CAPTURE_FEEDS)[number];
|
|
11
|
+
export type SourceMode = (typeof SOURCE_MODES)[number];
|
|
12
|
+
export type ConstructionMode = (typeof CONSTRUCTION_MODES)[number];
|
|
13
|
+
export type GapPolicy = (typeof GAP_POLICIES)[number];
|
|
14
|
+
/**
|
|
15
|
+
* Renders a finite JavaScript number as a plain decimal. Exponent expansion and
|
|
16
|
+
* negative-zero normalization are part of checksum algorithm v1 and are mirrored
|
|
17
|
+
* by the Python fixture verifier.
|
|
18
|
+
*/
|
|
19
|
+
export declare function canonicalDecimal(value: number): string;
|
|
20
|
+
export declare function canonicalSerialize(value: unknown): string;
|
|
21
|
+
export declare function sha256Canonical(value: unknown): string;
|
|
22
|
+
export declare function normalizeTimestampMs(value: unknown, field: string): number;
|
|
23
|
+
export declare function createRawCapture(context: MarketCaptureContext, input: {
|
|
24
|
+
payload: unknown;
|
|
25
|
+
eventTimeMs: unknown;
|
|
26
|
+
receivedTimeMs: unknown;
|
|
27
|
+
scope: RawCaptureScope;
|
|
28
|
+
}): RawCapture;
|
|
29
|
+
export declare function captureCoreFields(context: MarketCaptureContext, rawCapture: RawCapture): Record<string, unknown>;
|
|
@@ -5,6 +5,8 @@ import { OrderbookSampler } from "./orderbook-sampler";
|
|
|
5
5
|
import type { CexStreamArchiveInput, OhlcvArchiveInput, OrderbookArchiveInput, TickerArchiveInput, TradesArchiveInput } from "./types";
|
|
6
6
|
export declare function archiveOrderbookInBackground(archiver: BrokerExecutionArchiver | undefined, otelMetrics: OtelMetrics | undefined, input: OrderbookArchiveInput, options?: {
|
|
7
7
|
sampledOut?: boolean;
|
|
8
|
+
sourceMode?: "broker_live_sampling_v1" | "broker_current_snapshot_v1";
|
|
9
|
+
depthLimit?: number;
|
|
8
10
|
}): void;
|
|
9
11
|
/** @deprecated Use archiveOrderbookInBackground */
|
|
10
12
|
export declare const archiveOrderbookSnapshotInBackground: typeof archiveOrderbookInBackground;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
export { buildCanonicalOrderBookRows, OrderBookValidationError, } from "./canonical-orderbook";
|
|
1
2
|
export { archiveCexStreamEventInBackground, archiveOhlcvInBackground, archiveOrderbookInBackground, archiveOrderbookSnapshotInBackground, archiveOrderbookTobInBackground, archiveTickerInBackground, archiveTradesInBackground, createOhlcvBarTracker, createOrderbookSampler, createOrderbookTobSampler, } from "./capture";
|
|
3
|
+
export { captureEnvironmentFromEnv, createMarketCaptureContext, validateExternalFallbackContext, validateProductionCollectorArchive, } from "./capture-context";
|
|
4
|
+
export { ARCHIVE_SOURCES, CAPTURE_FEEDS, CHECKSUM_ALGORITHM, CONSTRUCTION_MODES, canonicalDecimal, canonicalSerialize, createRawCapture, GAP_POLICIES, MARKET_CAPTURE_SCHEMA_VERSION, RAW_CAPTURE_SCOPES, SOURCE_MODES, sha256Canonical, } from "./capture-contract";
|
|
5
|
+
export { buildLegacyOhlcvMigrationRow, buildLegacyOrderBookMigrationRows, type LegacyCandle, type LegacyOrderBookSnapshot, } from "./legacy-migration";
|
|
2
6
|
export { extractLatestOhlcvBar, extractOhlcvBars, OhlcvBarTracker, parseOhlcvBar, } from "./ohlcv-bar-tracker";
|
|
3
7
|
export { resolveOhlcvBootstrapLimit } from "./ohlcv-bootstrap";
|
|
4
8
|
export { bootstrapOhlcvHistory } from "./ohlcv-history";
|
|
5
9
|
export { getOrderbookArchiveDepthLimit, splitOrderBookSide, } from "./orderbook-depth";
|
|
6
10
|
export { getOrderbookIntervalMs, getOrderbookTobIntervalMs, isMarketArchiveEnabled, OrderbookSampler, OrderbookTobSampler, } from "./orderbook-sampler";
|
|
7
11
|
export { extractTrades, parseTicker, parseTrade } from "./parse-stream";
|
|
8
|
-
export {
|
|
9
|
-
export type { CexStreamArchiveInput, CexStreamType, MarketArchiveContext, OhlcvArchiveCandidate, OhlcvArchiveInput, OrderbookArchiveInput, OrderbookSnapshotArchiveInput, OrderbookTobArchiveInput, ParsedOhlcvBar, TickerArchiveInput, TradesArchiveInput, } from "./types";
|
|
12
|
+
export { buildCanonicalCexStreamEventRow, buildCanonicalOhlcvRow, buildCanonicalTickerEventRow, buildCanonicalTradeRow, buildCexStreamEventRow, } from "./rows";
|
|
13
|
+
export type { CaptureFeed, CaptureSourceMode, CexStreamArchiveInput, CexStreamType, MarketArchiveContext, MarketCaptureContext, OhlcvArchiveCandidate, OhlcvArchiveInput, OrderbookArchiveInput, OrderbookSnapshotArchiveInput, OrderbookTobArchiveInput, ParsedOhlcvBar, RawCapture, RawCaptureScope, TickerArchiveInput, TradesArchiveInput, } from "./types";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BrokerArchiveRow, BrokerArchiveSource } from "../broker-execution-archive/types";
|
|
2
|
+
export type LegacyOrderBookSnapshot = {
|
|
3
|
+
source?: BrokerArchiveSource;
|
|
4
|
+
deployment_id: string;
|
|
5
|
+
account_selector?: string;
|
|
6
|
+
exchange: string;
|
|
7
|
+
asset_type: "spot" | "swap" | "future";
|
|
8
|
+
symbol: string;
|
|
9
|
+
event_time_ms: number;
|
|
10
|
+
received_time_ms: number;
|
|
11
|
+
depth_limit: number;
|
|
12
|
+
bids_price: number[];
|
|
13
|
+
bids_size: number[];
|
|
14
|
+
asks_price: number[];
|
|
15
|
+
asks_size: number[];
|
|
16
|
+
sequence?: number;
|
|
17
|
+
};
|
|
18
|
+
export type LegacyCandle = {
|
|
19
|
+
source?: BrokerArchiveSource;
|
|
20
|
+
deployment_id: string;
|
|
21
|
+
account_selector?: string;
|
|
22
|
+
exchange: string;
|
|
23
|
+
asset_type: "spot" | "swap" | "future";
|
|
24
|
+
symbol: string;
|
|
25
|
+
timeframe: string;
|
|
26
|
+
open_time_ms: number;
|
|
27
|
+
open: number;
|
|
28
|
+
high: number;
|
|
29
|
+
low: number;
|
|
30
|
+
close: number;
|
|
31
|
+
volume: number;
|
|
32
|
+
quote_volume?: number;
|
|
33
|
+
is_closed: 0 | 1;
|
|
34
|
+
broker_version: number;
|
|
35
|
+
};
|
|
36
|
+
export declare function buildLegacyOrderBookMigrationRows(legacy: LegacyOrderBookSnapshot): BrokerArchiveRow[];
|
|
37
|
+
export declare function buildLegacyOhlcvMigrationRow(legacy: LegacyCandle): BrokerArchiveRow;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import type { BrokerArchiveRow } from "../broker-execution-archive/types";
|
|
2
2
|
import type { ParsedTicker, ParsedTrade } from "./parse-stream";
|
|
3
|
-
import type { CexStreamArchiveInput,
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
context: MarketArchiveContext;
|
|
3
|
+
import type { CexStreamArchiveInput, MarketCaptureContext, ParsedOhlcvBar, RawCapture } from "./types";
|
|
4
|
+
export declare function buildCanonicalCexStreamEventRow(context: MarketCaptureContext, rawCapture: RawCapture): BrokerArchiveRow;
|
|
5
|
+
export declare function buildCanonicalTickerEventRow(context: MarketCaptureContext, rawCapture: RawCapture, ticker: ParsedTicker): BrokerArchiveRow;
|
|
6
|
+
export declare function buildCanonicalTradeRow(context: MarketCaptureContext, rawCapture: RawCapture, trade: ParsedTrade): BrokerArchiveRow;
|
|
7
|
+
export declare function buildCanonicalOhlcvRow(input: {
|
|
8
|
+
context: MarketCaptureContext;
|
|
9
|
+
rawCapture: RawCapture;
|
|
11
10
|
bar: ParsedOhlcvBar;
|
|
12
11
|
isClosed: boolean;
|
|
13
12
|
brokerVersion: number;
|
|
14
|
-
receivedTimestamp: number;
|
|
15
13
|
}): BrokerArchiveRow;
|
|
16
14
|
export declare function buildCexStreamEventRow(input: CexStreamArchiveInput): BrokerArchiveRow;
|
|
17
|
-
export declare function buildCexTickerEventRow(input: TickerArchiveInput, ticker: ParsedTicker): BrokerArchiveRow;
|
|
18
|
-
export declare function buildCexTradeRow(input: TradesArchiveInput, trade: ParsedTrade): BrokerArchiveRow;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BrokerArchiveRow } from "../broker-execution-archive/types";
|
|
1
|
+
import type { BrokerArchiveRow, BrokerArchiveSource } from "../broker-execution-archive/types";
|
|
2
2
|
import type { BrokerMarketType } from "../market-type";
|
|
3
3
|
import type { NormalizedOrderBookSnapshot } from "../order-book";
|
|
4
|
-
export type MarketArchiveTable = "market_data.orderbook_snapshots" | "market_data.candles" | "market_data.cex_stream_events" | "market_data.cex_ticker_events" | "market_data.cex_trades";
|
|
4
|
+
export type MarketArchiveTable = "market_data.orderbook_snapshots" | "market_data.candles" | "market_data.cex_stream_events" | "market_data.cex_ticker_events" | "market_data.cex_trades" | "market_data.cex_ohlcv" | "market_data.cex_order_book_levels" | "market_data.cex_order_book_depth_summary";
|
|
5
5
|
export type CexStreamType = "BALANCE" | "ORDERS" | "ORDERBOOK" | "TRADES" | "TICKER" | "OHLCV";
|
|
6
6
|
export type ParsedOhlcvBar = {
|
|
7
7
|
openTimeMs: number;
|
|
@@ -18,6 +18,7 @@ export type OhlcvArchiveCandidate = {
|
|
|
18
18
|
brokerVersion: number;
|
|
19
19
|
};
|
|
20
20
|
export type MarketArchiveContext = {
|
|
21
|
+
source?: BrokerArchiveSource;
|
|
21
22
|
exchange: string;
|
|
22
23
|
symbol: string;
|
|
23
24
|
assetType: BrokerMarketType;
|
|
@@ -25,6 +26,28 @@ export type MarketArchiveContext = {
|
|
|
25
26
|
accountSelector?: string;
|
|
26
27
|
deploymentId: string;
|
|
27
28
|
};
|
|
29
|
+
export type CaptureFeed = "ORDERBOOK" | "TICKER" | "TRADES" | "OHLCV";
|
|
30
|
+
export type CaptureSourceMode = "broker_live_stream_v1" | "broker_live_sampling_v1" | "broker_current_snapshot_v1" | "broker_bootstrap_fetch_v1" | "external_ccxt_fallback_v1" | "external_hummingbot_fallback_v1" | "legacy_migration_v1";
|
|
31
|
+
export type RawCaptureScope = "ccxt_normalized_object" | "broker_visible_payload" | "exchange_wire_frame";
|
|
32
|
+
export type MarketCaptureContext = MarketArchiveContext & {
|
|
33
|
+
source: BrokerArchiveSource;
|
|
34
|
+
captureBundleId: string;
|
|
35
|
+
feed: CaptureFeed;
|
|
36
|
+
provider: string;
|
|
37
|
+
sourceMode: CaptureSourceMode;
|
|
38
|
+
schemaVersion: string;
|
|
39
|
+
checksumAlgorithm: string;
|
|
40
|
+
provenanceComplete: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type RawCapture = {
|
|
43
|
+
rawCaptureId: string;
|
|
44
|
+
rawCaptureScope: RawCaptureScope;
|
|
45
|
+
rawChecksum: string;
|
|
46
|
+
redactedPayload: unknown;
|
|
47
|
+
eventTimeMs: number;
|
|
48
|
+
receivedTimeMs: number;
|
|
49
|
+
checksumAlgorithm: string;
|
|
50
|
+
};
|
|
28
51
|
export type OrderbookArchiveInput = MarketArchiveContext & {
|
|
29
52
|
snapshot: NormalizedOrderBookSnapshot;
|
|
30
53
|
};
|
|
@@ -36,6 +59,7 @@ export type OhlcvArchiveInput = MarketArchiveContext & {
|
|
|
36
59
|
payload: unknown;
|
|
37
60
|
receivedTimestamp: number;
|
|
38
61
|
timeframe: string;
|
|
62
|
+
sourceMode?: "broker_live_stream_v1" | "broker_bootstrap_fetch_v1";
|
|
39
63
|
};
|
|
40
64
|
export type TradesArchiveInput = MarketArchiveContext & {
|
|
41
65
|
payload: unknown;
|