示例#1
0
 public void AddToPortfolio(StockPosition sp)
 {
     if (StockPortfolio == null)
     {
         StockPortfolio = new List <StockPosition>();
     }
     StockPortfolio.Add(sp);
     _listTickers.Add(sp.GetTicker());
     _indexedPositions.Add(sp.GetTicker(), sp);
 }
示例#2
0
        public void EditPosition(string getTicker, int newQty, decimal getEntrancePrice)
        {
            if (_indexedPositions.ContainsKey(getTicker))
            {
                StockPosition sp = new StockPosition(getTicker, newQty, getEntrancePrice);

                for (int i = 0; i < StockPortfolio.Count; i++)
                {
                    if (StockPortfolio[i] == _indexedPositions[getTicker])
                    {
                        StockPortfolio[i]            = sp;
                        _indexedPositions[getTicker] = sp;
                    }
                }
            }
            else
            {
                throw new NullReferenceException();
            }
        }