Skip to content

Commit 3d33f06

Browse files
codez0mb1eCopilot
andauthored
Push reuse logic to GetOrderBookSnapshotAsync()
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 40377c5 commit 3d33f06

1 file changed

Lines changed: 1 addition & 19 deletions

File tree

src/BinanceBot.Market/MarketDepthManager.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,25 +163,7 @@ 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-
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-
}
166+
response = await GetOrderBookSnapshotAsync(marketDepth.Symbol, orderBookDepth, ct).ConfigureAwait(false);
185167

186168
if (!response.Success || response.Data == null)
187169
throw new InvalidOperationException($"Failed to get order book snapshot: {response.Error?.Message}");

0 commit comments

Comments
 (0)