public override async Task LoadProcess(Action <string> showLogAction) { ShowLogAction = showLogAction; var dataJson = $"Bittrex.json"; var path = Path.Combine(AppContext.BaseDirectory, dataJson); var fileData = await File.ReadAllTextAsync(path); var deserialize = System.Text.Json.JsonSerializer.Deserialize <BittrexSymbolInformation[]>(fileData); var currentDate = DateTime.Now; foreach (var item in deserialize.Where(o => o.QuoteCurrencySymbol == "BTC" && o.Status == "ONLINE")) { CompareMarketDic.TryAdd(item.Symbol, new CompareMarketInformation() { Symbol = item.Symbol, CheckingTime = currentDate }); } _hubConnection = new HubConnection(Endpoint); _hubProxy = _hubConnection.CreateHubProxy("c3"); SetHeartbeatHandler(() => showLogAction("<heartbeat>")); AddMessageHandler <string>("market_summaries", msg => { ProcessMessage <BinanceMarketInformation>(msg); }); }
public override async Task LoadProcess(Action <string> showLogAction) { ShowLogAction = showLogAction; var dataJson = $"Binance.json"; var path = Path.Combine(AppContext.BaseDirectory, dataJson); var fileData = await File.ReadAllTextAsync(path); var deserialize = System.Text.Json.JsonSerializer.Deserialize <BinanceExchangeInformation>(fileData); var currentDate = DateTime.Now; foreach (var item in deserialize.Symbols.Where(o => o.IsMarginTradingAllowed && o.QuoteAsset == "BTC" && o.Status == "TRADING")) { CompareMarketDic.TryAdd(item.Symbol, new CompareMarketInformation() { Symbol = item.Symbol, CheckingTime = currentDate }); } _client = new WebsocketClient(new Uri(Endpoint)) { ReconnectTimeout = TimeSpan.FromSeconds(30) }; _client.ReconnectionHappened.Subscribe(info => showLogAction($"\n Reconnection happened, type: {info.Type}")); _client .MessageReceived .Where(o => o.Text == "ping frame") .ObserveOn(TaskPoolScheduler.Default) .Subscribe(o => _client.Send("pong frame")); _client .MessageReceived .Where(o => o.Text.Contains("BTC\"")) .ObserveOn(TaskPoolScheduler.Default) .Subscribe(o => ProcessMessage <BinanceMarketInformation>(o.Text)); }