JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.05k stars 429 forks source link

[Feature Request] Original Json #736

Closed ehajri closed 3 years ago

ehajri commented 3 years ago

In some scenarios, I'd need to store the result of the update streams as is, and to do that, I am serializing the object that Binance.Net has just deserialized. Example:

var stream= await _binanceSocketClient.Spot.SubscribeToTradeUpdatesAsync(symbol, async data =>
{
    var json = JsonSerializer.Serialize(data);
    await _redis.GetDatabase().PublishAsync("tradeStream", json);
});

running the app against a profiler shows a lot of time and memory are being utilized with .Serialize(). Is it possible to add a property/method to retrieve the original Json text? Something like data.Text

So far, the areas I am concerned about is Spot.SubscribeTo.. and Spot.SubscribeToUserDataUpdatesAsync().

ehajri commented 3 years ago

@HypsyNZ thank you for the workaround.

Indeed the file is growing so fast, and it doesn't seem I can assign logwriter for each sub.

JKorf commented 3 years ago

Hi, in the latest beta releases I've added an option for this. If you enable OutputOriginalData in the client options, the WebCallResult and DataEvent (new wrapper for socket updates) objects will contain the originally received json in the OriginalData property.

ehajri commented 3 years ago

@JKorf Thanks!