You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
3 years ago
|
using Binance.Net.Clients;
|
||
|
using Binance.Net.Enums;
|
||
|
using System.Threading;
|
||
|
|
||
|
namespace SDKAdapter.WebSockets.Market
|
||
|
{
|
||
|
public class BinanceSpotMarketWebSocketClient : SpotMarketWebSocketClient
|
||
|
{
|
||
|
private BinanceSocketClient client;
|
||
|
private CancellationTokenSource cancellationTokenSource;
|
||
|
|
||
|
public BinanceSpotMarketWebSocketClient(string symbol, NLog.ILogger logger) : base(symbol, logger)
|
||
|
{
|
||
|
client = new BinanceSocketClient();
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void Start()
|
||
|
{
|
||
|
cancellationTokenSource = new CancellationTokenSource();
|
||
|
client.SpotStreams.SubscribeToKlineUpdatesAsync(Symbol, KlineInterval.OneMinute, (e) =>
|
||
|
{
|
||
|
base.OnReceived(e.Data.Data.ClosePrice);
|
||
|
}, cancellationTokenSource.Token);
|
||
|
base.Start();
|
||
|
}
|
||
|
|
||
|
public override void Stop()
|
||
|
{
|
||
|
cancellationTokenSource.Cancel();
|
||
|
client.SpotStreams.Dispose();
|
||
|
base.Stop();
|
||
|
cancellationTokenSource = null;
|
||
|
}
|
||
|
}
|
||
|
}
|