public void LoadCurrentDeals() { _deals = _dbManager.GetAllDeals(); ResetInstrumentPosition(); foreach (var deal in _deals) { ObsInstruPosition pos; if (!_currentPosDico.TryGetValue(deal.InstrumentId, out pos)) { var newPos = new ObsInstruPosition(deal); _currentPosDico.Add(deal.InstrumentId, newPos); ObsPositions.Add(newPos); continue; } Pnl.ComputeInstrumentPosition(pos, deal); } ResetBookPosition(); foreach (ObsInstruPosition instruPos in _currentPosDico.Values) { ObsBookPosition pos; if (!_bookPositionDico.TryGetValue(instruPos.Book, out pos)) { var newPos = new ObsBookPosition(instruPos); _bookPositionDico.Add(instruPos.Book, newPos); ObsBookPosition.Add(newPos); return; } Pnl.ComputeBookPosition(pos, instruPos); } foreach (ObsInstruPosition instruPos in _expiredPosDico.Values) { ObsBookPosition pos; if (!_bookPositionDico.TryGetValue(instruPos.Book, out pos)) { var newPos = new ObsBookPosition(instruPos); _bookPositionDico.Add(instruPos.Book, newPos); ObsBookPosition.Add(newPos); return; } Pnl.ComputeBookPosition(pos, instruPos); } }
public void RemoveDeal(object obj) { _dbManager.RemoveDeal(SelectedDeal.DealId); CloseAction(); _currentPosDico.Clear(); ObsPositions.Clear(); ObsDeals.Clear(); LoadCurrentDeals(); foreach (var deal in _deals) { if (deal?.InstrumentId == SelectedObsInstruPosition?.InstruRic) { ObsDeals.Add(deal); } } }