@@ -163,7 +163,25 @@ public async Task BuildAsync(MarketDepth marketDepth, short orderBookDepth = 10,
163163 {
164164 _logger . Warn ( $ "Snapshot too old: LastUpdateId={ snapshot . LastUpdateId } < FirstEvent.U={ firstEvent . FirstUpdateId } . Retrying...") ;
165165 // Snapshot is too old, need to get a new one
166- response = await GetOrderBookSnapshotAsync ( marketDepth . Symbol , orderBookDepth , ct ) . ConfigureAwait ( false ) ;
166+ switch ( marketDepth . Symbol . ContractType )
167+ {
168+ case ContractType . Spot :
169+ WebCallResult < BinanceOrderBook > spotResponse = await _restClient . SpotApi . ExchangeData . GetOrderBookAsync (
170+ marketDepth . Symbol . FullName , orderBookDepth , ct )
171+ . ConfigureAwait ( false ) ;
172+
173+ response = ( spotResponse . Success , spotResponse . Data , spotResponse . Error ) ;
174+ break ;
175+ case ContractType . Futures :
176+ WebCallResult < BinanceFuturesOrderBook > futuresResponse = await _restClient . UsdFuturesApi . ExchangeData . GetOrderBookAsync (
177+ marketDepth . Symbol . FullName , orderBookDepth , ct )
178+ . ConfigureAwait ( false ) ;
179+
180+ response = ( futuresResponse . Success , futuresResponse . Data , futuresResponse . Error ) ;
181+ break ;
182+ default :
183+ throw new ArgumentOutOfRangeException ( nameof ( marketDepth . Symbol . ContractType ) , "Unknown contract type." ) ;
184+ }
167185
168186 if ( ! response . Success || response . Data == null )
169187 throw new InvalidOperationException ( $ "Failed to get order book snapshot: { response . Error ? . Message } ") ;
0 commit comments