private Position GetPosition(SecurityId securityId, string portfolioName, string strategyId)
        {
            var security = (!securityId.SecurityCode.IsEmpty() && !securityId.BoardCode.IsEmpty() ? _securityStorage.LookupById(securityId) : _securityStorage.Lookup(new Security
            {
                Code = securityId.SecurityCode,
            }).FirstOrDefault()) ?? TryCreateSecurity(securityId);

            if (security == null)
            {
                return(null);
            }

            var portfolio = _positionStorage.LookupByPortfolioName(portfolioName);

            if (portfolio == null)
            {
                portfolio = new Portfolio
                {
                    Name = portfolioName
                };

                _positionStorage.Save(portfolio);
            }

            return(_positionStorage.GetPosition(portfolio, security, strategyId) ?? new Position
            {
                Security = security,
                Portfolio = portfolio,
                StrategyId = strategyId,
            });
        }
        /// <inheritdoc />
        public override Position CreatePosition(Portfolio portfolio, Security security)
        {
            if (_trackPositions)
            {
                var position = _positionStorage.GetPosition(portfolio, security);

                if (position != null)
                {
                    return(position);
                }
            }

            return(base.CreatePosition(portfolio, security));
        }