예제 #1
0
 public byte[] ReadFromNStream(TcpClient clientSocket)
 {
     try
     {
         NetworkStream networkStream = clientSocket.GetStream();
         byte[]        buffer        = new byte[clientSocket.ReceiveBufferSize];
         int           RecLength     = networkStream.Read(buffer, 0, (int)clientSocket.ReceiveBufferSize);
         //	Console.WriteLine("Srtream Read Completed");
         return(LogicClass.BufferCopy(buffer, 0, 0, RecLength));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
        public void netposion(int tok, int lotsize, int Tlot, double b_s, double rate)
        {
            try
            {
                int t_1 = 0;


                query1 = Global.Instance.OrdetTable.AsEnumerable().Where(p => p.Field <string>("Status") == orderStatus.Traded.ToString() && Convert.ToInt32(p.Field <string>("TokenNo")) == tok).GroupBy(r => Convert.ToInt32(r.Field <string>("TokenNo")))
                         .Select(store => new SelectListItem
                {
                    TredingSymbol = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == Convert.ToInt32(store.Key)).Name),
                    TokenNo       = Convert.ToInt32(store.Key),
                    //   InstrumentName = store.First().Field<string>("InstrumentName"),
                    BuyQty = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))),

                    BuyAvg = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p => ((Convert.ToInt32(p.Field <string>("Volume"))) * Convert.ToDouble(p.Field <string>("FillPrice")))) /
                              ((store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))) == 0 ? 1 : (store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p8 => Convert.ToInt32(p8.Field <string>("Volume")))))),

                    SellQty = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))),

                    SellAvg = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p => (Convert.ToInt32(p.Field <string>("Volume"))) * Convert.ToDouble(p.Field <string>("FillPrice"))) /
                               ((store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))) == 0 ? 1 : (store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p8 => Convert.ToInt32(p8.Field <string>("Volume")))))),

                    NetQty =
                        ((store.Where(a1 => a1.Field <String>("Buy_SellIndicator") == "BUY").Sum(p1 => Convert.ToInt32(p1.Field <string>("Volume"))))) -
                        ((store.Where(a2 => a2.Field <String>("Buy_SellIndicator") == "SELL").Sum(p2 => Convert.ToInt32(p2.Field <string>("Volume"))))),
                }).ToList();
                //if(b_s==1)
                //{
                //    query1.FirstOrDefault().buy_rate = rate;
                //}
                //else
                //{
                //    query1.FirstOrDefault().Sell_rate = rate;
                //}

                var TempList = csv.CSV_Class.cimlist.Where(a => a.Token == tok).ToList();
                var checktok = TempList.First().EGMAGM;


                if (Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field <string>("TredingSymbol") == checktok).Count() > 0)
                {
                    //var rows = Global.Instance.NetBookTable.AsEnumerable().ToList();
                    //var fg = (rows.FindIndex(a => Convert.ToString(a.Field<string>("Symbol")) == "Total"));
                    //if (fg >= 0)
                    //{
                    //    Global.Instance.NetBookTable.Rows[fg].Delete();
                    //}

                    var rowlist = Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field <string>("TredingSymbol") == checktok).ToList();

                    try
                    {
                        foreach (var i in rowlist)
                        {
                            i["Token"]         = query1.FirstOrDefault().TokenNo;
                            i["TredingSymbol"] = query1.FirstOrDefault().TredingSymbol;
                            i["BuyQty"]        = query1.FirstOrDefault().BuyQty;
                            i["BuyAvg"]        = query1.FirstOrDefault().BuyAvg;
                            i["SellQty"]       = -query1.FirstOrDefault().SellQty;
                            i["SellAvg"]       = query1.FirstOrDefault().SellAvg;
                            //==========================================================================
                            //    i["NetQty"] = query1.FirstOrDefault().BuyQty + -query1.FirstOrDefault().SellQty;


                            //    i["NetValue"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().SellAvg) * (-query1.FirstOrDefault().SellQty)), 3) + Math.Round(Convert.ToDouble((-query1.FirstOrDefault().BuyAvg) * (query1.FirstOrDefault().BuyQty)), 3);
                            //------------------------------------------------------------------------------

                            i["InstrumentName"] = TempList.FirstOrDefault().InstrumentName;
                            i["Symbol"]         = TempList.FirstOrDefault().Symbol;
                            i["OptionType"]     = TempList.FirstOrDefault().OptionType;
                            i["StrikePrice"]    = Convert.ToDouble(TempList.FirstOrDefault().StrikePrice / 100);
                            i["ExpiryDate"]     = LogicClass.ConvertFromTimestamp(TempList.FirstOrDefault().ExpiryDate);
                            i["LTP"]            = Global.Instance.ltp[tok].LTP;
                            i["Delta"]          = Math.Round(Convert.ToDouble(Global.Instance.ltp[tok].Delta), 3);
                            i["NetQtyDelta"]    = Math.Round(Convert.ToDouble((query1.FirstOrDefault().NetQty) * (Global.Instance.ltp[tok].Delta)), 3);
                            //  i["BUYRATE"] = Math.Round(Convert.ToDouble(query1.FirstOrDefault().buy_rate),3);
                            //  i["SELLRATE"] = Math.Round(Convert.ToDouble(query1.FirstOrDefault().Sell_rate),3);
                            i["BUYVALUE"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().BuyAvg) * (query1.FirstOrDefault().BuyQty)), 3);


                            i["SELLVALUE"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().SellAvg) * (-query1.FirstOrDefault().SellQty)), 3);

                            i["MTM"] = Math.Round((Convert.ToDouble((-query1.FirstOrDefault().SellAvg) * (-query1.FirstOrDefault().SellQty)) + Convert.ToDouble((-query1.FirstOrDefault().BuyAvg) * (query1.FirstOrDefault().BuyQty))) - ((Global.Instance.ltp[tok].LTP) * (-query1.FirstOrDefault().BuyQty + -query1.FirstOrDefault().SellQty)), 3);



                            //         //=========================================

                            //    Global.Instance.NetBookTable.Rows.Add("Total", "-", Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("StrikePrice")), "-", "-", Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("BuyQty")),
                            //Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("BuyAvg")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("BUYVALUE")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("SellQty")),
                            //     Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("SellAvg")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("SELLVALUE")),
                            //       0, 0,
                            //       Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("MTM")),
                            //       Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("LTP")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("Delta")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("NetQtyDelta")), 0, 0);
                            //            //=============
                        }
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(" Exception " + Ex.StackTrace.ToString());
                    }
                }
                else
                {
                    //==================================  ===  ==  ==  ==  == == ==
                    var rows = Global.Instance.NetBookTable.AsEnumerable().ToList();

                    //var fg = (rows.FindIndex(a => Convert.ToString(a.Field<string>("Symbol")) == "Total"));
                    //if (fg >= 0)
                    //{
                    //    Global.Instance.NetBookTable.Rows[fg].Delete();
                    //}
                    DataRow i = Global.Instance.NetBookTable.NewRow();

                    i["Token"]         = query1.FirstOrDefault().TokenNo;
                    i["TredingSymbol"] = query1.FirstOrDefault().TredingSymbol;
                    i["BuyQty"]        = query1.FirstOrDefault().BuyQty;
                    i["BuyAvg"]        = query1.FirstOrDefault().BuyAvg;
                    i["SellQty"]       = -query1.FirstOrDefault().SellQty;
                    i["SellAvg"]       = query1.FirstOrDefault().SellAvg;


                    i["LTP"]            = Global.Instance.ltp[tok].LTP;
                    i["Delta"]          = Math.Round(Convert.ToDouble(Global.Instance.ltp[tok].Delta), 3);
                    i["NetQtyDelta"]    = Math.Round(Convert.ToDouble((Convert.ToDouble(query1.FirstOrDefault().NetQty) * (Global.Instance.ltp[tok].Delta))), 3);
                    i["InstrumentName"] = TempList.FirstOrDefault().InstrumentName;
                    i["Symbol"]         = TempList.FirstOrDefault().Symbol;
                    i["OptionType"]     = TempList.FirstOrDefault().OptionType;
                    i["StrikePrice"]    = Convert.ToDouble(TempList.FirstOrDefault().StrikePrice / 100);
                    i["ExpiryDate"]     = LogicClass.ConvertFromTimestamp(TempList.FirstOrDefault().ExpiryDate);

                    i["BUYVALUE"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().BuyAvg) * (query1.FirstOrDefault().BuyQty)), 3);


                    i["SELLVALUE"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().SellAvg) * (-query1.FirstOrDefault().SellQty)), 3);

                    i["MTM"] = Math.Round((Convert.ToDouble((-query1.FirstOrDefault().SellAvg) * (-query1.FirstOrDefault().SellQty)) + Convert.ToDouble((-query1.FirstOrDefault().BuyAvg) * (query1.FirstOrDefault().BuyQty))) - ((Global.Instance.ltp[tok].LTP) * (-query1.FirstOrDefault().BuyQty + -query1.FirstOrDefault().SellQty)), 3);

                    //   i["MTM"] = Math.Round(Convert.ToDouble( (query1.FirstOrDefault().NetValue) - ((Global.Instance.ltp[tok].LTP) * (-query1.FirstOrDefault().NetQty))),3);



                    Global.Instance.NetBookTable.Rows.Add(i);



                    //Global.Instance.NetBookTable.Rows.Add("Total", "-", Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("StrikePrice")), "-", "-", Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("BuyQty")),
                    //            Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("BuyAvg")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("BUYVALUE")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("SellQty")),
                    //                 Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("SellAvg")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("SELLVALUE")),
                    //                   0, 0,
                    //                   Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("MTM")),
                    //                   Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("LTP")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("Delta")), Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("NetQtyDelta")), 0, 0);
                }

                //DataRow ii = Global.Instance.NetBookTable.NewRow();
                //ii["InstrumentName"] = "Total";
                //Global.Instance.NetBookTable.Rows.Add(ii);


                DGV.DataSource = Global.Instance.NetBookTable;
            }
            catch (Exception ex)
            {
                Task.Factory.StartNew(() => LogWriterClass.logwritercls.logs("tradeerror", ex.StackTrace.ToString()));
            }


            if (this.InvokeRequired)
            {
                MethodInvoker del = delegate
                {
                    DGV.Refresh();
                };
                this.Invoke(del);
                return;
            }
        }
        public void netposion2(int tok, int lotsize, int Tlot, double b_s, double rate)
        {
            try
            {
                int t_1 = 0;

                query1 = Global.Instance.OrdetTable.AsEnumerable().Where(p => p.Field <string>("Status") == orderStatus.Traded.ToString()).GroupBy(r => Convert.ToInt32(r.Field <string>("TokenNo")))
                         .Select(store => new SelectListItem
                {
                    TredingSymbol = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == Convert.ToInt32(store.Key)).Name),
                    TokenNo       = Convert.ToInt32(store.Key),
                    BuyQty        = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))),

                    BuyAvg = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p => ((Convert.ToInt32(p.Field <string>("Volume"))) * Convert.ToDouble(p.Field <string>("FillPrice")))) /
                              ((store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))) == 0 ? 1 : (store.Where(a => a.Field <String>("Buy_SellIndicator") == "BUY").Sum(p8 => Convert.ToInt32(p8.Field <string>("Volume")))))),

                    SellQty = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))),

                    SellAvg = (store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p => (Convert.ToInt32(p.Field <string>("Volume"))) * Convert.ToDouble(p.Field <string>("FillPrice"))) /
                               ((store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p => Convert.ToInt32(p.Field <string>("Volume")))) == 0 ? 1 : (store.Where(a => a.Field <String>("Buy_SellIndicator") == "SELL").Sum(p8 => Convert.ToInt32(p8.Field <string>("Volume")))))),

                    NetQty =
                        ((store.Where(a1 => a1.Field <String>("Buy_SellIndicator") == "BUY").Sum(p1 => Convert.ToInt32(p1.Field <string>("Volume"))))) -
                        ((store.Where(a2 => a2.Field <String>("Buy_SellIndicator") == "SELL").Sum(p2 => Convert.ToInt32(p2.Field <string>("Volume"))))),
                }).ToList();
                if (b_s == 1)
                {
                    query1.FirstOrDefault().buy_rate = rate;
                }
                else
                {
                    query1.FirstOrDefault().Sell_rate = rate;
                }



                //==================================  ===  ==  ==  ==  == == == ==  == ==  ==

                for (int j = 0; j < query1.Count(); j++)
                {
                    var TempList = csv.CSV_Class.cimlist.Where(a => a.Token == query1[j].TokenNo).ToList();

                    var     checktok = TempList.First().EGMAGM;
                    DataRow i        = Global.Instance.NetBookTable.NewRow();

                    i["Token"]         = query1[j].TokenNo;
                    i["TredingSymbol"] = query1[j].TredingSymbol;
                    i["BuyQty"]        = query1[j].BuyQty;
                    i["BuyAvg"]        = query1[j].BuyAvg;
                    i["SellQty"]       = query1[j].SellQty;
                    i["SellAvg"]       = query1[j].SellAvg;
                    i["NetQty"]        = query1[j].BuyAvg - query1[j].SellQty;
                    //  i["NetQty"] = query1[j].NetQty;
                    //  i["NetQty"] = query1[j].NetQty;
                    //  i["BEP"] = query1[j].BEP;
                    //   i["NetValue"] = query1[j].NetValue;
                    i["NetValue"]       = Math.Round(Convert.ToDouble((query1[j].Sell_rate) * (query1[j].SellQty)), 3) + Math.Round(Convert.ToDouble((query1[j].buy_rate) * (query1[j].BuyQty)), 3);
                    i["InstrumentName"] = TempList.FirstOrDefault().InstrumentName;
                    i["Symbol"]         = TempList.FirstOrDefault().Symbol;
                    i["OptionType"]     = TempList.FirstOrDefault().OptionType;
                    i["StrikePrice"]    = Convert.ToDouble(TempList.FirstOrDefault().StrikePrice / 100);

                    i["ExpiryDate"] = LogicClass.ConvertFromTimestamp(TempList.FirstOrDefault().ExpiryDate);
                    i["LTP"]        = 0;

                    i["Delta"]       = 0;
                    i["NetQtyDelta"] = 0;


                    i["BUYVALUE"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().BuyAvg) * (query1.FirstOrDefault().BuyQty)), 3);


                    i["SELLVALUE"] = Math.Round(Convert.ToDouble((-query1.FirstOrDefault().SellAvg) * (-query1.FirstOrDefault().SellQty)), 3);
                    //i["BUYVALUE"] = Math.Round(Convert.ToDouble((query1[j].buy_rate) * (query1[j].BuyQty)), 3);
                    //i["SELLVALUE"] = Math.Round(Convert.ToDouble((query1[j].Sell_rate) * (query1[j].SellQty)), 3);
                    i["MTM"] = 0;
                    //======= ==========  ========= =============  ========== ===========  =======================  ============  ==========
                    //  lblbq.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("BuyQty")).ToString();
                    //  lblsq.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("SellQty")).ToString();
                    //  lvlNetQt.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("NetQty")).ToString();

                    // // lvelNetVal.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("NetValue")).ToString();
                    //  lblstrike.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<int>("StrikePrice")).ToString();
                    //  lvlLTP.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("LTP")).ToString();
                    //  lvlDelta.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("Delta")).ToString();
                    //  lvlNetQD.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("NetQtyDelta")).ToString();
                    //  lbllblBR.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("BUYRATE")).ToString();
                    //  lvlSealRate.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("SELLRATE")).ToString();
                    //  lblBV.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("BUYVALUE")).ToString();
                    // lvlSealval.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("SELLVALUE")).ToString();
                    ////  lvlMtm.Text = Global.Instance.NetBookTable.AsEnumerable().Sum(x => x.Field<double>("MTM")).ToString();

                    //============ ============  ========== ========= ======= =======  ==================  ==================== =============  ======== =======
                    Global.Instance.NetBookTable.Rows.Add(i);
                }

                DGV.DataSource = Global.Instance.NetBookTable;
            }
            catch (Exception ex)
            {
                Task.Factory.StartNew(() => LogWriterClass.logwritercls.logs("tradeerror", ex.StackTrace.ToString()));
            }


            if (this.InvokeRequired)
            {
                MethodInvoker del = delegate
                {
                    DGV.Refresh();
                };
                this.Invoke(del);
                return;
            }
        }
