/// <summary>
        /// Сохранить текущее портфолио в БД
        /// </summary>
        /// <returns></returns>
        public async Task SaveCurrentPortfolioBDAsync()
        {
            var portfolio = await GetPortfolioCurrencyAsync(Tinkoff.Trading.OpenApi.Models.Currency.Rub);

            _context.PortfolioHistory.Add(new PortfolioHistory()
            {
                balance  = (double)portfolio.Balance,
                currency = CurrencyEnum.Rub,
                time     = ServerTime.GetDate()
            });

            await _context.SaveChangesAsync();
        }
        public async Task <OperationHistory> PlaceMarketOrderAsync(string figi, int lots, OperationType operationType, StopLossData stopLoss, TakeProfitData takeProfit)
        {
            var result = await _contextApi.PlaceMarketOrderAsync(figi, lots, operationType);

            if (stopLoss == null)
            {
                stopLoss = new StopLossData();
            }
            if (takeProfit == null)
            {
                takeProfit = new TakeProfitData();
            }

            var operationHistory = new OperationHistory
            {
                orderType       = (operationType == OperationType.Buy) ? TinkoffApi.Data.Enums.OrderType.Buy : TinkoffApi.Data.Enums.OrderType.Sell,
                lots            = lots,
                figi            = figi,
                orderMode       = _contextApi.GetMode(),
                time            = ServerTime.GetDate(),
                orderId         = result.OrderId,
                operationStatus = TinkoffApi.Data.Enums.OperationStatus.Progress,
                Commission      = new TinkoffApi.Data.Models.MoneyAmount(),
                Price           = 0.0,
                StopLoss        = stopLoss,
                TakeProfit      = takeProfit
            };

            _context.OperationsHistory.Add(operationHistory);

            await SaveCurrentPortfolioBDAsync();

            await _context.SaveChangesAsync();

            _backgroundService.TaskFindOperation(_contextApi, figi, result.OrderId);

            return(operationHistory);
        }