Skip to content

Commit 5390207

Browse files
committed
Revert "Push reuse logic to GetOrderBookSnapshotAsync()"
This reverts commit 3d33f06.
1 parent 3d33f06 commit 5390207

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/BinanceBot.Market/MarketDepthManager.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)