コード例 #1
0
        private void SellOrder(DataGridViewRow Dr)
        {
            using (var frmord = new frmSpreadOrdEntry())
            {

                frmord.lblSpdOrderMsg.Text = "SELL " + Dr.Cells[SpreadContract.Symbol1].Value + Dr.Cells[SpreadContract.ExpiryDate2].Value;//+ Dr.Cells[SpreadContract.ExpiryDate1].Value;
                //frmord.lblSpdOrderMsg.BackColor = Color.Green;
                frmord.BackColor = ControlPaint.Light(Color.IndianRed);//Color.PaleVioletRed;

                frmord.cmbInstName1.Text = Dr.Cells[SpreadContract.InstrumentName1].Value.ToString();
                frmord.cmbInstName2.Text = Dr.Cells[SpreadContract.InstrumentName2].Value.ToString();
                frmord.cmbSymbol1.Text = Dr.Cells[SpreadContract.Symbol1].Value.ToString();
                frmord.cmbSymbol2.Text = Dr.Cells[SpreadContract.Symbol2].Value.ToString();
                frmord.cmbOpType1.Text = Dr.Cells[SpreadContract.OptionType1].Value.ToString();
                frmord.cmbOpType2.Text = Dr.Cells[SpreadContract.OptionType2].Value.ToString();
                frmord.cmbStrikePrice1.Text = Dr.Cells[SpreadContract.StrikePrice1].Value.ToString();
                frmord.cmbStrikePrice2.Text = Dr.Cells[SpreadContract.StrikePrice2].Value.ToString();
                frmord.cmbExpiry1.Text = Dr.Cells[SpreadContract.ExpiryDate1].Value.ToString();
                frmord.cmbExpiry2.Text = Dr.Cells[SpreadContract.ExpiryDate2].Value.ToString();
                frmord.txtPrice1.Text = Dr.Cells[SpreadContract.Bid].Value.ToString();
               frmord.txtTotalQty1.Text = "1";
               frmord.txtTotalQty2.Text = "1";

                frmord.txtMktLot1.Text = Dr.Cells[SpreadContract.BoardLotQuantity1].Value.ToString();
                frmord.txtMktLot2.Text = Dr.Cells[SpreadContract.BoardLotQuantity2].Value.ToString();

                frmord.cmbBuySell1.Text = "BUY";
                frmord.cmbBuySell2.Text = "SELL";
                pSpreadOrd.Token1 = Convert.ToInt32(Dr.Cells[SpreadContract.Token1].Value);
                pSpreadOrd.Token2 = Convert.ToInt32(Dr.Cells[SpreadContract.Token2].Value);

                // frmord.DesktopLocation = new Point(100, 100);
                int x = (Screen.PrimaryScreen.WorkingArea.Width - frmord.Width) / 2;
                int y = (Screen.PrimaryScreen.WorkingArea.Height - frmord.Height) - 50;
                frmord.Location = new Point(x, y);

                // var v = Convert.ToInt32(Dr.Cells[SpreadContract.ExpiryDate1].Value);
                if (frmord.ShowDialog(this) == DialogResult.OK)
                {
                    if (frmord.FormSpdDialogResult == (int)OrderEntryButtonCase.SUBMIT)
                    {
                        if (MessageBox.Show(this, "Are you sure you Want to Place Buy Order?",
                                          Application.ProductName, MessageBoxButtons.YesNo,
                                          MessageBoxIcon.Question) == DialogResult.Yes)
                        {

                            pSpreadOrd = new PlaceSpreadOrder();
                            pSpreadOrd.SecInfo1.Symbol = frmord.cmbSymbol1.Text;
                            pSpreadOrd.SecInfo2.Symbol = frmord.cmbSymbol2.Text;
                            pSpreadOrd.SecInfo1.InstrumentName = frmord.cmbInstName1.Text;
                            pSpreadOrd.SecInfo2.InstrumentName = frmord.cmbInstName2.Text;

                            pSpreadOrd.SecInfo1.ExpiryDate = Convert.ToInt32(Dr.Cells[SpreadContract.UnixExpiry1].Value);
                            pSpreadOrd.SecInfo2.ExpiryDate = Convert.ToInt32(Dr.Cells[SpreadContract.UnixExpiry2].Value);
                            pSpreadOrd.SecInfo1.OptionType = frmord.cmbOpType1.Text;
                            pSpreadOrd.SecInfo2.OptionType = frmord.cmbOpType2.Text;
                            pSpreadOrd.SecInfo1.StrikePrice = Convert.ToInt32(frmord.cmbStrikePrice1.Text);
                            pSpreadOrd.SecInfo2.StrikePrice = Convert.ToInt32(frmord.cmbStrikePrice2.Text);
                            pSpreadOrd.SecInfo1.CALevel = Convert.ToInt16(Dr.Cells[SpreadContract.CALevel1].Value);
                            pSpreadOrd.SecInfo2.CALevel = Convert.ToInt16(Dr.Cells[SpreadContract.CALevel2].Value);

                            pSpreadOrd.BuySell1 = 1;
                            pSpreadOrd.BuySell2 = 2;
                            pSpreadOrd.Token1 =Convert.ToInt32(Dr.Cells[SpreadContract.Token1].Value);
                            pSpreadOrd.Token2 = Convert.ToInt32(Dr.Cells[SpreadContract.Token2].Value);

                            pSpreadOrd.Price1 = Convert.ToInt32(Convert.ToSingle(frmord.txtPrice1.Text) * 100);
                            pSpreadOrd.Volume1 = Convert.ToInt32(frmord.txtTotalQty1.Text) * Convert.ToInt32(Dr.Cells[SpreadContract.BoardLotQuantity1].Value);
                            pSpreadOrd.Volume2 = Convert.ToInt32(frmord.txtTotalQty2.Text) * Convert.ToInt32(Dr.Cells[SpreadContract.BoardLotQuantity1].Value);

                            NNFInOut.Instance.SP_BOARD_LOT_IN(pSpreadOrd);

                            SpdOrderTableMethods._PriceDiff[pSpreadOrd.Token1] = new Dictionary<Structure.BUYSELL, float>();
                            SpdOrderTableMethods._PriceDiff[pSpreadOrd.Token1][Structure.BUYSELL.BUY] = Convert.ToSingle(frmord.txtPrice1.Text);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: NNFInOut.cs プロジェクト: spsinghdocument1/C-
        //2100
        public void SP_BOARD_LOT_IN(PlaceSpreadOrder spdOrder)
        {
            C_Spread_lot_In obj = new C_Spread_lot_In()
            {
                TransectionCode = 2100,
                OrderNo = OrderNoGet,
                ClintId = Global.Instance.ClientId,
                TokenNo = spdOrder.Token1,
                ReasonCode = 0,
                contract_obj = new C_Contract_Desc()
                {
                    InstrumentName = spdOrder.SecInfo1.InstrumentName,
                    Symbol = spdOrder.SecInfo1.Symbol,
                    ExpiryDate = spdOrder.SecInfo1.ExpiryDate,
                    StrikePrice = spdOrder.SecInfo1.StrikePrice,
                    OptionType = spdOrder.SecInfo1.OptionType,
                    CALevel = spdOrder.SecInfo1.CALevel,
                },
                AccountNumber = "",
                Buy_SellIndicator = spdOrder.BuySell1,
                Volume = spdOrder.Volume1,
                Price = 0,
                Open_Close = Convert.ToByte('O'),

                obj_leg2 = new C_MS_SPD_LEG_INFO()
                {
                    token = spdOrder.Token2,
                    Price2 = 0,
                    contract_obj = new C_Contract_Desc()
                    {
                        InstrumentName = spdOrder.SecInfo2.InstrumentName,
                        Symbol = spdOrder.SecInfo2.Symbol,
                        ExpiryDate = spdOrder.SecInfo2.ExpiryDate,
                        StrikePrice = spdOrder.SecInfo2.StrikePrice,
                        OptionType = spdOrder.SecInfo2.OptionType,
                        CALevel = spdOrder.SecInfo2.CALevel,
                    },
                    BuySell2 = spdOrder.BuySell2,
                    Volume2 = spdOrder.Volume2,
                    OpenClose2 = Convert.ToByte('O'),
                },

            };

            obj.PriceDiff = spdOrder.Price1;
            byte[] buffer = DataPacket.RawSerialize(obj);
            NNFHandler.Instance.Publisher(MessageType.ORDER, buffer);
        }