forked from ridicoulous/HitBtc.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HitBtcSymbolOrderBook.cs
40 lines (35 loc) · 1.5 KB
/
HitBtcSymbolOrderBook.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.OrderBook;
using CryptoExchange.Net.Sockets;
using HitBtc.Net.Objects.Socket;
using System.Threading.Tasks;
namespace HitBtc.Net
{
public class HitBtcSymbolOrderBook : SymbolOrderBook
{
private static HitBtcSymbolOrderBookOptions defaultoptions = new HitBtcSymbolOrderBookOptions(nameof(HitBtcSymbolOrderBookOptions), true, false);
private readonly HitBtcSocketClient hitBtcSocketClient;
public HitBtcSymbolOrderBook(string symbol):this(symbol, defaultoptions)
{
}
public HitBtcSymbolOrderBook(string symbol, HitBtcSymbolOrderBookOptions options) : base(symbol, options)
{
hitBtcSocketClient = new HitBtcSocketClient();
}
public override void Dispose()
{
asks.Clear();
bids.Clear();
}
protected override async Task<CallResult<bool>> DoResyncAsync()
{
return await Task.Run(() => new CallResult<bool>(true,null));
}
protected override async Task<CallResult<UpdateSubscription>> DoStartAsync()
{
hitBtcSocketClient.OnOrderBookUpdate += book => UpdateOrderBook(book.Data.Sequence, book.Data.Bids, book.Data.Asks);
hitBtcSocketClient.OnOrderBookSnapshot += book => SetInitialOrderBook(book.Data.Sequence, book.Data.Bids, book.Data.Asks);
return await hitBtcSocketClient.SubscribeAsync(new HitBtcSubscribeToOrderBookRequest(Symbol));
}
}
}