@@ -19,7 +19,7 @@ export interface GeminiWebSocketConfig {
1919 * Gemini Titan WebSocket for real-time order book and trade streaming.
2020 *
2121 * Subscribes to:
22- * - {symbol}@depth 20 (L2 partial depth snapshots at 1s intervals)
22+ * - {symbol}@depth @100ms (full depth snapshots/deltas at 100ms intervals)
2323 * - {symbol}@trade (executed trades)
2424 *
2525 * Auth headers are sent during the handshake if credentials are provided
@@ -75,7 +75,7 @@ export class GeminiWebSocket {
7575 // Resubscribe on reconnect
7676 const allStreams : string [ ] = [ ] ;
7777 for ( const sym of this . subscribedDepthSymbols ) {
78- allStreams . push ( ` ${ sym } @depth20` ) ;
78+ allStreams . push ( this . depthStream ( sym ) ) ;
7979 }
8080 for ( const sym of this . subscribedTradeSymbols ) {
8181 allStreams . push ( `${ sym } @trade` ) ;
@@ -152,7 +152,7 @@ export class GeminiWebSocket {
152152
153153 private handleMessage ( message : any ) : void {
154154 // Gemini sends flat objects, NOT wrapped in { stream, data }.
155- // Depth snapshots: { lastUpdateId, symbol , bids, asks }
155+ // Depth snapshots: { lastUpdateId, s , bids, asks }
156156 // Depth deltas: { e, E, s, U, u, b, a }
157157 // Trades: { E, s, t, p, q, m }
158158 // Confirmations: { id, status: 200 }
@@ -171,7 +171,12 @@ export class GeminiWebSocket {
171171 private handleDepthSnapshot ( data : any ) : void {
172172 // symbol comes back lowercase from the API, but we subscribed with
173173 // uppercase. Normalize to uppercase for resolver lookup.
174- const symbol = ( data . symbol as string ) . toUpperCase ( ) ;
174+ const rawSymbol = data . s ?? data . symbol ;
175+ if ( typeof rawSymbol !== 'string' || rawSymbol . length === 0 ) {
176+ logger . warn ( '[gemini-titan] depth snapshot missing symbol field' ) ;
177+ return ;
178+ }
179+ const symbol = rawSymbol . toUpperCase ( ) ;
175180
176181 const bids : OrderLevel [ ] = ( data . bids ?? [ ] ) . map ( ( level : [ string , string ] ) => ( {
177182 price : parseFloat ( level [ 0 ] ) ,
@@ -277,7 +282,7 @@ export class GeminiWebSocket {
277282 }
278283 } ) ;
279284 } else {
280- this . sendSubscribe ( [ ` ${ symbol } @depth20` ] ) ;
285+ this . sendSubscribe ( [ this . depthStream ( symbol ) ] ) ;
281286 }
282287
283288 const dataPromise = new Promise < OrderBook > ( ( resolve , reject ) => {
@@ -338,6 +343,10 @@ export class GeminiWebSocket {
338343 ) ;
339344 }
340345
346+ private depthStream ( symbol : string ) : string {
347+ return `${ symbol } @depth@100ms` ;
348+ }
349+
341350 async close ( ) : Promise < void > {
342351 this . isTerminated = true ;
343352
0 commit comments