private static void UseFtxWsOrderBooks(ILoggerFactory loggerFactory) { var client = new FtxWsOrderBooks(loggerFactory.CreateLogger <FtxWsOrderBooks>(), new [] { "BTC/USD" }); client.Start(); bool log = true; client.ReceiveUpdates = book => { if (log) { Console.WriteLine($"Receive updates for {book.id}"); } log = false; return(Task.CompletedTask); }; var cmd = Console.ReadLine(); while (cmd != "exit") { if (cmd == "count") { var books = client.GetOrderBooks().Count; Console.WriteLine($"Count books: {books}"); } else if (cmd == "reset") { client.Reset("BTC/USD").Wait(); } else if (cmd == "time") { var book = client.GetOrderBookById("BTC/USD"); Console.WriteLine($"nw: {DateTimeOffset.UtcNow:O}"); Console.WriteLine($"t1: {book.GetTime():O}"); client.Reset("BTC/USD").Wait(); } else { var orderBook = client.GetOrderBookById(cmd); if (orderBook != null) { Console.WriteLine($"{orderBook.id} {orderBook.GetTime():O} {orderBook.asks.Count}|{orderBook.bids.Count}"); } else { Console.WriteLine("Not found"); } } cmd = Console.ReadLine(); } }
public async Task Resubscribe(string symbol) { await _wsFtx.Reset(symbol); }