@0xarchive/sdk 0.5.4 → 0.6.1
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 +88 -0
- package/dist/index.d.mts +464 -8
- package/dist/index.d.ts +464 -8
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +212 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -308,6 +308,68 @@ const lighterCandles = await client.lighter.candles.history('BTC', {
|
|
|
308
308
|
| `1d` | 1 day |
|
|
309
309
|
| `1w` | 1 week |
|
|
310
310
|
|
|
311
|
+
### Data Quality Monitoring
|
|
312
|
+
|
|
313
|
+
Monitor data coverage, incidents, latency, and SLA compliance across all exchanges.
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
// Get overall system health status
|
|
317
|
+
const status = await client.dataQuality.status();
|
|
318
|
+
console.log(`System status: ${status.status}`);
|
|
319
|
+
for (const [exchange, info] of Object.entries(status.exchanges)) {
|
|
320
|
+
console.log(` ${exchange}: ${info.status}`);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Get data coverage summary for all exchanges
|
|
324
|
+
const coverage = await client.dataQuality.coverage();
|
|
325
|
+
for (const exchange of coverage.exchanges) {
|
|
326
|
+
console.log(`${exchange.exchange}:`);
|
|
327
|
+
for (const [dtype, info] of Object.entries(exchange.dataTypes)) {
|
|
328
|
+
console.log(` ${dtype}: ${info.totalRecords.toLocaleString()} records, ${info.completeness}% complete`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Get symbol-specific coverage with gap detection
|
|
333
|
+
const btc = await client.dataQuality.symbolCoverage('hyperliquid', 'BTC');
|
|
334
|
+
const oi = btc.dataTypes.open_interest;
|
|
335
|
+
console.log(`BTC OI completeness: ${oi.completeness}%`);
|
|
336
|
+
console.log(`Gaps found: ${oi.gaps.length}`);
|
|
337
|
+
for (const gap of oi.gaps.slice(0, 5)) {
|
|
338
|
+
console.log(` ${gap.durationMinutes} min gap: ${gap.start} -> ${gap.end}`);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// List incidents with filtering
|
|
342
|
+
const result = await client.dataQuality.listIncidents({ status: 'open' });
|
|
343
|
+
for (const incident of result.incidents) {
|
|
344
|
+
console.log(`[${incident.severity}] ${incident.title}`);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Get latency metrics
|
|
348
|
+
const latency = await client.dataQuality.latency();
|
|
349
|
+
for (const [exchange, metrics] of Object.entries(latency.exchanges)) {
|
|
350
|
+
console.log(`${exchange}: OB lag ${metrics.dataFreshness.orderbookLagMs}ms`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Get SLA compliance metrics for a specific month
|
|
354
|
+
const sla = await client.dataQuality.sla({ year: 2026, month: 1 });
|
|
355
|
+
console.log(`Period: ${sla.period}`);
|
|
356
|
+
console.log(`Uptime: ${sla.actual.uptime}% (${sla.actual.uptimeStatus})`);
|
|
357
|
+
console.log(`API P99: ${sla.actual.apiLatencyP99Ms}ms (${sla.actual.latencyStatus})`);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
#### Data Quality Endpoints
|
|
361
|
+
|
|
362
|
+
| Method | Description |
|
|
363
|
+
|--------|-------------|
|
|
364
|
+
| `status()` | Overall system health and per-exchange status |
|
|
365
|
+
| `coverage()` | Data coverage summary for all exchanges |
|
|
366
|
+
| `exchangeCoverage(exchange)` | Coverage details for a specific exchange |
|
|
367
|
+
| `symbolCoverage(exchange, symbol)` | Coverage with gap detection for specific symbol |
|
|
368
|
+
| `listIncidents(params)` | List incidents with filtering and pagination |
|
|
369
|
+
| `getIncident(incidentId)` | Get specific incident details |
|
|
370
|
+
| `latency()` | Current latency metrics (WebSocket, REST, data freshness) |
|
|
371
|
+
| `sla(params)` | SLA compliance metrics for a specific month |
|
|
372
|
+
|
|
311
373
|
### Legacy API (Deprecated)
|
|
312
374
|
|
|
313
375
|
The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
|
|
@@ -457,6 +519,31 @@ ws.stream('orderbook', 'BTC', {
|
|
|
457
519
|
ws.streamStop();
|
|
458
520
|
```
|
|
459
521
|
|
|
522
|
+
### Gap Detection
|
|
523
|
+
|
|
524
|
+
During historical replay and bulk streaming, the server automatically detects gaps in the data and notifies the client. This helps identify periods where data may be missing.
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
// Handle gap notifications during replay/stream
|
|
528
|
+
ws.onGap((channel, coin, gapStart, gapEnd, durationMinutes) => {
|
|
529
|
+
console.log(`Gap detected in ${channel}/${coin}:`);
|
|
530
|
+
console.log(` From: ${new Date(gapStart).toISOString()}`);
|
|
531
|
+
console.log(` To: ${new Date(gapEnd).toISOString()}`);
|
|
532
|
+
console.log(` Duration: ${durationMinutes} minutes`);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// Start replay - gaps will be reported via onGap callback
|
|
536
|
+
ws.replay('orderbook', 'BTC', {
|
|
537
|
+
start: Date.now() - 86400000,
|
|
538
|
+
end: Date.now(),
|
|
539
|
+
speed: 10
|
|
540
|
+
});
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
Gap thresholds vary by channel:
|
|
544
|
+
- **orderbook**, **candles**, **liquidations**: 2 minutes
|
|
545
|
+
- **trades**: 60 minutes (trades can naturally have longer gaps during low activity periods)
|
|
546
|
+
|
|
460
547
|
### WebSocket Configuration
|
|
461
548
|
|
|
462
549
|
```typescript
|
|
@@ -477,6 +564,7 @@ const ws = new OxArchiveWs({
|
|
|
477
564
|
| `orderbook` | L2 order book updates | Yes | Yes |
|
|
478
565
|
| `trades` | Trade/fill updates | Yes | Yes |
|
|
479
566
|
| `candles` | OHLCV candle data | Yes | Yes (replay/stream only) |
|
|
567
|
+
| `liquidations` | Liquidation events (May 2025+) | Yes | Yes (replay/stream only) |
|
|
480
568
|
| `ticker` | Price and 24h volume | Yes | Real-time only |
|
|
481
569
|
| `all_tickers` | All market tickers | No | Real-time only |
|
|
482
570
|
|
package/dist/index.d.mts
CHANGED
|
@@ -536,8 +536,24 @@ interface WsStreamStopped {
|
|
|
536
536
|
type: 'stream_stopped';
|
|
537
537
|
snapshots_sent: number;
|
|
538
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* Gap detected in historical data stream.
|
|
541
|
+
* Sent when there's a gap exceeding the threshold between consecutive data points.
|
|
542
|
+
* Thresholds: 2 minutes for orderbook/candles/liquidations, 60 minutes for trades.
|
|
543
|
+
*/
|
|
544
|
+
interface WsGapDetected {
|
|
545
|
+
type: 'gap_detected';
|
|
546
|
+
channel: WsChannel;
|
|
547
|
+
coin: string;
|
|
548
|
+
/** Start of the gap (last data point timestamp in ms) */
|
|
549
|
+
gap_start: number;
|
|
550
|
+
/** End of the gap (next data point timestamp in ms) */
|
|
551
|
+
gap_end: number;
|
|
552
|
+
/** Gap duration in minutes */
|
|
553
|
+
duration_minutes: number;
|
|
554
|
+
}
|
|
539
555
|
/** Server message union type */
|
|
540
|
-
type WsServerMessage = WsSubscribed | WsUnsubscribed | WsPong | WsError | WsData | WsReplayStarted | WsReplayPaused | WsReplayResumed | WsReplayCompleted | WsReplayStopped | WsHistoricalData | WsHistoricalTickData | WsStreamStarted | WsStreamProgress | WsHistoricalBatch | WsStreamCompleted | WsStreamStopped;
|
|
556
|
+
type WsServerMessage = WsSubscribed | WsUnsubscribed | WsPong | WsError | WsData | WsReplayStarted | WsReplayPaused | WsReplayResumed | WsReplayCompleted | WsReplayStopped | WsHistoricalData | WsHistoricalTickData | WsStreamStarted | WsStreamProgress | WsHistoricalBatch | WsStreamCompleted | WsStreamStopped | WsGapDetected;
|
|
541
557
|
/**
|
|
542
558
|
* WebSocket connection options.
|
|
543
559
|
*
|
|
@@ -586,6 +602,265 @@ declare class OxArchiveError extends Error {
|
|
|
586
602
|
}
|
|
587
603
|
/** Timestamp can be Unix ms (number), ISO string, or Date object */
|
|
588
604
|
type Timestamp = number | string | Date;
|
|
605
|
+
/** System status values */
|
|
606
|
+
type SystemStatusValue = 'operational' | 'degraded' | 'outage' | 'maintenance';
|
|
607
|
+
/** Status of a single exchange */
|
|
608
|
+
interface ExchangeStatus {
|
|
609
|
+
/** Current status */
|
|
610
|
+
status: SystemStatusValue;
|
|
611
|
+
/** Timestamp of last received data */
|
|
612
|
+
lastDataAt?: string;
|
|
613
|
+
/** Current latency in milliseconds */
|
|
614
|
+
latencyMs?: number;
|
|
615
|
+
}
|
|
616
|
+
/** Status of a data type (orderbook, fills, etc.) */
|
|
617
|
+
interface DataTypeStatus {
|
|
618
|
+
/** Current status */
|
|
619
|
+
status: SystemStatusValue;
|
|
620
|
+
/** Data completeness over last 24 hours (0-100) */
|
|
621
|
+
completeness24h: number;
|
|
622
|
+
}
|
|
623
|
+
/** Overall system status response */
|
|
624
|
+
interface StatusResponse {
|
|
625
|
+
/** Overall system status */
|
|
626
|
+
status: SystemStatusValue;
|
|
627
|
+
/** When this status was computed */
|
|
628
|
+
updatedAt: string;
|
|
629
|
+
/** Per-exchange status */
|
|
630
|
+
exchanges: Record<string, ExchangeStatus>;
|
|
631
|
+
/** Per-data-type status */
|
|
632
|
+
dataTypes: Record<string, DataTypeStatus>;
|
|
633
|
+
/** Number of active incidents */
|
|
634
|
+
activeIncidents: number;
|
|
635
|
+
}
|
|
636
|
+
/** Coverage information for a specific data type */
|
|
637
|
+
interface DataTypeCoverage {
|
|
638
|
+
/** Earliest available data timestamp */
|
|
639
|
+
earliest: string;
|
|
640
|
+
/** Latest available data timestamp */
|
|
641
|
+
latest: string;
|
|
642
|
+
/** Total number of records */
|
|
643
|
+
totalRecords: number;
|
|
644
|
+
/** Number of symbols with data */
|
|
645
|
+
symbols: number;
|
|
646
|
+
/** Data resolution (e.g., '1.2s', '1m') */
|
|
647
|
+
resolution?: string;
|
|
648
|
+
/** Current data lag */
|
|
649
|
+
lag?: string;
|
|
650
|
+
/** Completeness percentage (0-100) */
|
|
651
|
+
completeness: number;
|
|
652
|
+
}
|
|
653
|
+
/** Coverage for a single exchange */
|
|
654
|
+
interface ExchangeCoverage {
|
|
655
|
+
/** Exchange name */
|
|
656
|
+
exchange: string;
|
|
657
|
+
/** Coverage per data type */
|
|
658
|
+
dataTypes: Record<string, DataTypeCoverage>;
|
|
659
|
+
}
|
|
660
|
+
/** Overall coverage response */
|
|
661
|
+
interface CoverageResponse {
|
|
662
|
+
/** Coverage for all exchanges */
|
|
663
|
+
exchanges: ExchangeCoverage[];
|
|
664
|
+
}
|
|
665
|
+
/** Gap information for per-symbol coverage */
|
|
666
|
+
interface CoverageGap {
|
|
667
|
+
/** Start of the gap (last data before gap) */
|
|
668
|
+
start: string;
|
|
669
|
+
/** End of the gap (first data after gap) */
|
|
670
|
+
end: string;
|
|
671
|
+
/** Duration of the gap in minutes */
|
|
672
|
+
durationMinutes: number;
|
|
673
|
+
}
|
|
674
|
+
/** Coverage for a specific symbol and data type */
|
|
675
|
+
interface SymbolDataTypeCoverage {
|
|
676
|
+
/** Earliest available data timestamp */
|
|
677
|
+
earliest: string;
|
|
678
|
+
/** Latest available data timestamp */
|
|
679
|
+
latest: string;
|
|
680
|
+
/** Total number of records */
|
|
681
|
+
totalRecords: number;
|
|
682
|
+
/** Completeness percentage (0-100) */
|
|
683
|
+
completeness: number;
|
|
684
|
+
/** Detected data gaps */
|
|
685
|
+
gaps: CoverageGap[];
|
|
686
|
+
}
|
|
687
|
+
/** Per-symbol coverage response */
|
|
688
|
+
interface SymbolCoverageResponse {
|
|
689
|
+
/** Exchange name */
|
|
690
|
+
exchange: string;
|
|
691
|
+
/** Symbol name */
|
|
692
|
+
symbol: string;
|
|
693
|
+
/** Coverage per data type */
|
|
694
|
+
dataTypes: Record<string, SymbolDataTypeCoverage>;
|
|
695
|
+
}
|
|
696
|
+
/** Incident status values */
|
|
697
|
+
type IncidentStatusValue = 'open' | 'investigating' | 'identified' | 'monitoring' | 'resolved';
|
|
698
|
+
/** Incident severity values */
|
|
699
|
+
type IncidentSeverityValue = 'minor' | 'major' | 'critical';
|
|
700
|
+
/** Data quality incident */
|
|
701
|
+
interface Incident {
|
|
702
|
+
/** Unique incident ID */
|
|
703
|
+
id: string;
|
|
704
|
+
/** Status: open, investigating, identified, monitoring, resolved */
|
|
705
|
+
status: string;
|
|
706
|
+
/** Severity: minor, major, critical */
|
|
707
|
+
severity: string;
|
|
708
|
+
/** Affected exchange (if specific to one) */
|
|
709
|
+
exchange?: string;
|
|
710
|
+
/** Affected data types */
|
|
711
|
+
dataTypes: string[];
|
|
712
|
+
/** Affected symbols */
|
|
713
|
+
symbolsAffected: string[];
|
|
714
|
+
/** When the incident started */
|
|
715
|
+
startedAt: string;
|
|
716
|
+
/** When the incident was resolved */
|
|
717
|
+
resolvedAt?: string;
|
|
718
|
+
/** Total duration in minutes */
|
|
719
|
+
durationMinutes?: number;
|
|
720
|
+
/** Incident title */
|
|
721
|
+
title: string;
|
|
722
|
+
/** Detailed description */
|
|
723
|
+
description?: string;
|
|
724
|
+
/** Root cause analysis */
|
|
725
|
+
rootCause?: string;
|
|
726
|
+
/** Resolution details */
|
|
727
|
+
resolution?: string;
|
|
728
|
+
/** Number of records affected */
|
|
729
|
+
recordsAffected?: number;
|
|
730
|
+
/** Number of records recovered */
|
|
731
|
+
recordsRecovered?: number;
|
|
732
|
+
}
|
|
733
|
+
/** Pagination info for incident list */
|
|
734
|
+
interface Pagination {
|
|
735
|
+
/** Total number of incidents */
|
|
736
|
+
total: number;
|
|
737
|
+
/** Page size limit */
|
|
738
|
+
limit: number;
|
|
739
|
+
/** Current offset */
|
|
740
|
+
offset: number;
|
|
741
|
+
}
|
|
742
|
+
/** Incidents list response */
|
|
743
|
+
interface IncidentsResponse {
|
|
744
|
+
/** List of incidents */
|
|
745
|
+
incidents: Incident[];
|
|
746
|
+
/** Pagination info */
|
|
747
|
+
pagination: Pagination;
|
|
748
|
+
}
|
|
749
|
+
/** WebSocket latency metrics */
|
|
750
|
+
interface WebSocketLatency {
|
|
751
|
+
/** Current latency */
|
|
752
|
+
currentMs: number;
|
|
753
|
+
/** 1-hour average latency */
|
|
754
|
+
avg1hMs: number;
|
|
755
|
+
/** 24-hour average latency */
|
|
756
|
+
avg24hMs: number;
|
|
757
|
+
/** 24-hour P99 latency */
|
|
758
|
+
p9924hMs?: number;
|
|
759
|
+
}
|
|
760
|
+
/** REST API latency metrics */
|
|
761
|
+
interface RestApiLatency {
|
|
762
|
+
/** Current latency */
|
|
763
|
+
currentMs: number;
|
|
764
|
+
/** 1-hour average latency */
|
|
765
|
+
avg1hMs: number;
|
|
766
|
+
/** 24-hour average latency */
|
|
767
|
+
avg24hMs: number;
|
|
768
|
+
}
|
|
769
|
+
/** Data freshness metrics (lag from source) */
|
|
770
|
+
interface DataFreshness {
|
|
771
|
+
/** Orderbook data lag */
|
|
772
|
+
orderbookLagMs?: number;
|
|
773
|
+
/** Fills/trades data lag */
|
|
774
|
+
fillsLagMs?: number;
|
|
775
|
+
/** Funding rate data lag */
|
|
776
|
+
fundingLagMs?: number;
|
|
777
|
+
/** Open interest data lag */
|
|
778
|
+
oiLagMs?: number;
|
|
779
|
+
}
|
|
780
|
+
/** Latency metrics for a single exchange */
|
|
781
|
+
interface ExchangeLatency {
|
|
782
|
+
/** WebSocket latency metrics */
|
|
783
|
+
websocket?: WebSocketLatency;
|
|
784
|
+
/** REST API latency metrics */
|
|
785
|
+
restApi?: RestApiLatency;
|
|
786
|
+
/** Data freshness metrics */
|
|
787
|
+
dataFreshness: DataFreshness;
|
|
788
|
+
}
|
|
789
|
+
/** Overall latency response */
|
|
790
|
+
interface LatencyResponse {
|
|
791
|
+
/** When these metrics were measured */
|
|
792
|
+
measuredAt: string;
|
|
793
|
+
/** Per-exchange latency metrics */
|
|
794
|
+
exchanges: Record<string, ExchangeLatency>;
|
|
795
|
+
}
|
|
796
|
+
/** SLA targets */
|
|
797
|
+
interface SlaTargets {
|
|
798
|
+
/** Uptime target percentage */
|
|
799
|
+
uptime: number;
|
|
800
|
+
/** Data completeness target percentage */
|
|
801
|
+
dataCompleteness: number;
|
|
802
|
+
/** API P99 latency target in milliseconds */
|
|
803
|
+
apiLatencyP99Ms: number;
|
|
804
|
+
}
|
|
805
|
+
/** Completeness metrics per data type */
|
|
806
|
+
interface CompletenessMetrics {
|
|
807
|
+
/** Orderbook completeness percentage */
|
|
808
|
+
orderbook: number;
|
|
809
|
+
/** Fills completeness percentage */
|
|
810
|
+
fills: number;
|
|
811
|
+
/** Funding rate completeness percentage */
|
|
812
|
+
funding: number;
|
|
813
|
+
/** Overall completeness percentage */
|
|
814
|
+
overall: number;
|
|
815
|
+
}
|
|
816
|
+
/** Actual SLA metrics */
|
|
817
|
+
interface SlaActual {
|
|
818
|
+
/** Actual uptime percentage */
|
|
819
|
+
uptime: number;
|
|
820
|
+
/** 'met' or 'missed' */
|
|
821
|
+
uptimeStatus: string;
|
|
822
|
+
/** Actual completeness metrics */
|
|
823
|
+
dataCompleteness: CompletenessMetrics;
|
|
824
|
+
/** 'met' or 'missed' */
|
|
825
|
+
completenessStatus: string;
|
|
826
|
+
/** Actual API P99 latency */
|
|
827
|
+
apiLatencyP99Ms: number;
|
|
828
|
+
/** 'met' or 'missed' */
|
|
829
|
+
latencyStatus: string;
|
|
830
|
+
}
|
|
831
|
+
/** SLA compliance response */
|
|
832
|
+
interface SlaResponse {
|
|
833
|
+
/** Period covered (e.g., '2026-01') */
|
|
834
|
+
period: string;
|
|
835
|
+
/** Target SLA metrics */
|
|
836
|
+
slaTargets: SlaTargets;
|
|
837
|
+
/** Actual SLA metrics */
|
|
838
|
+
actual: SlaActual;
|
|
839
|
+
/** Number of incidents in this period */
|
|
840
|
+
incidentsThisPeriod: number;
|
|
841
|
+
/** Total downtime in minutes */
|
|
842
|
+
totalDowntimeMinutes: number;
|
|
843
|
+
}
|
|
844
|
+
/** Parameters for listing incidents */
|
|
845
|
+
interface ListIncidentsParams {
|
|
846
|
+
/** Filter by incident status */
|
|
847
|
+
status?: IncidentStatusValue;
|
|
848
|
+
/** Filter by exchange */
|
|
849
|
+
exchange?: string;
|
|
850
|
+
/** Only show incidents starting after this timestamp (Unix ms) */
|
|
851
|
+
since?: number | string;
|
|
852
|
+
/** Maximum results per page (default: 20, max: 100) */
|
|
853
|
+
limit?: number;
|
|
854
|
+
/** Pagination offset */
|
|
855
|
+
offset?: number;
|
|
856
|
+
}
|
|
857
|
+
/** Parameters for getting SLA metrics */
|
|
858
|
+
interface SlaParams {
|
|
859
|
+
/** Year (defaults to current year) */
|
|
860
|
+
year?: number;
|
|
861
|
+
/** Month 1-12 (defaults to current month) */
|
|
862
|
+
month?: number;
|
|
863
|
+
}
|
|
589
864
|
|
|
590
865
|
interface HttpClientOptions {
|
|
591
866
|
baseUrl: string;
|
|
@@ -1026,6 +1301,165 @@ declare class LiquidationsResource {
|
|
|
1026
1301
|
byUser(userAddress: string, params: LiquidationsByUserParams): Promise<CursorResponse<Liquidation[]>>;
|
|
1027
1302
|
}
|
|
1028
1303
|
|
|
1304
|
+
/**
|
|
1305
|
+
* Data quality API resource
|
|
1306
|
+
*
|
|
1307
|
+
* Provides endpoints for monitoring data quality, coverage, incidents, and SLA metrics.
|
|
1308
|
+
*
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```typescript
|
|
1311
|
+
* // Get system status
|
|
1312
|
+
* const status = await client.dataQuality.status();
|
|
1313
|
+
* console.log(`System status: ${status.status}`);
|
|
1314
|
+
*
|
|
1315
|
+
* // Get coverage for all exchanges
|
|
1316
|
+
* const coverage = await client.dataQuality.coverage();
|
|
1317
|
+
*
|
|
1318
|
+
* // Get symbol-specific coverage with gap detection
|
|
1319
|
+
* const btc = await client.dataQuality.symbolCoverage('hyperliquid', 'BTC');
|
|
1320
|
+
* console.log(`BTC OI completeness: ${btc.dataTypes.open_interest.completeness}%`);
|
|
1321
|
+
* for (const gap of btc.dataTypes.open_interest.gaps.slice(0, 5)) {
|
|
1322
|
+
* console.log(`Gap: ${gap.start} - ${gap.end} (${gap.durationMinutes} min)`);
|
|
1323
|
+
* }
|
|
1324
|
+
* ```
|
|
1325
|
+
*/
|
|
1326
|
+
declare class DataQualityResource {
|
|
1327
|
+
private http;
|
|
1328
|
+
private basePath;
|
|
1329
|
+
constructor(http: HttpClient, basePath?: string);
|
|
1330
|
+
/**
|
|
1331
|
+
* Get overall system health status
|
|
1332
|
+
*
|
|
1333
|
+
* @returns StatusResponse with overall status, per-exchange status,
|
|
1334
|
+
* per-data-type status, and active incident count
|
|
1335
|
+
*
|
|
1336
|
+
* @example
|
|
1337
|
+
* ```typescript
|
|
1338
|
+
* const status = await client.dataQuality.status();
|
|
1339
|
+
* console.log(`Overall: ${status.status}`);
|
|
1340
|
+
* for (const [exchange, info] of Object.entries(status.exchanges)) {
|
|
1341
|
+
* console.log(`${exchange}: ${info.status}`);
|
|
1342
|
+
* }
|
|
1343
|
+
* ```
|
|
1344
|
+
*/
|
|
1345
|
+
status(): Promise<StatusResponse>;
|
|
1346
|
+
/**
|
|
1347
|
+
* Get data coverage summary for all exchanges
|
|
1348
|
+
*
|
|
1349
|
+
* @returns CoverageResponse with coverage info for all exchanges and data types
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* ```typescript
|
|
1353
|
+
* const coverage = await client.dataQuality.coverage();
|
|
1354
|
+
* for (const exchange of coverage.exchanges) {
|
|
1355
|
+
* console.log(`${exchange.exchange}:`);
|
|
1356
|
+
* for (const [dtype, info] of Object.entries(exchange.dataTypes)) {
|
|
1357
|
+
* console.log(` ${dtype}: ${info.totalRecords} records`);
|
|
1358
|
+
* }
|
|
1359
|
+
* }
|
|
1360
|
+
* ```
|
|
1361
|
+
*/
|
|
1362
|
+
coverage(): Promise<CoverageResponse>;
|
|
1363
|
+
/**
|
|
1364
|
+
* Get data coverage for a specific exchange
|
|
1365
|
+
*
|
|
1366
|
+
* @param exchange - Exchange name ('hyperliquid' or 'lighter')
|
|
1367
|
+
* @returns ExchangeCoverage with coverage info for all data types on this exchange
|
|
1368
|
+
*
|
|
1369
|
+
* @example
|
|
1370
|
+
* ```typescript
|
|
1371
|
+
* const hl = await client.dataQuality.exchangeCoverage('hyperliquid');
|
|
1372
|
+
* console.log(`Orderbook earliest: ${hl.dataTypes.orderbook.earliest}`);
|
|
1373
|
+
* ```
|
|
1374
|
+
*/
|
|
1375
|
+
exchangeCoverage(exchange: string): Promise<ExchangeCoverage>;
|
|
1376
|
+
/**
|
|
1377
|
+
* Get data coverage for a specific symbol on an exchange
|
|
1378
|
+
*
|
|
1379
|
+
* Includes gap detection showing periods where data may be missing.
|
|
1380
|
+
*
|
|
1381
|
+
* @param exchange - Exchange name ('hyperliquid' or 'lighter')
|
|
1382
|
+
* @param symbol - Symbol name (e.g., 'BTC', 'ETH')
|
|
1383
|
+
* @returns SymbolCoverageResponse with per-data-type coverage including gaps
|
|
1384
|
+
*
|
|
1385
|
+
* @example
|
|
1386
|
+
* ```typescript
|
|
1387
|
+
* const btc = await client.dataQuality.symbolCoverage('hyperliquid', 'BTC');
|
|
1388
|
+
* const oi = btc.dataTypes.open_interest;
|
|
1389
|
+
* console.log(`OI completeness: ${oi.completeness}%`);
|
|
1390
|
+
* console.log(`Gaps found: ${oi.gaps.length}`);
|
|
1391
|
+
* for (const gap of oi.gaps.slice(0, 3)) {
|
|
1392
|
+
* console.log(` ${gap.durationMinutes} min gap at ${gap.start}`);
|
|
1393
|
+
* }
|
|
1394
|
+
* ```
|
|
1395
|
+
*/
|
|
1396
|
+
symbolCoverage(exchange: string, symbol: string): Promise<SymbolCoverageResponse>;
|
|
1397
|
+
/**
|
|
1398
|
+
* List incidents with filtering and pagination
|
|
1399
|
+
*
|
|
1400
|
+
* @param params - Filter and pagination options
|
|
1401
|
+
* @returns IncidentsResponse with list of incidents and pagination info
|
|
1402
|
+
*
|
|
1403
|
+
* @example
|
|
1404
|
+
* ```typescript
|
|
1405
|
+
* // Get all open incidents
|
|
1406
|
+
* const result = await client.dataQuality.listIncidents({ status: 'open' });
|
|
1407
|
+
* for (const incident of result.incidents) {
|
|
1408
|
+
* console.log(`${incident.severity}: ${incident.title}`);
|
|
1409
|
+
* }
|
|
1410
|
+
* ```
|
|
1411
|
+
*/
|
|
1412
|
+
listIncidents(params?: ListIncidentsParams): Promise<IncidentsResponse>;
|
|
1413
|
+
/**
|
|
1414
|
+
* Get a specific incident by ID
|
|
1415
|
+
*
|
|
1416
|
+
* @param incidentId - The incident ID
|
|
1417
|
+
* @returns Incident details
|
|
1418
|
+
*
|
|
1419
|
+
* @example
|
|
1420
|
+
* ```typescript
|
|
1421
|
+
* const incident = await client.dataQuality.getIncident('inc_123');
|
|
1422
|
+
* console.log(`Status: ${incident.status}`);
|
|
1423
|
+
* console.log(`Root cause: ${incident.rootCause}`);
|
|
1424
|
+
* ```
|
|
1425
|
+
*/
|
|
1426
|
+
getIncident(incidentId: string): Promise<Incident>;
|
|
1427
|
+
/**
|
|
1428
|
+
* Get current latency metrics for all exchanges
|
|
1429
|
+
*
|
|
1430
|
+
* @returns LatencyResponse with WebSocket, REST API, and data freshness metrics
|
|
1431
|
+
*
|
|
1432
|
+
* @example
|
|
1433
|
+
* ```typescript
|
|
1434
|
+
* const latency = await client.dataQuality.latency();
|
|
1435
|
+
* for (const [exchange, metrics] of Object.entries(latency.exchanges)) {
|
|
1436
|
+
* console.log(`${exchange}:`);
|
|
1437
|
+
* if (metrics.websocket) {
|
|
1438
|
+
* console.log(` WS current: ${metrics.websocket.currentMs}ms`);
|
|
1439
|
+
* }
|
|
1440
|
+
* console.log(` OB lag: ${metrics.dataFreshness.orderbookLagMs}ms`);
|
|
1441
|
+
* }
|
|
1442
|
+
* ```
|
|
1443
|
+
*/
|
|
1444
|
+
latency(): Promise<LatencyResponse>;
|
|
1445
|
+
/**
|
|
1446
|
+
* Get SLA compliance metrics for a specific month
|
|
1447
|
+
*
|
|
1448
|
+
* @param params - Optional year and month (defaults to current month)
|
|
1449
|
+
* @returns SlaResponse with SLA targets, actual metrics, and compliance status
|
|
1450
|
+
*
|
|
1451
|
+
* @example
|
|
1452
|
+
* ```typescript
|
|
1453
|
+
* const sla = await client.dataQuality.sla({ year: 2026, month: 1 });
|
|
1454
|
+
* console.log(`Period: ${sla.period}`);
|
|
1455
|
+
* console.log(`Uptime: ${sla.actual.uptime}% (${sla.actual.uptimeStatus})`);
|
|
1456
|
+
* console.log(`Completeness: ${sla.actual.dataCompleteness.overall}%`);
|
|
1457
|
+
* console.log(`API P99: ${sla.actual.apiLatencyP99Ms}ms`);
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
sla(params?: SlaParams): Promise<SlaResponse>;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1029
1463
|
/**
|
|
1030
1464
|
* Hyperliquid exchange client
|
|
1031
1465
|
*
|
|
@@ -1158,6 +1592,10 @@ declare class OxArchive {
|
|
|
1158
1592
|
* Lighter.xyz exchange data (August 2025+)
|
|
1159
1593
|
*/
|
|
1160
1594
|
readonly lighter: LighterClient;
|
|
1595
|
+
/**
|
|
1596
|
+
* Data quality metrics: status, coverage, incidents, latency, SLA
|
|
1597
|
+
*/
|
|
1598
|
+
readonly dataQuality: DataQualityResource;
|
|
1161
1599
|
/**
|
|
1162
1600
|
* @deprecated Use client.hyperliquid.orderbook instead
|
|
1163
1601
|
*/
|
|
@@ -1257,6 +1695,7 @@ declare class OxArchiveWs {
|
|
|
1257
1695
|
private streamCompleteHandlers;
|
|
1258
1696
|
private orderbookHandlers;
|
|
1259
1697
|
private tradesHandlers;
|
|
1698
|
+
private gapHandlers;
|
|
1260
1699
|
constructor(options: WsOptions);
|
|
1261
1700
|
/**
|
|
1262
1701
|
* Connect to the WebSocket server
|
|
@@ -1418,6 +1857,23 @@ declare class OxArchiveWs {
|
|
|
1418
1857
|
* Handle stream completed event
|
|
1419
1858
|
*/
|
|
1420
1859
|
onStreamComplete(handler: (channel: WsChannel, coin: string, snapshotsSent: number) => void): void;
|
|
1860
|
+
/**
|
|
1861
|
+
* Handle gap detected events during replay or streaming.
|
|
1862
|
+
* Called when there's a gap in the historical data exceeding the threshold.
|
|
1863
|
+
* Thresholds: 2 minutes for orderbook/candles/liquidations, 60 minutes for trades.
|
|
1864
|
+
*
|
|
1865
|
+
* @param handler - Callback receiving channel, coin, gap start/end timestamps (ms), and duration (minutes)
|
|
1866
|
+
*
|
|
1867
|
+
* @example
|
|
1868
|
+
* ```typescript
|
|
1869
|
+
* ws.onGap((channel, coin, gapStart, gapEnd, durationMinutes) => {
|
|
1870
|
+
* console.warn(`Gap detected in ${channel} ${coin}: ${durationMinutes} minutes`);
|
|
1871
|
+
* console.warn(` From: ${new Date(gapStart).toISOString()}`);
|
|
1872
|
+
* console.warn(` To: ${new Date(gapEnd).toISOString()}`);
|
|
1873
|
+
* });
|
|
1874
|
+
* ```
|
|
1875
|
+
*/
|
|
1876
|
+
onGap(handler: (channel: WsChannel, coin: string, gapStart: number, gapEnd: number, durationMinutes: number) => void): void;
|
|
1421
1877
|
/**
|
|
1422
1878
|
* Get current connection state
|
|
1423
1879
|
*/
|
|
@@ -1788,8 +2244,8 @@ declare const CandleSchema: z.ZodObject<{
|
|
|
1788
2244
|
quoteVolume: z.ZodOptional<z.ZodNumber>;
|
|
1789
2245
|
tradeCount: z.ZodOptional<z.ZodNumber>;
|
|
1790
2246
|
}, "strip", z.ZodTypeAny, {
|
|
1791
|
-
timestamp: string;
|
|
1792
2247
|
open: number;
|
|
2248
|
+
timestamp: string;
|
|
1793
2249
|
high: number;
|
|
1794
2250
|
low: number;
|
|
1795
2251
|
close: number;
|
|
@@ -1797,8 +2253,8 @@ declare const CandleSchema: z.ZodObject<{
|
|
|
1797
2253
|
quoteVolume?: number | undefined;
|
|
1798
2254
|
tradeCount?: number | undefined;
|
|
1799
2255
|
}, {
|
|
1800
|
-
timestamp: string;
|
|
1801
2256
|
open: number;
|
|
2257
|
+
timestamp: string;
|
|
1802
2258
|
high: number;
|
|
1803
2259
|
low: number;
|
|
1804
2260
|
close: number;
|
|
@@ -3082,8 +3538,8 @@ declare const CandleArrayResponseSchema: z.ZodObject<{
|
|
|
3082
3538
|
quoteVolume: z.ZodOptional<z.ZodNumber>;
|
|
3083
3539
|
tradeCount: z.ZodOptional<z.ZodNumber>;
|
|
3084
3540
|
}, "strip", z.ZodTypeAny, {
|
|
3085
|
-
timestamp: string;
|
|
3086
3541
|
open: number;
|
|
3542
|
+
timestamp: string;
|
|
3087
3543
|
high: number;
|
|
3088
3544
|
low: number;
|
|
3089
3545
|
close: number;
|
|
@@ -3091,8 +3547,8 @@ declare const CandleArrayResponseSchema: z.ZodObject<{
|
|
|
3091
3547
|
quoteVolume?: number | undefined;
|
|
3092
3548
|
tradeCount?: number | undefined;
|
|
3093
3549
|
}, {
|
|
3094
|
-
timestamp: string;
|
|
3095
3550
|
open: number;
|
|
3551
|
+
timestamp: string;
|
|
3096
3552
|
high: number;
|
|
3097
3553
|
low: number;
|
|
3098
3554
|
close: number;
|
|
@@ -3115,8 +3571,8 @@ declare const CandleArrayResponseSchema: z.ZodObject<{
|
|
|
3115
3571
|
}>;
|
|
3116
3572
|
}, "strip", z.ZodTypeAny, {
|
|
3117
3573
|
data: {
|
|
3118
|
-
timestamp: string;
|
|
3119
3574
|
open: number;
|
|
3575
|
+
timestamp: string;
|
|
3120
3576
|
high: number;
|
|
3121
3577
|
low: number;
|
|
3122
3578
|
close: number;
|
|
@@ -3132,8 +3588,8 @@ declare const CandleArrayResponseSchema: z.ZodObject<{
|
|
|
3132
3588
|
};
|
|
3133
3589
|
}, {
|
|
3134
3590
|
data: {
|
|
3135
|
-
timestamp: string;
|
|
3136
3591
|
open: number;
|
|
3592
|
+
timestamp: string;
|
|
3137
3593
|
high: number;
|
|
3138
3594
|
low: number;
|
|
3139
3595
|
close: number;
|
|
@@ -3257,4 +3713,4 @@ type ValidatedCandle = z.infer<typeof CandleSchema>;
|
|
|
3257
3713
|
type ValidatedLiquidation = z.infer<typeof LiquidationSchema>;
|
|
3258
3714
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
3259
3715
|
|
|
3260
|
-
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, HyperliquidClient, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationsByUserParams, type OpenInterest, OpenInterestArrayResponseSchema, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookResponseSchema, OrderBookSchema, OxArchive, OxArchiveError, OxArchiveWs, type PriceLevel, PriceLevelSchema, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default };
|
|
3716
|
+
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataFreshness, type DataTypeCoverage, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OpenInterest, OpenInterestArrayResponseSchema, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookResponseSchema, OrderBookSchema, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceLevel, PriceLevelSchema, type RestApiLatency, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default };
|