Skip to content

Commit

Permalink
ohlcv latency fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Svisstack committed Mar 29, 2024
1 parent be0b48d commit ec85c33
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions data-api/csharp-ws/CoinAPI.WebSocket.Stats.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public async Task MakeRequest([FromService] IConfiguration configuration, string
wsClient.TradeEvent += (s, i) => { ProcessMsg(i.time_exchange, i.time_coinapi, latencyType); };
break;
case "ohlcv":
wsClient.OHLCVEvent += (s, i) => { ProcessMsg(null, null, latencyType); };
wsClient.OHLCVEvent += (s, i) => { ProcessMsg(i.time_close, null, latencyType); };
break;
case "exrate":
wsClient.ExchangeRateEvent += (s, i) => { msgCount++; };
Expand Down Expand Up @@ -185,20 +185,17 @@ void WsClient_Error(object? sender, Exception e)
private void ProcessMsg(DateTime? time_exchange, DateTime? time_coinapi, LatencyType latencyType)
{
msgCount++;
if (time_coinapi.HasValue && time_exchange.HasValue)
if (latencyType == LatencyType.nc && time_coinapi.HasValue)
{
switch (latencyType)
{
case LatencyType.nc:
latencyList.Add((DateTime.UtcNow, time_coinapi.Value));
break;
case LatencyType.ne:
latencyList.Add((DateTime.UtcNow, time_exchange.Value));
break;
case LatencyType.ce:
latencyList.Add((time_coinapi.Value, time_exchange.Value));
break;
}
latencyList.Add((DateTime.UtcNow, time_coinapi.Value));
}
else if (latencyType == LatencyType.ne && time_exchange.HasValue)
{
latencyList.Add((DateTime.UtcNow, time_exchange.Value));
}
else if (latencyType == LatencyType.ce && time_coinapi.HasValue && time_exchange.HasValue)
{
latencyList.Add((time_coinapi.Value, time_exchange.Value));
}
}

Expand Down

0 comments on commit ec85c33

Please sign in to comment.