private void BeginReceiveTradesHttp() => Task.Run(async() =>
        {
            using (Logger.BeginProtocolScope("Https"))
            {
                var symbols = ExchangeWorker.Configuration.Symbol.Select(symbolCode => SymbolFactory.Get(symbolCode)).Where(symbol => symbol.Tradable);

                while (true)
                {
                    if (!ExchangeWorker.Online)
                    {
                        await Task.Delay(1000);

                        continue;
                    }

                    foreach (var symbol in symbols)
                    {
                        using (Logger.BeginSymbolScope(symbol.Code))
                        {
                            try
                            {
                                var lastTradeFilter = await HistorianRepository.GetTradeFilter(Exchange.Name, symbol.Code);

                                TradeResult result;

                                using (var transaction = await StorageTransactionFactory.Begin())
                                {
                                    result = await ExchangeTradeProvider.ReceiveTradesHttp(transaction, Logger, Exchange.Name, symbol, HttpClient, Limit, lastTradeFilter);

                                    if (result != null)
                                    {
                                        await HistorianRepository.SetTradeFilter(transaction, Exchange.Name, symbol.Code, result.Filter);
                                    }

                                    await transaction.Commit();
                                }

                                if (result == null)
                                {
                                    await Task.Delay(1000);
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.LogError(ex, "Unexpected error occurred");
                            }
                        }
                    }
                }
            }
        });
        private void BeginTradeCatchupWorker(int limit) => Task.Run(async() =>
        {
            using (Logger.BeginProtocolScope("Https"))
            {
                while (true)
                {
                    foreach (var symbolCode in ExchangeWorker.Configuration.Symbol)
                    {
                        using (Logger.BeginSymbolScope(symbolCode))
                        {
                            var symbol = SymbolFactory.Get(symbolCode);

                            if (!symbol.Tradable)
                            {
                                continue;
                            }

                            try
                            {
                                if (!ExchangeWorker.Online)
                                {
                                    await Task.Delay(2000);

                                    continue;
                                }

                                var current = await HistorianRepository.GetNextTradeCatchup(Exchange.Name, symbolCode);

                                if (current == null)
                                {
                                    continue;
                                }

                                TradeResult result = null;

                                using (var transaction = await StorageTransactionFactory.Begin())
                                {
                                    result = await ExchangeTradeProvider.ReceiveTradesHttp(transaction, Logger, Exchange.Name, symbol, HttpClient, limit, current.CurrentTradeFilter);

                                    await transaction.Commit();
                                }

                                if (result == null)
                                {
                                    continue;
                                }

                                var lastTrade = result.Trades.LastOrDefault();

                                if (lastTrade.Epoch.TimestampMilliseconds > current.EpochTo.TimestampMilliseconds)
                                {
                                    await HistorianRepository.RemoveTradeCatchup(current);
                                }
                                else
                                {
                                    current.CurrentTradeFilter = result.Filter;
                                    await HistorianRepository.UpdateTradeCatchup(current);
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.LogError(ex, "Unable to get trade catchup jobs.");
                            }
                        }
                    }
                }
            }
        });