示例#1
0
        public async Task Handle(NewTradesCheckEvent @event)
        {
            try
            {
                var lastChecked = await _bus.QueryAsync(new LastCheckedQuery(Constants.Binance));

                var orderHistory = await _exchangeService.GetOrderHistory(lastChecked.LastChecked - TimeSpan.FromDays(2));

                var newTradesResponse = await _bus.QueryAsync(new FindNewTradeQuery(orderHistory));

                await _bus.SendAsync(new AddLastCheckedCommand(Constants.Binance));

                await SendAndCheckNotifications(newTradesResponse);
                await SendOpenOrdersNotifications(lastChecked.LastChecked);
            }
            catch (Exception ex)
            {
                _log.LogError("Error in getting new orders from Binance\n" + ex.Message);
                throw;
            }
        }