10 changed files with 225 additions and 16 deletions
@ -0,0 +1,36 @@ |
|||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace SDKAdapter.WebSockets.Market |
||||
|
{ |
||||
|
public class GateIOSpotMarketWebSocketClient : SpotMarketWebSocketClient |
||||
|
{ |
||||
|
public GateIOSpotMarketWebSocketClient(string symbol, NLog.ILogger logger) : base(symbol, logger) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue