JKorf / FTX.Net

MIT License
31 stars 24 forks source link

Subscribe to Ticker List updates without performance problem #21

Closed glikoz closed 2 years ago

glikoz commented 2 years ago

I have to write such kind of code to subscribe ticker updates for symbol list:

foreach (var symbol in symbols) { var res=await socketClient.SubscribeToTickerUpdatesAsync(symbol, async bookPrice => {});

Does It cause a performance problem for my system? Is there any way to combine these subscriptions to get rid of performance problems?

Thx for advance.

JKorf commented 2 years ago

It depends, if you can handle the data coming in fast enough then it's fine. The library will automatically combine 10 subscriptions on a single connection, which you could increase with the SocketSubscriptionsCombineTarget client option.

There is not really a way to combine the call for multiple symbols as the API only support a subscription per symbol. So if I we're to accept multiple symbols in the call it would mean doing the same as you're doing now; just looping over the symbols.