Esempio n. 1
0
 //
 //
 private void buttonFindResultingInstrument_Click(object sender, EventArgs e)
 {
     if (m_InstrumentMatrix != null)
     {
         ResultingInstrument resultingInstrument;
         InstrumentName      instrumentName1;
         InstrumentName      instrumentName2;
         if (InstrumentName.TryDeserialize(this.textBoxInstrument1.Text, out instrumentName1) &&
             InstrumentName.TryDeserialize(this.textBoxInstrument2.Text, out instrumentName2))
         {
             int filledQty1;
             int filledQty2;
             if (int.TryParse(this.textBoxQty1.Text, out filledQty1) && int.TryParse(this.textBoxQty2.Text, out filledQty2))
             {
                 int resultingQty;
                 int qty1Remaining;
                 int qty2Remaining;
                 if (m_InstrumentMatrix.TryFindResultingInstrument(instrumentName1, filledQty1, instrumentName2, filledQty2,
                                                                   out resultingInstrument, out resultingQty, out qty1Remaining, out qty2Remaining))
                 {
                     this.textBoxResultingInstrument.Text = resultingInstrument.ResultingInstrumentName.FullName;
                     this.textBoxResultingQty.Text        = resultingQty.ToString();
                     this.textBoxQty1Remaining.Text       = qty1Remaining.ToString();
                     this.textBoxQty2Remaining.Text       = qty2Remaining.ToString();
                 }
                 else
                 {
                     this.textBoxResultingInstrument.Text = string.Empty;
                     this.textBoxResultingQty.Text        = string.Empty;
                     this.textBoxQty1Remaining.Text       = string.Empty;
                     this.textBoxQty2Remaining.Text       = string.Empty;
                 }
             }
             else
             {
                 this.textBoxResultingInstrument.Text = string.Empty;
                 this.textBoxResultingQty.Text        = string.Empty;
                 this.textBoxQty1Remaining.Text       = string.Empty;
                 this.textBoxQty2Remaining.Text       = string.Empty;
             }
         }
         else
         {
             this.textBoxResultingInstrument.Text = string.Empty;
             this.textBoxResultingQty.Text        = string.Empty;
             this.textBoxQty1Remaining.Text       = string.Empty;
             this.textBoxQty2Remaining.Text       = string.Empty;
         }
     }
     else
     {
         m_Log.NewEntry(LogLevel.Minor, "Not setup the instrument matrix yet.");
     }
 }
Esempio n. 2
0
        public void ShowInstrumentMatrix(List <InstrumentName> instrumentNames, InstrumentMatrix instrumentMatrix)
        {
            this.m_InstrumentNames = instrumentNames;
            DataTable dataTable       = new DataTable("InstrumentMatrix");
            int       instrumentCount = instrumentNames.Count;

            for (int index = 0; index < instrumentCount; ++index)
            {
                string instrumentNameString = instrumentNames[index].FullName;
                dataTable.Columns.Add(instrumentNameString, typeof(string));
            }
            for (int index = 0; index < instrumentCount; ++index)
            {
                dataTable.Rows.Add(new object[instrumentCount]);
            }

            this.dataGridViewInstrumentMatrix.SuspendLayout();
            this.dataGridViewInstrumentMatrix.ColumnHeadersHeight = m_CellHeight;
            this.dataGridViewInstrumentMatrix.DataSource          = dataTable;

            for (int xIndex = 0; xIndex < instrumentCount; ++xIndex)
            {
                for (int yIndex = 0; yIndex < instrumentCount; ++yIndex)
                {
                    InstrumentName      quoteInstrument = instrumentNames[xIndex];
                    InstrumentName      hedgeInstrument = instrumentNames[yIndex];
                    ResultingInstrument resultingInstrument;
                    if (instrumentMatrix.TryFindResultingInstrument(quoteInstrument, 0, hedgeInstrument, 0, out resultingInstrument))
                    {
                        dataTable.Rows[yIndex][xIndex] = resultingInstrument.ResultingInstrumentNameTT;
                    }
                }
            }

            foreach (DataGridViewColumn column in this.dataGridViewInstrumentMatrix.Columns)
            {
                column.Width    = m_CellWidth;
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            this.dataGridViewInstrumentMatrix.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
            this.dataGridViewInstrumentMatrix.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells);
            this.dataGridViewInstrumentMatrix.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            this.dataGridViewInstrumentMatrix.SelectionMode             = DataGridViewSelectionMode.CellSelect;
            this.dataGridViewInstrumentMatrix.ClipboardCopyMode         = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
            this.dataGridViewInstrumentMatrix.DefaultCellStyle.WrapMode = DataGridViewTriState.True;

            this.WindowState = FormWindowState.Maximized;
            this.Show();
            this.dataGridViewInstrumentMatrix.ResumeLayout();
        }