feat(): add all symbols allLiquidaitons ws example

This commit is contained in:
tiagosiebler
2025-02-26 10:16:39 +00:00
parent 568d4517cb
commit 5005b816b3
2 changed files with 129 additions and 0 deletions

View File

@@ -14,6 +14,29 @@ import {
WSPositionEventV5,
} from '../types/websockets/ws-events';
export interface BybitEventV5<TData = unknown> {
topic: string;
type: string;
ts: number;
data: TData;
wsKey: string;
}
export function isWsEventV5<TEventData = unknown>(
event: unknown,
): event is BybitEventV5<TEventData> {
if (
typeof event !== 'object' ||
!event ||
typeof event['topic'] !== 'string' ||
typeof event['type'] !== 'string'
) {
return false;
}
return true;
}
/**
* Type guard to detect a V5 orderbook event (delta & snapshots)
*
@@ -141,3 +164,17 @@ export function isTopicSubscriptionConfirmation(
return true;
}
export function isWsAllLiquidationEvent(
event: unknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): event is BybitEventV5<any[]> {
if (!isWsEventV5(event)) {
return false;
}
if (event['topic'].startsWith('allLiquidation')) {
return true;
}
return false;
}