예제 #4
0
        private void loadbackfill_data()
        {
            DataSet ds = new DataSet();

            ds.ReadXml(Application.StartupPath + Path.DirectorySeparatorChar + "001.xml");

            ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "InstrumentName"; // "InstrumentName";
            ds.Tables[0].Columns["SYMBOL"].ColumnName     = "Symbol";

            ds.Tables[0].Columns["TOKENNO"].ColumnName = "TokenNo";
            //  ds.Tables[0].Columns["TOKENNO"].DataType = typeof(Int32);
            ds.Tables[0].Columns["Buy_SellIndicator"].ColumnName = "Buy_SellIndicator";
            ds.Tables[0].Columns["OPTIONTYPE"].ColumnName        = "OptionType";
            ds.Tables[0].Columns["STRIKEPRICE"].ColumnName       = "StrikePrice";
            //   ds.Tables[0].Columns["PRICE"].DataType = typeof(double);
            ds.Tables[0].Columns["PRICE"].ColumnName = "Price";
            //ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "FillPrice";
            ds.Tables[0].Columns["VOLUME"].ColumnName                   = "Volume";
            ds.Tables[0].Columns["STATUS"].ColumnName                   = "Status";
            ds.Tables[0].Columns["ACCOUNTNUMBER"].ColumnName            = "AccountNumber";
            ds.Tables[0].Columns["BOOKTYPE"].ColumnName                 = "BookType";
            ds.Tables[0].Columns["BRANCHID"].ColumnName                 = "BranchId";
            ds.Tables[0].Columns["CLOSEOUTFLAG"].ColumnName             = "CloseoutFlag";
            ds.Tables[0].Columns["EXPIRYDATE"].ColumnName               = "ExpiryDate";
            ds.Tables[0].Columns["DISCLOSEDVOLUME"].ColumnName          = "DisclosedVolume";
            ds.Tables[0].Columns["DISCLOSEDVOLUMEREMAINING"].ColumnName = "DisclosedVolumeRemaining";
            ds.Tables[0].Columns["ENTRYDATETIME"].ColumnName            = "EntryDateTime";
            ds.Tables[0].Columns["FILLER"].ColumnName                   = "filler";
            ds.Tables[0].Columns["GOODTILLDATE"].ColumnName             = "GoodTillDate";
            ds.Tables[0].Columns["LASTMODIFIED"].ColumnName             = "LastModified";
            ds.Tables[0].Columns["LOGTIME"].ColumnName                  = "LogTime";
            ds.Tables[0].Columns["Modified_CancelledBy"].ColumnName     = "Modified_CancelledBy";
            ds.Tables[0].Columns["NNFFIELD"].ColumnName                 = "nnffield";
            ds.Tables[0].Columns["OPEN_CLOSE"].ColumnName               = "Open_Close";
            ds.Tables[0].Columns["OrderNumber"].ColumnName              = "OrderNumber";
            //  ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "RejectReason";
            ds.Tables[0].Columns["PRO_CLIENTINDICATOR"].ColumnName = "Pro_ClientIndicator";
            ds.Tables[0].Columns["REASONCODE"].ColumnName          = "ReasonCode";
            ds.Tables[0].Columns["SETTLOR"].ColumnName             = "Settlor";
            // ds.Tables[0].Columns["TIMESTAMP1"].ColumnName = "TimeStamp1";
            //ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "TimeStamp2";
            ds.Tables[0].Columns["TOTALVOLUMEREMAINING"].ColumnName = "TotalVolumeRemaining";
            ds.Tables[0].Columns["TRADERID"].ColumnName             = "TraderId";
            ds.Tables[0].Columns["TRANSACTIONCODE"].ColumnName      = "TransactionCode";
            ds.Tables[0].Columns["USERID"].ColumnName = "UserId";
            //  ds.Tables[0].Columns["VOLUMEFILLEDTODAY"].DataType = typeof(Int32);
            ds.Tables[0].Columns["VOLUMEFILLEDTODAY"].ColumnName = "VolumeFilledToday";
            //  ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "TimeStamp1";
            Global.Instance.OrdetTable = ds.Tables[0];



            DataRow[] dr_selectbal = Global.Instance.OrdetTable.Select("STATUS='Open'");

            //  double d =
            foreach (var item in dr_selectbal)
            {
                Order ord = new Order(1);
                ord.mS_OE_RESPONSE_TR.AccountNumber = System.Text.Encoding.ASCII.GetBytes(item["AccountNumber"].ToString());
                var a = (Convert.ToInt64(item["OrderNumber"]));
                ord.mS_OE_RESPONSE_TR.OrderNumber = Convert.ToDouble(Convert.ToInt64(item["OrderNumber"]));
                //Convert.ToDouble(item["OrderNumber"].ToString());

                var c = (long)LogicClass.DoubleEndianChange(ord.mS_OE_RESPONSE_TR.OrderNumber);
                ord.mS_OE_RESPONSE_TR.Buy_SellIndicator = (short)IPAddress.HostToNetworkOrder(Convert.ToInt32(item["Buy_SellIndicator"] == "BUY"?"1":"2"));

                //    MS_OE_RESPONSE_TR obj = (MS_OE_RESPONSE_TR)DataPacket.RawDeserialize(buffer, typeof(MS_OE_RESPONSE_TR));
                Holder.holderOrder.TryAdd(LogicClass.DoubleEndianChange(ord.mS_OE_RESPONSE_TR.OrderNumber), ord);
                Holder.holderOrder[LogicClass.DoubleEndianChange(ord.mS_OE_RESPONSE_TR.OrderNumber)].mS_OE_RESPONSE_TR = ord.mS_OE_RESPONSE_TR;
            }
        }