Skip to content

Commit ec85c33

Browse files
committed
ohlcv latency fix
1 parent be0b48d commit ec85c33

File tree

1 file changed

+11
-14
lines changed
  • data-api/csharp-ws/CoinAPI.WebSocket.Stats.Console

1 file changed

+11
-14
lines changed

data-api/csharp-ws/CoinAPI.WebSocket.Stats.Console/Program.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public async Task MakeRequest([FromService] IConfiguration configuration, string
149149
wsClient.TradeEvent += (s, i) => { ProcessMsg(i.time_exchange, i.time_coinapi, latencyType); };
150150
break;
151151
case "ohlcv":
152-
wsClient.OHLCVEvent += (s, i) => { ProcessMsg(null, null, latencyType); };
152+
wsClient.OHLCVEvent += (s, i) => { ProcessMsg(i.time_close, null, latencyType); };
153153
break;
154154
case "exrate":
155155
wsClient.ExchangeRateEvent += (s, i) => { msgCount++; };
@@ -185,20 +185,17 @@ void WsClient_Error(object? sender, Exception e)
185185
private void ProcessMsg(DateTime? time_exchange, DateTime? time_coinapi, LatencyType latencyType)
186186
{
187187
msgCount++;
188-
if (time_coinapi.HasValue && time_exchange.HasValue)
188+
if (latencyType == LatencyType.nc && time_coinapi.HasValue)
189189
{
190-
switch (latencyType)
191-
{
192-
case LatencyType.nc:
193-
latencyList.Add((DateTime.UtcNow, time_coinapi.Value));
194-
break;
195-
case LatencyType.ne:
196-
latencyList.Add((DateTime.UtcNow, time_exchange.Value));
197-
break;
198-
case LatencyType.ce:
199-
latencyList.Add((time_coinapi.Value, time_exchange.Value));
200-
break;
201-
}
190+
latencyList.Add((DateTime.UtcNow, time_coinapi.Value));
191+
}
192+
else if (latencyType == LatencyType.ne && time_exchange.HasValue)
193+
{
194+
latencyList.Add((DateTime.UtcNow, time_exchange.Value));
195+
}
196+
else if (latencyType == LatencyType.ce && time_coinapi.HasValue && time_exchange.HasValue)
197+
{
198+
latencyList.Add((time_coinapi.Value, time_exchange.Value));
202199
}
203200
}
204201

0 commit comments

Comments
 (0)