Ejemplo n.º 1
0
        private void btnApply_Click(int RowIndex, int ColumnIndex)
        {
            if (RowIndex <= -1)
                return;

            if (DGV1.Rows[RowIndex].Cells[ColumnIndex] is DataGridViewButtonCell)
            {

                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);
                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),
                 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)

             };

                NNFHandler.Instance.Publisher(MessageType.IOCPAIRDIFF, DataPacket.RawSerialize(_frmDIff));
                Task.Factory.StartNew(() => applyFun());

            }
        }
Ejemplo n.º 2
0
        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),
                };
                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(_frmDIff.PORTFOLIONAME, _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(_frmDIff.PORTFOLIONAME, _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;

            }
        }