private void PortfolioSpotNumberUpdated(long id, object[,] table) { int countElem = table.GetLength(0); if (countElem == 0) { return; } for (int i = 0; i < countElem; i++) { string firm = table[i, 0].ToString(); if (firm.Length != firm.Replace("SPBFUT", "").Length) { return; } string numberPortfolio = table[i, 1].ToString(); Portfolio myPortfolio = _portfolios.Find(portfolio => portfolio.Number == numberPortfolio); if (myPortfolio == null) { myPortfolio = new Portfolio(); myPortfolio.Number = numberPortfolio; _portfolios.Add(myPortfolio); QuikPortfolio data = new QuikPortfolio(); data.Firm = firm; data.Number = numberPortfolio; _portfoliosQuik.Add(data); } } }
// 3) порфели и спот и деривативы private void PortfolioSpotUpdated(long id, object[,] table) { int countElem = table.GetLength(0); if (countElem == 0) { return; } for (int i = 0; i < countElem; i++) { string firm = table[i, 0].ToString(); if (firm.Length != firm.Replace("SPBFUT", "").Length) { return; } decimal valueBegin = ToDecimal(table[i, 1]); decimal profitLoss = ToDecimal(table[i, 3]); decimal valueCurrent = valueBegin + profitLoss; decimal valueBlock = valueCurrent - ToDecimal(table[i, 2]); if (valueBegin == 0 && valueBlock == 0 && profitLoss == 0) { return; } string portfolioClient = table[i, 4].ToString(); QuikPortfolio data = _portfoliosQuik.Find(port => port.Firm == firm); if (data == null) { PortfolioReturner r = new PortfolioReturner(); r.Long = id; r.Objects = table; r.PortfolioUpdate += PortfolioSpotUpdated; Thread worker = new Thread(r.Start); worker.IsBackground = true; worker.Start(); return; } Portfolio portfolioWithoutClient = _portfolios.Find(portfolio => portfolio.Number == data.Number); if (portfolioWithoutClient != null) { portfolioWithoutClient.Number = data.Number + "@" + portfolioClient; } Portfolio myPortfolio = _portfolios.Find(portfolio => portfolio.Number == data.Number + "@" + portfolioClient); if (myPortfolio == null) { continue; } myPortfolio.ValueBegin = valueBegin; myPortfolio.ValueCurrent = valueCurrent; myPortfolio.ValueBlocked = valueBlock; myPortfolio.Profit = profitLoss; if (UpdatePortfolios != null) { UpdatePortfolios(_portfolios); } } }