private void UpdateStockPrice(RealTimePositionObject r) { if (StockPrices.ContainsKey(r.Cusip)) { StockPriceViewObject s = null; StockPrices.TryGetValue(r.Cusip, out s); if (s != null) { r.Price = (double)s.StockloanPrice; } else { r.Price = 0; } } }
private void ProcessOrders(IncomingDeliveryOrderObject d) { try { /*if (d.Cusip == "493267108") * { * int c = 2; * }*/ this.Text = "Price Control - " + DateTime.Now.ToString(); PriceControlDeliveryOrder d2 = new PriceControlDeliveryOrder(d); if (calc.StockPrices.ContainsKey(d2.Cusip)) { StockPriceViewObject s = null; calc.StockPrices.TryGetValue(d2.Cusip, out s); if (s != null) { d2.Price = (double)s.Price; } } double priceDiff = Math.Abs(d.MoneyValue.Value - (d2.Price * d.ShareQuantity.Value)); if ((d.DtcStatusIndicator == " " || d.DtcStatusIndicator == "X") && (d.OriginalInputSource != "CNS") && (d2.Price > 0) && ((d.MoneyValue / d.ShareQuantity) > d2.MaxPrice || (d.MoneyValue / d.ShareQuantity) < d2.MinPrice) && (d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.Borrow || d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.Loan || d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.BorrowReclaimed || d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.LoanReclaimed) && (d.Receiver == Settings.Account.Padded() || d.Deliverer == Settings.Account.Padded()) ) { d2.PriceDiff = priceDiff; ProblemOrders.Add(d2); } if ((d.DtcStatusIndicator == " " || d.DtcStatusIndicator == "X") && (d.OriginalInputSource != "CNS") && (d2.Price > 0) && (d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.Borrow || d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.Loan || d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.BorrowReclaimed || d.DeliveryOrderDirection == DeliveryOrderDirectionEnum.LoanReclaimed) && (d.Receiver == Settings.Account.Padded() || d.Deliverer == Settings.Account.Padded()) ) { if (!Orders.ContainsKey(d2.Cusip)) { List <PriceControlDeliveryOrder> p = new List <PriceControlDeliveryOrder>(); p.Add(d2); Orders.Add(d2.Cusip, p); } else { //check to see if an order for a different price had come in List <PriceControlDeliveryOrder> p = Orders[d2.Cusip]; int i = p.Count(x => (x.MoneyValue / x.ShareQuantity) != (d2.MoneyValue / d2.ShareQuantity) && (x.Deliverer == d2.Deliverer || x.Deliverer == d2.Receiver)); if (i != 0) { DifferentPricedOrders.Add(d2); } //add to list of orders Orders[d2.Cusip].Add(d2); } } } catch (Exception) { throw; } }