Exemple #1
0
        private static void AddInFullyExecutedMemory(OrderModel item)
        {
            FullyExecutedModel objFullyExecutedModel = new FullyExecutedModel();

            objFullyExecutedModel.BuySell = item.BuySellIndicator;

            objFullyExecutedModel.ClientID   = item.ClientId;
            objFullyExecutedModel.ClientType = item.ClientType;
            objFullyExecutedModel.OrdID      = item.OrderId;
            objFullyExecutedModel.OrdType    = item.OrderType;
            objFullyExecutedModel.Qty        = item.TradedQty;
            objFullyExecutedModel.ScripID    = item.Symbol;
            objFullyExecutedModel.ScripCode  = item.ScripCode.ToString();
            objFullyExecutedModel.ScripGroup = item.Group.ToString();
            string Segment_Name = CommonFunctions.GetSegmentID(item.ScripCode);
            int    Decimal_pnt  = CommonFunctions.GetDecimal(System.Convert.ToInt32(item.ScripCode), "BSE", Segment_Name);

            objFullyExecutedModel.Time = Convert.ToDateTime(item.Time);
            if (objFullyExecutedModel.Qty > 0)
            {
                if (Decimal_pnt == 2)
                {
                    objFullyExecutedModel.AvgRate = string.Format("{0:0.00}", (item.NetOrderValue / objFullyExecutedModel.Qty) / Math.Pow(10, Decimal_pnt));
                }
                else if (Decimal_pnt == 4)
                {
                    objFullyExecutedModel.AvgRate = string.Format("{0:0.0000}", (item.NetOrderValue / objFullyExecutedModel.Qty) / Math.Pow(10, Decimal_pnt));
                }
                else
                {
                    objFullyExecutedModel.AvgRate = string.Format("{0:0.00}", (item.NetOrderValue / objFullyExecutedModel.Qty) / Math.Pow(10, Decimal_pnt));
                }
            }

            objFullyExecutedModel.OrderKey  = string.Format("{0}_{1}", item.ScripCode, item.OrderId);
            objFullyExecutedModel.SegmentID = item.SegmentFlag;

            if (FullyExecutedOrderCollection != null && FullyExecutedOrderCollection.Count > 0)
            {
                if (FullyExecutedOrderCollection.Any(x => x.OrderKey == item.OrderKey))
                {
                    int index = FullyExecutedOrderCollection.IndexOf(FullyExecutedOrderCollection.Where(x => x.OrderKey == item.OrderKey).FirstOrDefault());
                    FullyExecutedOrderCollection[index] = objFullyExecutedModel;
                }
                else
                {
                    FullyExecutedOrderCollection.Add(objFullyExecutedModel);
                }
            }
            else
            {
                FullyExecutedOrderCollection?.Add(objFullyExecutedModel);
            }
        }
Exemple #2
0
 private static void RemoveFromFullyExecutedMemory(OrderModel item)
 {
     if (FullyExecutedOrderCollection != null && FullyExecutedOrderCollection.Count > 0)
     {
         if (FullyExecutedOrderCollection.Any(x => x.OrderKey == item.OrderKey))
         {
             int index = FullyExecutedOrderCollection.IndexOf(FullyExecutedOrderCollection.Where(x => x.OrderKey == item.OrderKey).FirstOrDefault());
             if (index != -1)
             {
                 FullyExecutedOrderCollection.RemoveAt(index);
             }
         }
     }
 }