Ejemplo n.º 1
0
        public async Task <List <Line> > AddNewLines(List <Currency> currencies, List <Indicator> indicators)
        {
            // Start watch
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            // Get watchers willing to buy or sell
            var watchers = await _mainDbContext.Watchers.Where(WatcherExpression.WatcherSet()).ToListAsync();

            // Build new lines
            var lines = LineBuilder.BuildLines(currencies, indicators, watchers);

            // Set new lines
            _mainDbContext.Lines.AddRange(lines);

            // Save
            await _mainDbContext.SaveChangesAsync();

            // Stop watch
            stopwatch.Stop();

            // Log
            _logger.LogInformation("{@Event}, {@Count}, {@ExecutionTime}", "NewLinesAdded", lines.Count, stopwatch.Elapsed.TotalSeconds);

            // Return
            return(lines);
        }