예제 #1
0
        private static void RefreshStrategyMapping(IEnumerable <IBPortfolioModel> ibport, string accountname)
        {
            var _ibstrategymapping = SQLQueryAccessor.GetIbStrategyMapping(accountname);
            var _newmapping        = new List <IBStrategyMapping>();

            foreach (IBPortfolioModel port in ibport)
            {
                if (!_ibstrategymapping.Select(x => x.TickerName).Contains(port.tickerName))
                {
                    _newmapping.Add(new IBStrategyMapping()
                    {
                        TickerName = port.tickerName, AccountName = accountname, LastUpdated = DateTime.Now, IBStrategy = "UNKNOWN"
                    });
                }
            }
            if (_newmapping.Count > 0)
            {
                SQLQueryAccessor.InsertIbStrategyMapping(_newmapping);
                _ibstrategymapping = SQLQueryAccessor.GetIbStrategyMapping(accountname);
            }
            foreach (IBPortfolioModel port in ibport)
            {
                port.strategyName = _ibstrategymapping.Where(x => x.TickerName == port.tickerName && x.AccountName == accountname).Select(x => x.IBStrategy).First();
            }
        }
예제 #2
0
        public static IEnumerable <IBPortfolioModel> UpdatePortfolio(IBCore _ibcore)
        {
            var ibport      = _ibcore._Portfolios;
            var accountname = _ibcore._AccountName;
            var staticdata  = SQLQueryAccessor.GetIbStaticData();

            RefreshStrategyMapping(ibport, accountname);
            RefreshOptionStrategyMapping(ibport);
            RefreshStaticData(ibport, staticdata);

            return(ibport);
        }