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;

            }
        }
Ejemplo n.º 2
0
        private void ApplyAll_Click(object sender, EventArgs e)
        {
            //if (DGV1.Rows[RowIndex].Cells[ColumnIndex] is DataGridViewButtonCell)

            //if (WTC_txt.Text == "")
            //{
            //    WTC_txt.BackColor = Color.Red;
            //    return;
            //}
            //else
            //{
            //    WTC_txt.BackColor = Color.White;
            //}
            foreach(DataGridViewRow dr in DGV1.Rows)
            {
                   using (frmDiff _frmDIff = new frmDiff())
                {
                    _frmDIff._FOPairDiff.BFSNDIFF = Convert.ToDouble(dr.Cells["BFSNDIFF"].Value);
                    _frmDIff._FOPairDiff.BNSFDIFF = Convert.ToDouble(dr.Cells["BNSFDIFF"].Value);
                    _frmDIff._FOPairDiff.BNSFMNQ = Convert.ToInt32(dr.Cells["BNSFMNQ"].Value);
                    _frmDIff._FOPairDiff.BFSNMNQ = Convert.ToInt32(dr.Cells["BFSNMNQ"].Value);
                    _frmDIff._FOPairDiff.BNSFMXQ = Convert.ToInt32(dr.Cells["BNSFMXQ"].Value);
                    _frmDIff._FOPairDiff.BFSNMXQ = Convert.ToInt32(dr.Cells["BFSNMXQ"].Value);
                    _frmDIff._FOPairDiff.PORTFOLIONAME = Convert.ToInt32(dr.Cells["PF"].Value);
                    _frmDIff._FOPairDiff.TokenNear = Convert.ToInt32(dr.Cells["Token1"].Value);
                    _frmDIff._FOPairDiff.TokenFar = Convert.ToInt32(dr.Cells["Token2"].Value);
                    _frmDIff._FOPairDiff.Depth_Best = Convert.ToBoolean(dr.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(dr.Cells["TICKS"].Value) % 1 != 0)
                    {
                        MessageBox.Show("Please insert valid value");
                        return;
                    }
                    if (Convert.ToBoolean(dr.Cells["Enable"].Value) == true)
                    {
                        dr.Cells["Enable"].Style.BackColor = Color.Green;
                    }

                    _frmDIff._FOPairDiff.TickCount = (int)Math.Round(Convert.ToDouble(dr.Cells["TICKS"].Value));
                    byte[] buffer = DataPacket.RawSerialize(_frmDIff._FOPairDiff);
                    NNFHandler.Instance.Publisher(MessageType.FOPAIRDIFF, buffer);
                    Global.Instance.write = true;
                    //Task.Factory.StartNew(() => applyFun());
                }
            }
        }
Ejemplo n.º 3
0
        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());
                }
            }
        }
Ejemplo n.º 4
0
        private void btnApply_Click(int RowIndex, int ColumnIndex)
        {
            if (RowIndex <= -1)
                return;
            if (DGV1.Rows[RowIndex].Cells[ColumnIndex] is DataGridViewButtonCell)
            {
                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);
                    if (Convert.ToDouble(DGV1.Rows[RowIndex].Cells["TICKS"].Value) %1 != 0)
                    {
                        MessageBox.Show("Please insert valid value");
                        return;
                    }

                    _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);
                    Task.Factory.StartNew(() => applyFun());
                }
            }
        }