//double trp1; //double trp11; //double trp2; //double trp22; public void Fillqty_ingrd(int tokenno, int buy_sell,MS_TRADE_CONFIRM_TR obj) { try { bool sp; string strbuysell = buy_sell == 1 ? "Buy" : "Sell"; string Token1Side,Token2Side, Token3Side; Client.Csv_Struct _lotsize = new Csv_Struct(); object ob = new object(); lock (ob) { // DataGridViewRow row=null; DataGridViewRow row = DGV1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["Token1"].Value.ToString().Equals(Convert.ToString(tokenno))).FirstOrDefault(); //foreach(DataGridViewRow row1 in DGV1.Rows) //{ // if(row1.Cells["Token1"].Value.ToString()==Convert.ToString(tokenno)) // { // row = row1; // break; // } //} if (row == null) { row = DGV1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["Token2"].Value.ToString().Equals(Convert.ToString(Convert.ToString(tokenno)))).FirstOrDefault(); if (row == null) { row = DGV1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["Token3"].Value.ToString().Equals(Convert.ToString(Convert.ToString(tokenno)))).FirstOrDefault(); if (row == null) { return; } } //return; } //var v = Global.Instance.Ratio.Where(a => a.Key == (tokenno)).Select(b => b.Value).ToList(); //val = Convert.ToInt32(v.FirstOrDefault().ToString()); var pf = Convert.ToInt32(DGV1.Rows[row.Index].Cells["PF"].Value); var val1 = Convert.ToInt32(DGV1.Rows[row.Index].Cells["ratio1"].Value); var val2 = Convert.ToInt32(DGV1.Rows[row.Index].Cells["ratio2"].Value); var val3 = Convert.ToInt32(DGV1.Rows[row.Index].Cells["ratio3"].Value); int near_tok1= Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token1"].Value); int far_tok2 = Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token2"].Value); int _tok3 = Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token3"].Value); // int buy= Convert.ToInt32(DGV1.Rows[row.Index].Cells["Buy"].Value); //int sell = Convert.ToInt32(DGV1.Rows[row.Index].Cells["Sell"].Value); if (Holder._DictLotSize.ContainsKey(tokenno) == false || tokenno != 0) { Holder._DictLotSize.TryAdd(tokenno, new Csv_Struct() { lotsize = CSV_Class.cimlist.Where(q => q.Token == tokenno).Select(a => a.BoardLotQuantity).First() } ); } query1 = Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token1"].Value)).Select(a => new SelectListItem { TokenNo = Convert.ToInt32(a.Field<Int32>("Token")), BuyAvg = a.Field<double>("BuyAvg"), SellAvg = a.Field<double>("SellAvg") }).ToList(); var foundRow = Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token2"].Value)).Count()>0; //if(foundRow != null) { ////You have it ... // } // if(Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token2"].Value))) if (foundRow ==true) { query2 = Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token2"].Value)).Select(a => new SelectListItem { TokenNo = a.Field<Int32>("Token"), BuyAvg = a.Field<double>("BuyAvg"), SellAvg = a.Field<double>("SellAvg") }).ToList(); } var foundRow2 = Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token3"].Value)).Count() > 0; //if(foundRow != null) { ////You have it ... // } // if(Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token2"].Value))) if (foundRow2 == true) { query3 = Global.Instance.NetBookTable.AsEnumerable().Where(p => p.Field<Int32>("Token") == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token3"].Value)).Select(a => new SelectListItem { TokenNo = a.Field<Int32>("Token"), BuyAvg = a.Field<double>("BuyAvg"), SellAvg = a.Field<double>("SellAvg") }).ToList(); } _lotsize = Holder._DictLotSize[tokenno]; if (near_tok1 == tokenno) { if (strbuysell == Convert.ToString(DGV1.Rows[row.Index].Cells["Tok1B_S"].Value))//create { DGV1.Rows[row.Index].Cells["TRP1"].Value = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; sp = true; Token2Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok2B_S"].Value); Token3Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok3B_S"].Value); var ob_o = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), strbuysell.ToUpper()) && (a.Field<string>("Status") == "Traded")).Sum(a => Convert.ToInt32(a.Field<string>("Volume"))); // DGV1.Rows[row.Index].Cells["TRDQTY(B)"].Value = Convert.ToInt32(ob_o) / (Convert.ToInt32(_lotsize.lotsize) * (Convert.ToInt32(val1))); double ob1 = Convert.ToDouble(ob_o); double rev_ratio = _lotsize.lotsize * val1; DGV1.Rows[row.Index].Cells["TRDQTY(B)"].Value = Math.Round(ob1 / rev_ratio, 2); //========================================================================= // int TrdqtyBuy = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), strbuysell.ToUpper()) && (a.Field<string>("Status") == "Traded")).ToList().Count; // DGV1.Rows[row.Index].Cells["TRDQTY(B)"].Value = TrdqtyBuy; //======================================================= double Result1 = strbuysell == "Buy" ? -(query1.FirstOrDefault().BuyAvg * Convert.ToInt32(val1)) : (query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1)); double Result2 = Token2Side == "Buy" ? -((query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2)) : ((query2 == null ? 0 : query2.FirstOrDefault().SellAvg) * Convert.ToInt32(val2)); double Result3 = Token3Side == "Buy" ? -((query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3)) : ((query3 == null ? 0 : query3.FirstOrDefault().SellAvg) * Convert.ToInt32(val3)); DGV1.Rows[row.Index].Cells["ATP(B)"].Value = Math.Round( Result1 + Result2 + Result3,3); } else //reverse { DGV1.Rows[row.Index].Cells["TRP11"].Value = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; var ob_o = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), strbuysell.ToUpper()) && (a.Field<string>("Status") == "Traded")).Sum(a => Convert.ToInt32(a.Field<string>("Volume"))); double ob1 = Convert.ToDouble(ob_o); double cr_ratio = _lotsize.lotsize * val2; DGV1.Rows[row.Index].Cells["TRDQTY(S)"].Value = Math.Round( ob1 / cr_ratio,2); // DGV1.Rows[row.Index].Cells["TRDQTY(S)"].Value = Convert.ToInt32(ob_o) / (Convert.ToInt32(_lotsize.lotsize) * (Convert.ToInt32(val2))); //============================================== // int TrdqtySel = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), strbuysell.ToUpper()) && (a.Field<string>("Status") == "Traded")).ToList().Count; // DGV1.Rows[row.Index].Cells["TRDQTY(S)"].Value = TrdqtySel; //======================================================================== Token2Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok2B_S"].Value) =="Buy" ? "Sell" : "Buy"; Token3Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok3B_S"].Value)=="Buy" ? "Sell" : "Buy"; sp = false; double ResultT1 = strbuysell == "Buy" ? -(query1.FirstOrDefault().BuyAvg * Convert.ToInt32(val1)) : (query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1)); double ResultT2 = Token2Side == "Buy" ? -((query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2)) : ((query2 == null ? 0 : query2.FirstOrDefault().SellAvg) * Convert.ToInt32(val2)); double ResultT3 = Token3Side == "Buy" ? -((query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3)) : ((query3 == null ? 0 : query3.FirstOrDefault().SellAvg) * Convert.ToInt32(val3)); DGV1.Rows[row.Index].Cells["ATP(S)"].Value = Math.Round( ResultT1 + ResultT2 + ResultT3,3); } //====== ======== ======== ====== ========= ============= ====== ========= ============= ====== ====== ======== ======== ==== ==== ======= ========== == == == == == == == == == == == } if (far_tok2 == tokenno) { if (strbuysell == Convert.ToString(DGV1.Rows[row.Index].Cells["Tok2B_S"].Value))//create { DGV1.Rows[row.Index].Cells["TRP2"].Value = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; Token1Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok1B_S"].Value); Token3Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok3B_S"].Value); double res1 = Token1Side == "Buy" ? -(query1.FirstOrDefault().BuyAvg * Convert.ToInt32(val1)) : (query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1)); double res2 = strbuysell == "Buy" ? -((query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2)) : ((query2 == null ? 0 : query2.FirstOrDefault().SellAvg) * Convert.ToInt32(val2)); double res3 = Token3Side == "Buy" ? -((query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3)) : ((query3 == null ? 0 : query3.FirstOrDefault().SellAvg) * Convert.ToInt32(val3)); DGV1.Rows[row.Index].Cells["ATP(B)"].Value = Math.Round( res1 + res2 + res3,3); sp = true; } else //reverse { DGV1.Rows[row.Index].Cells["TRP22"].Value = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; Token1Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok1B_S"].Value) == "Buy" ? "Sell" : "Buy"; Token3Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok3B_S"].Value) == "Buy" ? "Sell" : "Buy"; double resS1 = Token1Side == "Buy" ? -(query1.FirstOrDefault().BuyAvg * Convert.ToInt32(val1)) : (query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1)); double resS2 = strbuysell == "Buy" ? -((query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2)) : ((query2 == null ? 0 : query2.FirstOrDefault().SellAvg) * Convert.ToInt32(val2)); double resS3 = Token3Side == "Buy" ? -((query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3)) : ((query3 == null ? 0 : query3.FirstOrDefault().SellAvg) * Convert.ToInt32(val3)); DGV1.Rows[row.Index].Cells["ATP(S)"].Value = Math.Round( resS1 + resS2 + resS3,3); sp = false; } if (Convert.ToString(DGV1.Rows[row.Index].Cells["Strategy_Type"].Value) == "2_LEG") { if (Global.Instance.TradeTrac_dict.ContainsKey(IPAddress.HostToNetworkOrder(obj.Token))) { double trp1 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP1"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP1"].Value) * Convert.ToInt32(val1); double trp11 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP11"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP11"].Value) * Convert.ToInt32(val1); double trp2 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP2"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP2"].Value) * Convert.ToInt32(val2); double trp22 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP22"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP22"].Value) * Convert.ToInt32(val2); trd_obj = new TradeTrac(); // var a = trp1 + trp2; // double v =v + a; var creat = trp1 + trp2 ; var Rev = trp11 + trp22; int TrdqtyBuy = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), "BUY") && (a.Field<string>("Status") == "Traded")).ToList().Count; int TrdqtySell = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), "SELL") && (a.Field<string>("Status") == "Traded")).ToList().Count; trd_obj = Global.Instance.TradeTrac_dict[near_tok1]; trd_obj.ACTUALPRICE = sp == true ? creat : Rev; trd_obj.B_S = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator); trd_obj.QTy = IPAddress.HostToNetworkOrder(obj.FillQuantity); trd_obj.SYMBOL = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol); trd_obj.TIME = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff"); Global.Instance.TradeTrac_dict.AddOrUpdate(IPAddress.HostToNetworkOrder(obj.Token), trd_obj, (k, v1) => trd_obj); //DataRow[] dr = Global.Instance.TradeTracker.Select("PF_ID = '" + Convert.ToInt32(trd_obj.PF_ID) + "'"); DataRow[] dr = Global.Instance.TradeTracker.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() +"'"); if (dr.Length > 0) { dr[0]["PF_ID"] = Convert.ToString(trd_obj.PF_ID); // dr[0]["B/S"] = trd_obj.B_S == 1 ? "BUY" : "SELL"; dr[0]["B/S"] = sp == true ? "BUY" : "SELL"; //dr[0]["QTY"] = Convert.ToString(trd_obj.QTy); // dr[0]["QTY"] = trd_obj.B_S == 1 ? Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRDQTY(B)"].Value) : Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRDQTY(S)"].Value); double vo = Convert.ToDouble(IPAddress.HostToNetworkOrder(obj.FillQuantity)); double createratio = Convert.ToDouble(_lotsize.lotsize * val2); dr[0]["QTY"] = vo / createratio >= Convert.ToDouble(1.0) ? "Complete" : "Partial"; dr[0]["QTY"] = dr[0]["QTY"] + " \t" + Convert.ToString(Math.Round(vo / createratio, 2)); //"1"; // dr[0]["QTY"] = trd_obj.B_S == 1 ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); // dr[0]["QTY"] =Convert.ToDecimal(IPAddress.HostToNetworkOrder(obj.FillQuantity)/ (Convert.ToInt32(_lotsize.lotsize) * (Convert.ToInt32(val2)))); //"1"; // dr[0]["QTY"] = sp == true ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); dr[0]["ACTUALPRICE"] = Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.ACTUALPRICE), 3)); //dr[0]["GIVENPRICEBUY"] = Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Buy), 3)); //dr[0]["GIVENPRICESELL"] = Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Sell), 3)); dr[0]["GIVENPRICEBUY"] = sp == true ? Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Buy), 3)) : "0"; dr[0]["GIVENPRICESELL"] = sp == true ? "0" : Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Sell), 3)); dr[0]["SYMBOL"] = Convert.ToString(trd_obj.SYMBOL); dr[0]["TIME"] = Convert.ToString(trd_obj.TIME); dr[0]["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString(); } else { BeginInvoke((Action)delegate { DataRow dr2 = Global.Instance.TradeTracker.NewRow(); // dr2["Sno2"] = trd_ob.ToString(); dr2["PF_ID"] = Convert.ToString(trd_obj.PF_ID); //dr2["B/S"] = trd_obj.B_S == 1 ? "BUY" : "SELL"; dr2["B/S"] = sp == true ? "BUY" : "SELL"; // dr2["GIVENPRICEBUY"] = sp == true ? "BUY" : "SELL"; // dr2["QTY"] = Convert.ToString(trd_obj.QTy); // dr2["QTY"] = trd_obj.B_S == 1 ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); //dr2["QTY"] = sp == true ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); double vo = Convert.ToDouble(IPAddress.HostToNetworkOrder(obj.FillQuantity)); double createratio = Convert.ToDouble(_lotsize.lotsize * val2); dr2["QTY"] = vo / createratio >= Convert.ToDouble(1.0) ? "Complete" : "Partial"; dr2["QTY"] = dr2["QTY"] + " \t" + Convert.ToString(Math.Round(vo / createratio, 2)); //"1"; dr2["ACTUALPRICE"] = Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.ACTUALPRICE), 3)); dr2["GIVENPRICEBUY"] = sp == true ? Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Buy), 3)) : "0"; dr2["GIVENPRICESELL"] = sp == true ? "0" : Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Sell), 3)); dr2["SYMBOL"] = Convert.ToString(trd_obj.SYMBOL); dr2["TIME"] = Convert.ToString(trd_obj.TIME); dr2["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString(); Global.Instance.TradeTracker.Rows.Add(dr2); }); //Trade_Tracker.Instance.DGV.ScrollBars = ScrollBars.Vertical; } //================== ================= =============== ========== ========== ====== ==== ===== ===== ===== ======= ====== ============== ==== == == == == == == == == == == double WTC_txt1 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["W_T_C"].Value); if(sp == true) // crea { if ((Math.Abs((trd_obj.Given_Price_Buy)) + Math.Abs(WTC_txt1)) < Math.Abs(trd_obj.ACTUALPRICE)) { DGV1.Rows[row.Index].Cells["WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) + 1; } DGV1.Rows[row.Index].Cells["_con_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) + 1; if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == Convert.ToInt32(WTC_txt.Text) && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) // if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == 5 && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) { DGV1.Rows[row.Index].Cells["WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_con_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["Enable"].Value = false; } if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) != Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value)) { DGV1.Rows[row.Index].Cells["WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_con_WTC"].Value = 0; } // \\\\ /// } else // rev { if ((Math.Abs((trd_obj.Given_Price_Sell)) - Math.Abs(WTC_txt1)) > Math.Abs(trd_obj.ACTUALPRICE)) { DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) + 1; } // var _T_v = (IPAddress.HostToNetworkOrder(obj.FillPrice) / 100) + trd_obj.ACTUALPRICE; DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value) + 1; if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) == Convert.ToInt32(WTC_txt.Text) && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value)) // if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == 5 && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) { DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["Enable"].Value = false; } if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) != Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value)) { DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = 0; } } //=============================================================================================================== } } } //================================= if (_tok3 == tokenno) { if (strbuysell == Convert.ToString(DGV1.Rows[row.Index].Cells["Tok3B_S"].Value))//create { DGV1.Rows[row.Index].Cells["TRP3"].Value = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; // var t = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; // DGV1.Rows[row.Index].Cells["TRP3"].Value = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP3"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP3"].Value) + t; Token1Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok1B_S"].Value); Token2Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok2B_S"].Value); double res1 = Token1Side == "Buy" ? -(query1.FirstOrDefault().BuyAvg * Convert.ToInt32(val1)) : (query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1)); double res2 = Token2Side == "Buy" ? -((query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2)) : ((query2 == null ? 0 : query2.FirstOrDefault().SellAvg) * Convert.ToInt32(val2)); double res3 = strbuysell == "Buy" ? -((query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3)) : ((query3 == null ? 0 : query3.FirstOrDefault().SellAvg) * Convert.ToInt32(val3)); DGV1.Rows[row.Index].Cells["ATP(B)"].Value = Math.Round( res1 + res2 + res3,3); sp = true; } else //reverse { // var t = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; // DGV1.Rows[row.Index].Cells["TRP33"].Value = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP33"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP33"].Value) + t; DGV1.Rows[row.Index].Cells["TRP33"].Value = strbuysell == "Buy" ? -IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00 : IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00; // DGV1.Rows[row.Index].Cells["ATP(S)"].Value = query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1) - (query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2) - (query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3); Token1Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok1B_S"].Value) == "Buy" ?"Sell" : "Buy"; Token2Side = Convert.ToString(DGV1.Rows[row.Index].Cells["Tok2B_S"].Value) == "Buy" ? "Sell" : "Buy"; double resS1 = Token1Side == "Buy" ? -(query1.FirstOrDefault().BuyAvg * Convert.ToInt32(val1)) : (query1.FirstOrDefault().SellAvg * Convert.ToInt32(val1)); double resS2 = Token2Side == "Buy" ? -((query2 == null ? 0 : query2.FirstOrDefault().BuyAvg) * Convert.ToInt32(val2)) : ((query2 == null ? 0 : query2.FirstOrDefault().SellAvg) * Convert.ToInt32(val2)); double resS3 = strbuysell == "Buy" ? -((query3 == null ? 0 : query3.FirstOrDefault().BuyAvg) * Convert.ToInt32(val3)) : ((query3 == null ? 0 : query3.FirstOrDefault().SellAvg) * Convert.ToInt32(val3)); DGV1.Rows[row.Index].Cells["ATP(S)"].Value = Math.Round( resS1 + resS2 + resS3,3); sp = false; } if (Convert.ToString(DGV1.Rows[row.Index].Cells["Strategy_Type"].Value) == "3_LEG") { if (Global.Instance.TradeTrac_dict.ContainsKey(IPAddress.HostToNetworkOrder(obj.Token))) { // double trp13 = Token1Side == "Buy" ? -Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP1"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP1"].Value) : Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP1"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP1"].Value); // double trp23 = Token2Side == "Buy" ? -Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP2"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP2"].Value) : Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP2"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP2"].Value); // double trp33 = strbuysell == "Buy" ? -Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP3"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP3"].Value) : Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP3"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP3"].Value); double trp1 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP1"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP1"].Value) * Convert.ToInt32(val1); double trp11 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP11"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP11"].Value) * Convert.ToInt32(val1); double trp2 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP2"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP2"].Value) * Convert.ToInt32(val2); double trp22 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP22"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP22"].Value) * Convert.ToInt32(val2); double trp3 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP3"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP3"].Value) * Convert.ToInt32(val3); double trp33 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["TRP33"].Value == DBNull.Value ? 0 : DGV1.Rows[row.Index].Cells["TRP33"].Value) * Convert.ToInt32(val3); int TrdqtyBuy = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), "BUY") && (a.Field<string>("Status") == "Traded")).ToList().Count; int TrdqtySell = Global.Instance.OrdetTable.AsEnumerable().Where(a => (Convert.ToInt32(a.Field<string>("TokenNo")) == tokenno) && String.Equals(a.Field<string>("Buy_SellIndicator"), "SELL") && (a.Field<string>("Status") == "Traded")).ToList().Count; trd_obj = new TradeTrac(); var crea = trp1 + trp2 + trp3; var rev = trp11 + trp22 + trp33; trd_obj = Global.Instance.TradeTrac_dict[near_tok1]; trd_obj.ACTUALPRICE = sp == true ? crea : rev; trd_obj.B_S = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator); trd_obj.QTy = IPAddress.HostToNetworkOrder(obj.FillQuantity); trd_obj.SYMBOL = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol); trd_obj.TIME = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff"); Global.Instance.TradeTrac_dict.AddOrUpdate(IPAddress.HostToNetworkOrder(obj.Token), trd_obj, (k, v1) => trd_obj); DataRow[] dr = Global.Instance.TradeTracker.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'"); if (dr.Length > 0) { dr[0]["PF_ID"] = Convert.ToString(trd_obj.PF_ID); //dr[0]["B/S"] = trd_obj.B_S == 1 ? "BUY" : "SELL"; dr[0]["B/S"] = sp == true ? "BUY" : "SELL"; // dr[0]["QTY"] = Convert.ToString(trd_obj.QTy); double vo = Convert.ToDouble(IPAddress.HostToNetworkOrder(obj.FillQuantity)); double createratio = Convert.ToDouble(_lotsize.lotsize * val3); dr[0]["QTY"] = vo / createratio >= Convert.ToDouble(1.0) ? "Complete" : "Partial"; dr[0]["QTY"] = dr[0]["QTY"] + " \t" + Convert.ToString(Math.Round(vo / createratio, 2)); //"1"; // dr[0]["QTY"] = trd_obj.B_S == 1 ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); // dr[0]["QTY"] = Convert.ToDecimal(IPAddress.HostToNetworkOrder(obj.OriginalVolume) / (Convert.ToInt32(_lotsize.lotsize) * (Convert.ToInt32(val3)))); // dr[0]["QTY"] = sp == true ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); dr[0]["ACTUALPRICE"] = Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.ACTUALPRICE), 3)); dr[0]["GIVENPRICEBUY"] = sp == true ? Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Buy), 3)) : "0"; dr[0]["GIVENPRICESELL"] = sp == true ? "0" : Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Sell), 3)); dr[0]["SYMBOL"] = Convert.ToString(trd_obj.SYMBOL); dr[0]["TIME"] = Convert.ToString(trd_obj.TIME); dr[0]["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString(); // Trade_Tracker.Instance.DGV.Refresh(); } else { BeginInvoke((Action)delegate { DataRow dr2 = Global.Instance.TradeTracker.NewRow(); // dr2["Sno2"] = trd_ob.ToString(); dr2["PF_ID"] = Convert.ToString(trd_obj.PF_ID); // dr2["B/S"] = trd_obj.B_S == 1 ? "BUY" : "SELL"; dr2["B/S"] = sp == true ? "BUY" : "SELL"; // dr2["QTY"] = Convert.ToString(trd_obj.QTy); double vo = Convert.ToDouble(IPAddress.HostToNetworkOrder(obj.FillQuantity)); double createratio = Convert.ToDouble(_lotsize.lotsize * val3); dr2["QTY"] = vo / createratio >= Convert.ToDouble(1.0) ? "Complete" : "Partial"; dr2["QTY"] = dr2["QTY"] + " \t" + Convert.ToString(Math.Round(vo / createratio, 2)); //"1"; // dr2["QTY"] = trd_obj.B_S == 1 ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); // dr[0]["QTY"] =Convert.ToDecimal(IPAddress.HostToNetworkOrder(obj.OriginalVolume) / (Convert.ToInt32(_lotsize.lotsize) * (Convert.ToInt32(val3)))); //dr2["QTY"] = sp == true ? Convert.ToDouble(TrdqtyBuy) : Convert.ToDouble(TrdqtySell); dr2["ACTUALPRICE"] = Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.ACTUALPRICE), 3)); // dr2["GIVENPRICEBUY"] = trd_obj.B_S == 1 ? Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Buy), 3)) : "0"; // dr2["GIVENPRICESELL"] = trd_obj.B_S == 1 ? "0" : Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Sell), 3)); dr2["GIVENPRICEBUY"] = sp == true ? Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Buy), 3)) : "0"; dr2["GIVENPRICESELL"] = sp == true ? "0" : Convert.ToString(Math.Round(Convert.ToDouble(trd_obj.Given_Price_Sell), 3)); dr2["SYMBOL"] = Convert.ToString(trd_obj.SYMBOL); dr2["TIME"] = Convert.ToString(trd_obj.TIME); dr2["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString(); Global.Instance.TradeTracker.Rows.Add(dr2); //Trade_Tracker.Instance.DGV.Refresh(); }); } //================================================================================================================================ double WTC_txt1 = Convert.ToDouble(DGV1.Rows[row.Index].Cells["W_T_C"].Value); if (sp == true) // crea { if ((Math.Abs((trd_obj.Given_Price_Buy)) + Math.Abs(WTC_txt1)) < Math.Abs(trd_obj.ACTUALPRICE)) { DGV1.Rows[row.Index].Cells["WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) + 1; } DGV1.Rows[row.Index].Cells["_con_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) + 1; if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == Convert.ToInt32(WTC_txt.Text) && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) // if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == 5 && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) { DGV1.Rows[row.Index].Cells["WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_con_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["Enable"].Value = false; } if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) != Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value)) { DGV1.Rows[row.Index].Cells["WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_con_WTC"].Value = 0; } } else // rev { if ((Math.Abs((trd_obj.Given_Price_Sell)) - Math.Abs(WTC_txt1)) > Math.Abs(trd_obj.ACTUALPRICE)) { DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) + 1; } // var _T_v = (IPAddress.HostToNetworkOrder(obj.FillPrice) / 100) + trd_obj.ACTUALPRICE; DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value) + 1; if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) == Convert.ToInt32(WTC_txt.Text) && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value)) // if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == 5 && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) { DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["Enable"].Value = false; } if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) != Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value)) { DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = 0; DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = 0; } } //===== === ==== === === ==== === === == === ==== ===== == === === ===== ==== ===== ===== ==== ==== ===== ==== === === == === ===== ==== ===== ==== } } } } } catch (Exception ex) { Client.LogWriterClass.logwritercls.logs("ErrorValue_check", "Value Check update in gridview" + ex.Message); } }
private void btnApply_Click(int RowIndex, int ColumnIndex) { if (RowIndex <= -1) return; //if (WTC_txt.Text == "") //{ // WTC_txt.BackColor = Color.Red; // return; //} //else //{ // WTC_txt.BackColor = Color.White; //} if (DGV1.Rows[RowIndex].Cells[ColumnIndex] is DataGridViewButtonCell) { //MessageBox.Show( DGV1.Rows[RowIndex].Cells["D_B"].Value.ToString()); using (frmDiff _frmDIff = new frmDiff()) { _frmDIff._FOPairDiff.BFSNDIFF = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BFSNDIFF"].Value); _frmDIff._FOPairDiff.BNSFDIFF = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BNSFDIFF"].Value); _frmDIff._FOPairDiff.BNSFMNQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["BNSFMNQ"].Value); _frmDIff._FOPairDiff.BFSNMNQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["BFSNMNQ"].Value); _frmDIff._FOPairDiff.BNSFMXQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["BNSFMXQ"].Value); _frmDIff._FOPairDiff.BFSNMXQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["BFSNMXQ"].Value); _frmDIff._FOPairDiff.PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); _frmDIff._FOPairDiff.TokenNear = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token1"].Value); _frmDIff._FOPairDiff.TokenFar = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token2"].Value); _frmDIff._FOPairDiff.Depth_Best =Convert.ToBoolean(DGV1.Rows[RowIndex].Cells["D_B"].Value) == true ? Convert.ToInt16(db.Best) : Convert.ToInt16(db.Depth); //decimal d; //if (decimal.TryParse(DGV1.Rows[RowIndex].Cells["TICKS"].Value.ToString(), out d)) //{ // MessageBox.Show("Please insert valid value"); // return; //} if (Convert.ToDouble(DGV1.Rows[RowIndex].Cells["TICKS"].Value) % 1 != 0) { MessageBox.Show("Please insert valid value"); return; } TradeTrac trd_struct = new TradeTrac(); trd_struct.PF_ID = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); trd_struct.Given_Price_Buy = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BNSFDIFF"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BNSFDIFF"].Value); trd_struct.Given_Price_Sell = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BFSNDIFF"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BFSNDIFF"].Value); //trd_struct.B_S = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); Global.Instance.TradeTrac_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token1"].Value), trd_struct, (k, v1) => trd_struct); TradeTrac trd_struct2 = new TradeTrac(); trd_struct2.PF_ID = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); //trd_struct2.B_S = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); trd_struct2.Given_Price_Buy = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BNSFDIFF"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BNSFDIFF"].Value); trd_struct2.Given_Price_Sell = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BFSNDIFF"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BFSNDIFF"].Value); Global.Instance.TradeTrac_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token2"].Value), trd_struct2, (k, v1) => trd_struct2); _frmDIff._FOPairDiff.TickCount =(int)Math.Round(Convert.ToDouble(DGV1.Rows[RowIndex].Cells["TICKS"].Value)); byte[] buffer = DataPacket.RawSerialize(_frmDIff._FOPairDiff); NNFHandler.Instance.Publisher( MessageType.FOPAIRDIFF , buffer); Global.Instance.write = true; if (Convert.ToBoolean(DGV1.Rows[RowIndex].Cells["Enable"].Value) == true) { DGV1.Rows[RowIndex].Cells["Enable"].Style.BackColor = Color.Green; } //Task.Factory.StartNew(() => applyFun()); } } }
private void btnApply_Click(int RowIndex, int ColumnIndex) { if (RowIndex <= -1) return; if (DGV1.Rows[RowIndex].Cells[ColumnIndex] is DataGridViewButtonCell) { //======================================================================================================================================================= var se = DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value == "" ? "0" : DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value; var bpy = DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value == "" ? "0" : DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value; var sep = DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value == "" ? "0" : DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value; var ods = DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value == "" ? "0" : DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value; var totalqB = DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value == "" ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value; var totalqS = DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value == "" ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value; var cmpS = DGV1.Rows[RowIndex].Cells["CMP(S)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["CMP(S)"].Value; var cmpB = DGV1.Rows[RowIndex].Cells["CMP(B)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["CMP(B)"].Value; double ORDQTYB = Convert.ToDouble(se); double BUYPRICE = Convert.ToDouble(bpy); double SELLPRICE = Convert.ToDouble(sep); double ORDQTYs = Convert.ToDouble(ods); double TOTALQTYB = Convert.ToDouble(totalqB); double TOTALQTYS = Convert.ToDouble(totalqS); double cmpS1 = ((Convert.ToDouble(cmpS) * 5) / 100) + Convert.ToDouble(cmpS); double cmpSdou = Convert.ToDouble(cmpS) - ((Convert.ToDouble(cmpS) * 5) / 100); double cmpB1 = ((Convert.ToDouble(cmpB) * 5) / 100) + Convert.ToDouble(cmpB); double cmpBdou = Convert.ToDouble(cmpB) - ((Convert.ToDouble(cmpB) * 5) / 100); if (ORDQTYB > 100) { label1.Visible = true; label1.Text = "PLZ Enter ORDQTY(B) > 100"; DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value = 0; return; } else { label1.Visible = false; label1.Text = "*"; } if (ORDQTYs > 100) { label2.Visible = true; label2.Text = "PLZ Enter ORDQTY(S) > 100"; DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value = 0; return; } else { label2.Visible = false; label2.Text = "*"; } if (TOTALQTYB > 500) { label5.Visible = true; label5.Text = "PLZ Enter TOTALQTY(B) > 500"; DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value = 0; return; } else { label5.Visible = false; label5.Text = "*"; } if (TOTALQTYS > 500) { label6.Visible = true; label6.Text = "PLZ Enter TOTALQTY(S) > 500"; DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value = 0; return; } else { label6.Visible = false; label6.Text = "*"; } if (Regex.IsMatch(Convert.ToString(cmpB.ToString()), @"[-/*()]")) { if (BUYPRICE < cmpB1) { label3.Visible = true; label3.Text = "PLZ Enter BUYPRICE > CMP(B) 5% "; DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value = 0; return; } else { // before = BUYPRICE; label3.Visible = false; label3.Text = "*"; } } else { if (BUYPRICE < cmpBdou) { label3.Visible = true; label3.Text = "PLZ Enter BUYPRICE > CMP(B) 5% "; DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value = 0; return; } else { // before = BUYPRICE; label3.Visible = false; label3.Text = "*"; } } if (Regex.IsMatch(Convert.ToString(cmpB.ToString()), @"[-/*()]")) { if (SELLPRICE > cmpSdou) { label4.Visible = false; label4.Text = "*"; } else { label4.Visible = true; label4.Text = "PLZ Enter SELLPRICE > CMP(S) 5% "; DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value = 0; return; } } else { // if (SELLPRICE > cmpSdou) if (SELLPRICE >= Convert.ToDouble(cmpS)) { label4.Visible = false; label4.Text = "*"; } else { label4.Visible = true; label4.Text = "PLZ Enter SELLPRICE > CMP(S) 5% "; DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value = 0; return; } } // ====================== ============== =============== =========== ========== ======== ========== ===== ========== =========== ======= ======= double _buy= Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value); double _sell = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value); string we = Convert.ToString(DGV1.SelectedRows[0].Cells["THRESHOLD"].Value == DBNull.Value ? "0" : DGV1.SelectedRows[0].Cells["THRESHOLD"].Value); string THRESHOLD2 = ""; if (we =="0") { THRESHOLD2 = we; } else { THRESHOLD2= we.Remove(we.Length - 1); } // FOPAIRDIFFLEG2 _frmDIff = new FOPAIRDIFFLEG2; //{ // PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["PF"].Value), // BuyMin = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value), // BuyMax = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value), // // Divisor = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value), // SPREADBUY = Convert.ToInt32(_buy * 100), // SPREADSELL = Convert.ToInt32(_sell * 100), // SellMin = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value), // SellMax = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value), // Token1Ratio = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ratio1"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ratio1"].Value), // Token2Ratio = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ratio2"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ratio2"].Value), // Token3Ratio = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ratio3"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ratio3"].Value), // Token4Ratio = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ratio4"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ratio4"].Value), //// // Order_Type = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["Order_Type"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["Order_Type"].Value), // Order_Type = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["Order_Type"].Value == DBNull.Value ? OrderType.defaul : //Convert.ToString(DGV1.Rows[RowIndex].Cells["Order_Type"].Value) == "Bidding" ? OrderType.Bidding : // Convert.ToString(DGV1.Rows[RowIndex].Cells["Order_Type"].Value) == "IOC" ? OrderType.IOC : OrderType.defaul // ), // firstbid =(short) (DGV1.Rows[RowIndex].Cells["First_LEG"].Value == DBNull.Value ? FirstBid.defaul : // Convert.ToString(DGV1.Rows[RowIndex].Cells["First_LEG"].Value) == "NORMAL" ? FirstBid.Normal : // Convert.ToString(DGV1.Rows[RowIndex].Cells["First_LEG"].Value) == "WEIGHTED" ? FirstBid.WEIGHTED : // Convert.ToString(DGV1.Rows[RowIndex].Cells["First_LEG"].Value) == "BESTBID" ? FirstBid.BESTBID : FirstBid.defaul), // second_leg =(short) (DGV1.Rows[RowIndex].Cells["Second_Leg"].Value == DBNull.Value ? SecondLeg.defaul : // Convert.ToString(DGV1.Rows[RowIndex].Cells["Second_Leg"].Value) == "MKT" ? SecondLeg.MKT : // Convert.ToString(DGV1.Rows[RowIndex].Cells["Second_Leg"].Value) == "LIMIT" ? SecondLeg.LIMIT : // Convert.ToString(DGV1.Rows[RowIndex].Cells["Second_Leg"].Value) == "BEST BID" ? SecondLeg.BESTBID : SecondLeg.defaul), // Req_count = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["ReqConnt"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ReqConnt"].Value), // Opt_Tick = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["OPT_TICK"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["OPT_TICK"].Value), // Order_Depth = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["ORDER_DEPTH"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["ORDER_DEPTH"].Value), // // Threshold = Convert.ToInt16(THRESHOLD2), // Bidding_Range = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["BIDDING_RANGE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BIDDING_RANGE"].Value), // //Pay_up_Ticks = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["PAYUPTIEKS"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["PAYUPTIEKS"].Value), //}; using (frmDiff _frmDIff = new frmDiff()) { _frmDIff._FOPairDiff.BFSNDIFF = Convert.ToInt32(_buy * 100); _frmDIff._FOPairDiff.BNSFDIFF = Convert.ToInt32(_sell * 100); _frmDIff._FOPairDiff.BNSFMNQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ORDQTY(S)"].Value); _frmDIff._FOPairDiff.BFSNMNQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ORDQTY(B)"].Value); _frmDIff._FOPairDiff.BNSFMXQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["TOTALQTY(S)"].Value); _frmDIff._FOPairDiff.BFSNMXQ = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["TOTALQTY(B)"].Value); _frmDIff._FOPairDiff.PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); _frmDIff._FOPairDiff.TokenNear = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token2"].Value); _frmDIff._FOPairDiff.TokenFar = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token1"].Value); // _frmDIff._FOPairDiff.Depth_Best =Convert.ToBoolean(DGV1.Rows[RowIndex].Cells["D_B"].Value) == true ? Convert.ToInt16(db.Best) : Convert.ToInt16(db.Depth); _frmDIff._FOPairDiff._obj_FOPair = new FOPAIR() { PORTFOLIONAME = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value), TokenNear = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token2"].Value), TokenFar = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token1"].Value), Token1Ratio = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ratio2"].Value), Token2Ratio = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["ratio1"].Value), Token1side = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["Tok2B_S"].Value.ToString() == "Buy" ? 1 : 2), Token2side = Convert.ToInt16(DGV1.Rows[RowIndex].Cells["Tok1B_S"].Value.ToString() == "Buy" ? 1 : 2) }; NNFHandler.Instance.Publisher(MessageType.FOPAIRDIFF, DataPacket.RawSerialize(_frmDIff._FOPairDiff)); TradeTrac trd_struct = new TradeTrac(); trd_struct.PF_ID = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); trd_struct.Given_Price_Buy = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value); trd_struct.Given_Price_Sell = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value); //trd_struct.B_S = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); Global.Instance.TradeTrac_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token1"].Value), trd_struct, (k, v1) => trd_struct); TradeTrac trd_struct2 = new TradeTrac(); trd_struct2.PF_ID = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); //trd_struct2.B_S = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); trd_struct2.Given_Price_Buy = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value); trd_struct2.Given_Price_Sell = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value); Global.Instance.TradeTrac_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token2"].Value), trd_struct2, (k, v1) => trd_struct2); Global.Instance.Refresh_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value), _frmDIff, (k, v1) => _frmDIff); TradeTrac trd_struct3 = new TradeTrac(); trd_struct3.PF_ID = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); //trd_struct2.B_S = Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value); trd_struct3.Given_Price_Buy = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["BUYPRICE"].Value); trd_struct3.Given_Price_Sell = Convert.ToDouble(DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value == DBNull.Value ? "0" : DGV1.Rows[RowIndex].Cells["SELLPRICE"].Value); Global.Instance.TradeTrac_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["Token3"].Value), trd_struct3, (k, v1) => trd_struct3); Global.Instance.Refresh_dict.AddOrUpdate(Convert.ToInt32(DGV1.Rows[RowIndex].Cells["PF"].Value), _frmDIff, (k, v1) => _frmDIff); //NNFHandler.Instance.Publisher(MessageType.IOCPAIRDIFF, DataPacket.RawSerialize(_frmDIff)); } Task.Factory.StartNew(() => applyFun()); DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)DGV1.Rows[RowIndex].Cells["Enable"]; if ( checkCell.Value == null) { checkCell.Value = false; } if ((bool)checkCell.Value == true && checkCell.Value != null) { DGV1.Rows[RowIndex].Cells["PF"].Style.BackColor = Color.Green; } // DGV1.Rows[RowIndex].Cells["Apply"].Style.ForeColor = Color.Green; // DGV1.Rows[RowIndex].Cells["ratio4"].CurrentCell.Style.SelectionBackColor = Color.Red; } }
public void Fillqty_ingrd(byte[] buffer) { try { object ob = new object(); lock (ob) { var obj = (MS_TRADE_CONFIRM_TR)DataPacket.RawDeserialize(buffer, typeof(MS_TRADE_CONFIRM_TR)); foreach(DataGridViewRow row2 in DGV1.Rows) { if (Convert.ToString(row2.Cells["Token1"].Value) == Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token))) { row = row2; break; } } // DataGridViewRow row = DGV1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["Token1"].Value.ToString().Equals(Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token)))).FirstOrDefault(); if (row == null) { //row = DGV1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["Token2"].Value.ToString().Equals(Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token)))).FirstOrDefault(); return; } first_tok=frmNetBook.Instance.query1.Where(a => a.TokenNo == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token1"].Value)).ToList(); second_tok = frmNetBook.Instance.query1.Where(a => a.TokenNo == Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token2"].Value)).ToList(); string _neartoken = DGV1.Rows[row.Index].Cells["Token1"].Value.ToString(); int _first_Tok = Convert.ToInt32(DGV1.Rows[row.Index].Cells["Token1"].Value); // string _fartoken = DGV1.Rows[row.Index].Cells["Token2"].Value.ToString(); if (_neartoken == Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token))) { if (IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1) { if (DGV1.Rows[row.Index].Cells["BNSFTQ"].Value == null || Convert.ToString(DGV1.Rows[row.Index].Cells["BNSFTQ"].Value) == "") { DGV1.Rows[row.Index].Cells["BNSFTQ"].Value = 0; } // if (IPAddress.HostToNetworkOrder(obj.RemainingVolume) <= 0) // { DGV1.Rows[row.Index].Cells["BNSFTQ"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["BNSFTQ"].Value) + 1; /* this.DGV1.Columns["Buy_Avg"].DefaultCellStyle.Format = "0.##"; this.DGV1.Columns["Sell_Avg"].DefaultCellStyle.Format = "0.##";*/ //} if (DGV1.Rows[row.Index].Cells["Buy_Avg"].Value == null || Convert.ToString(DGV1.Rows[row.Index].Cells["Buy_Avg"].Value) == "") { DGV1.Rows[row.Index].Cells["Buy_Avg"].Value = 0; } DGV1.Rows[row.Index].Cells["Buy_Avg"].Value =((first_tok.Count() ==0 ?0 : first_tok.FirstOrDefault().BuyAvg) - (second_tok.Count()==0?0:second_tok.FirstOrDefault().SellAvg)); if (Global.Instance.TradeTrac_dict.ContainsKey(_first_Tok)) { trd_obj = new TradeTrac(); trd_obj = Global.Instance.TradeTrac_dict[_first_Tok]; trd_obj.ACTUALPRICE = Convert.ToDouble(DGV1.Rows[row.Index].Cells["BNSFTD"].Value); trd_obj.B_S = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator); trd_obj.QTy = IPAddress.HostToNetworkOrder(obj.FillQuantity); trd_obj.SYMBOL = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol); trd_obj.TIME = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff"); Global.Instance.TradeTrac_dict.AddOrUpdate(IPAddress.HostToNetworkOrder(obj.Token), trd_obj, (k, v1) => trd_obj); DataRow dr2 = Global.Instance.TradeTracker.NewRow(); // dr2["Sno2"] = trd_ob.ToString(); dr2["PF_ID"] = Convert.ToString(trd_obj.PF_ID); dr2["B/S"] = trd_obj.B_S == 1 ? "BUY" : "SELL"; dr2["QTY"] = Convert.ToString(trd_obj.QTy); dr2["ACTUALPRICE"] = Convert.ToString(trd_obj.ACTUALPRICE); dr2["GIVENPRICEBUY"] = Convert.ToString(trd_obj.Given_Price_Buy); dr2["SYMBOL"] = Convert.ToString(trd_obj.SYMBOL); dr2["TIME"] = Convert.ToString(trd_obj.TIME); //if ((trd_obj.Given_Price_Buy/100) > trd_obj.ACTUALPRICE) //{ // DGV1.Rows[row.Index].Cells["WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) + 1; //} Global.Instance.TradeTracker.Rows.Add(dr2); //DGV1.Rows[row.Index].Cells["_con_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) + 1; //if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) == Convert.ToInt32(WTC_txt.Text) && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value)) //{ // DGV1.Rows[row.Index].Cells["WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["_con_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["Enable"].Value = false; //} //if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["WTC"].Value) != Convert.ToInt32(DGV1.Rows[row.Index].Cells["_con_WTC"].Value)) //{ // DGV1.Rows[row.Index].Cells["WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["_con_WTC"].Value = 0; //} } } else { if (DGV1.Rows[row.Index].Cells["BFSNTQ"].Value == null || Convert.ToString(DGV1.Rows[row.Index].Cells["BFSNTQ"].Value) == "") { DGV1.Rows[row.Index].Cells["BFSNTQ"].Value = 0; } // if (IPAddress.HostToNetworkOrder(obj.RemainingVolume) <= 0) //{ DGV1.Rows[row.Index].Cells["BFSNTQ"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["BFSNTQ"].Value) + 1; //} if (DGV1.Rows[row.Index].Cells["Sell_Avg"].Value == null || Convert.ToString(DGV1.Rows[row.Index].Cells["Sell_Avg"].Value) == "") { DGV1.Rows[row.Index].Cells["Sell_Avg"].Value = 0; } DGV1.Rows[row.Index].Cells["Sell_Avg"].Value = (second_tok.Count()==0?0:second_tok.FirstOrDefault().BuyAvg) - (first_tok.Count()==0?0:first_tok.FirstOrDefault().SellAvg); if (Global.Instance.TradeTrac_dict.ContainsKey(_first_Tok)) { trd_obj = new TradeTrac(); trd_obj = Global.Instance.TradeTrac_dict[IPAddress.HostToNetworkOrder(obj.Token)]; trd_obj.ACTUALPRICE = Convert.ToDouble(DGV1.Rows[row.Index].Cells["BFSNTD"].Value); trd_obj.B_S = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator); trd_obj.QTy = IPAddress.HostToNetworkOrder(obj.FillQuantity); trd_obj.SYMBOL = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol); trd_obj.TIME = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff"); Global.Instance.TradeTrac_dict.AddOrUpdate(IPAddress.HostToNetworkOrder(obj.Token), trd_obj, (k, v1) => trd_obj); DataRow dr2 = Global.Instance.TradeTracker.NewRow(); // dr2["Sno2"] = trd_ob.ToString(); dr2["PF_ID"] = Convert.ToString(trd_obj.PF_ID); dr2["B/S"] = trd_obj.B_S == 1 ? "BUY" : "SELL"; dr2["QTY"] = Convert.ToString(trd_obj.QTy); dr2["ACTUALPRICE"] = Convert.ToString(trd_obj.ACTUALPRICE); dr2["GIVENPRICESEll"] = Convert.ToString(trd_obj.Given_Price_Sell); dr2["SYMBOL"] = Convert.ToString(trd_obj.SYMBOL); dr2["TIME"] = Convert.ToString(trd_obj.TIME); Global.Instance.TradeTracker.Rows.Add(dr2); // _sell_con_WTC_sell_WTC //if (((trd_obj.Given_Price_Buy/100)-(trd_obj.ACTUALPRICE))<0) //if (((IPAddress.HostToNetworkOrder(obj.FillPrice) / 100) - (trd_obj.Given_Price_Buy / 100)) > ((IPAddress.HostToNetworkOrder(obj.FillPrice) / 100) + trd_obj.ACTUALPRICE)) //{ // DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) + 1; //} //var _T_v=(IPAddress.HostToNetworkOrder(obj.FillPrice) / 100) + trd_obj.ACTUALPRICE; //DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value) + 1; //if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) == Convert.ToInt32(WTC_txt.Text) && Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value) == Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value)) //{ // DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["Enable"].Value = false; //} //if (Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_WTC"].Value) != Convert.ToInt32(DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value)) //{ // DGV1.Rows[row.Index].Cells["_sell_WTC"].Value = 0; // DGV1.Rows[row.Index].Cells["_sell_con_WTC"].Value = 0; //} } } } //else if (_fartoken == Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token))) //{ // if(IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1) // { // if (DGV1.Rows[row.Index].Cells["BFSNTQ"].Value == null || Convert.ToString(DGV1.Rows[row.Index].Cells["BFSNTQ"].Value) == "") // { // DGV1.Rows[row.Index].Cells["BFSNTQ"].Value = 0; // } // DGV1.Rows[row.Index].Cells["BFSNTQ"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["BFSNTQ"].Value) + 1; // } // else // { // if (DGV1.Rows[row.Index].Cells["BNSFTQ"].Value == null || Convert.ToString(DGV1.Rows[row.Index].Cells["BNSFTQ"].Value) == "") // { // DGV1.Rows[row.Index].Cells["BNSFTQ"].Value = 0; // } // DGV1.Rows[row.Index].Cells["BNSFTQ"].Value = Convert.ToInt32(DGV1.Rows[row.Index].Cells["BNSFTQ"].Value) + 1; // } //} } } catch (Exception ex) { // Client.LogWriterClass.logwritercls.logs("ErrorValue_check.txt", "Value Check update in gridview" + ex.Message); } }