Skip to content

Commit

Permalink
"Extended IOKXSocketClientUnifiedApiExchangeData to give the possibil…
Browse files Browse the repository at this point in the history
…ity to subscribe on ticker updates for mutiple symbols. (#34)

Ex:
{   "op": "subscribe",   "args": [     {       "channel": "tickers",       "instId": "BTC-USDT"     } , {       "channel": "tickers",       "instId": "BTC-BRL"     }     ] }"
[feat/add-support-for-subscribe-on-multiple-symbols 911565e] Extended IOKXSocketClientUnifiedApiExchangeData to give the possibility to subscribe on ticker updates for multiple symbols. Ex: {   op: subscribe,   args: [     {       channel: tickers,       instId: BTC-USDT     } , {       channel: tickers,       instId: BTC-BRL     }     ] }
  • Loading branch information
SimonRiis authored Mar 28, 2024
1 parent dc33db0 commit 3847362
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ public virtual async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdat
return await _client.SubscribeInternalAsync(_client.GetUri("/ws/v5/public"), subscription, ct).ConfigureAwait(false);
}


/// <inheritdoc />
public virtual async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<OKXTicker>> onData, CancellationToken ct = default)
{
var symbolSubs = symbols.Select(symbol =>
new Objects.Sockets.Models.OKXSocketArgs
{
Channel = "tickers",
Symbol = symbol
}
).ToList();

var subscription = new OKXSubscription<OKXTicker>(_logger, symbolSubs , onData, null, false);

return await _client.SubscribeInternalAsync(_client.GetUri("/ws/v5/public"), subscription, ct).ConfigureAwait(false);
}

/// <inheritdoc />
public virtual async Task<CallResult<UpdateSubscription>> SubscribeToOpenInterestUpdatesAsync(string symbol, Action<DataEvent<OKXOpenInterest>> onData, CancellationToken ct = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ public interface IOKXSocketClientUnifiedApiExchangeData
/// <returns></returns>
Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(string symbol, Action<DataEvent<OKXTicker>> onData, CancellationToken ct = default);


/// <summary>
/// Subscribe to the last traded price updates, bid price, ask price and 24-hour trading volume of instruments. Data will be pushed every 100 ms.
/// <para><a href="https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel" /></para>
/// </summary>
/// <param name="symbols">Symbol</param>
/// <param name="onData">On Data Handler</param>
/// <param name="ct">Cancellation Token</param>
/// <returns></returns>
Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(IEnumerable<string> symbols, Action<DataEvent<OKXTicker>> onData, CancellationToken ct = default);

/// <summary>
/// Subscribe to the recent trades data updates. Data will be pushed whenever there is a trade.
/// <para><a href="https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-trades-channel" /></para>
Expand Down

0 comments on commit 3847362

Please sign in to comment.