internal void Add(string exchange, string symbol)
 {
     lock (LockObject)
     {
         SpreadMatrixData spreadMatrixData = new SpreadMatrixData(exchange, symbol);
         matrices.SetValue(exchange, symbol, spreadMatrixData);
         RaizeChanged(spreadMatrixData);
     }
 }
        public SecurityDefinitionRow NewRow(SpreadMatrixData spreadMatrixData)
        {
            SecurityDefinitionRow row = new SecurityDefinitionRow();

            row.label.Text = spreadMatrixData.Exchange + "/" + spreadMatrixData.Symbol;
            row.Exchange = spreadMatrixData.Exchange;
            row.Symbol = spreadMatrixData.Symbol;

            return row;
        }
Exemple #3
0
        public void CreateGrid(SpreadMatrixData smd)
        {
            ClearGrid();

            int dMonth = GetDeltaMonth(smd.MinYearMonth, smd.MaxYearMonth);

            if (smd.MaxYearMonth == new DateTime())
                return;

            for (int i = 0; i < dMonth; i++)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.Width = new GridLength(CellWidth);
                grid.ColumnDefinitions.Add(col);
            }

            for (int i = 0; i < dMonth + 1; i++)
            {
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(CellHeight);
                grid.RowDefinitions.Add(row);
            }

            for (int c = 0; c < dMonth + 1; c++)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.Width = new GridLength(CellWidth);
                gridHeader.ColumnDefinitions.Add(col);

                SpreadMatrixCell cellHeaderDate = new SpreadMatrixCell
                                                     {
                                                         Width = CellWidth,
                                                         Height = CellHeight/2
                                                     };
                cellHeaderDate.FillData(smd.MinYearMonth.AddMonths(c));

                Grid.SetRow(cellHeaderDate, 2);
                Grid.SetColumn(cellHeaderDate, c);

                SpreadMatrixDataCell cellHeader = new SpreadMatrixDataCell
                                             {
                                                 Width = CellWidth,
                                                 Height = CellHeight,
                                                 //AskPx = "?",
                                                 //AskCount = "?",
                                                 //BidPx = "?",
                                                 //BidCount = "?"
                                             };

                Grid.SetRow(cellHeader, 1);
                Grid.SetColumn(cellHeader, c);

                SpreadMatrixCell cellHeaderElm = new SpreadMatrixCell { Width = CellWidth, Height = CellHeight };

                Grid.SetRow(cellHeaderElm, 0);
                Grid.SetColumn(cellHeaderElm, c);
                cellHeaderElm.FillData("?");

                gridHeader.Children.Add(cellHeaderDate);
                gridHeader.Children.Add(cellHeader);
                gridHeader.Children.Add(cellHeaderElm);
            }

            for (int r = 0; r < dMonth; r++)
            {
                SpreadMatrixCell cellDate = new SpreadMatrixCell { Width = CellWidth, Height = CellHeight };

                Grid.SetRow(cellDate, r);
                Grid.SetColumn(cellDate, r);
                cellDate.FillData(smd.MinYearMonth.AddMonths(r));
                grid.Children.Add(cellDate);

                for (int c = r; c < dMonth; c++)
                {
                    MDDatePair datePair = new MDDatePair(smd.MinYearMonth.AddMonths(r), smd.MinYearMonth.AddMonths(c));
                    SpreadMatrixDataCell cell = smd.GetDataCell(datePair) ?? new SpreadMatrixDataCell();

                    cell.MouseDown += cell_MouseDown;

                    cell.Width = CellWidth;
                    cell.Height = CellHeight;
                    Grid.SetRow(cell, r == c ? r + 1 : r);
                    Grid.SetColumn(cell, c);
                    cellPosDictionary.SetValue(r, c, cell);
                    grid.Children.Add(cell);
                }
            }
            InvalidateVisual();
        }
Exemple #4
0
        private SecurityEntry GetSecurity(SpreadMatrixData smd, SpreadMatrixDataCell cell)
        {
            int r = Grid.GetRow(cell);
            int c = Grid.GetColumn(cell);
            if (r > c)
                r--;

            DateTime date1 = smd.MinYearMonth.AddMonths(r);
            DateTime date2 = smd.MinYearMonth.AddMonths(c);

            MDDatePair datePair = new MDDatePair(date1, date2);

            return smd.Get(datePair);
        }
Exemple #5
0
        public void UpdateGrid(SpreadMatrixData smd, SecurityEntry entry)
        {
            if (!smd.Values.Contains(entry))
                return;

            MDDatePair datePair = entry.GetDatePair();

            int dMonth1 = GetDeltaMonth(smd.MinYearMonth, datePair.GetMinDate());
            int dMonth2 = GetDeltaMonth(smd.MinYearMonth, datePair.GetMaxDate());
            int r = dMonth1 - 1;
            int c = dMonth2 - 1;

            SpreadMatrixDataCell cell = (SpreadMatrixDataCell)cellPosDictionary.GetValue(r, c);

            if(cell==null)
            {
                cell = new SpreadMatrixDataCell { Width = CellWidth, Height = CellHeight };

                cell.MouseDown += cell_MouseDown;

                Grid.SetRow(cell, r == c ? r + 1 : r);
                Grid.SetColumn(cell, c);

                cellPosDictionary.SetValue(r, c, cell);
                grid.Children.Add(cell);
            }

            cell.FillData(entry);
        }
Exemple #6
0
        public void FillGrid(SpreadMatrixData smd, IEnumerable<SecurityEntry> entries)
        {
            int dMonth = GetDeltaMonth(smd.MinYearMonth, smd.MaxYearMonth);

            if (grid.ColumnDefinitions.Count != dMonth)
                CreateGrid(smd);
            else
            {
                foreach (SecurityEntry entry in entries.Where(entry => !entry.IsDisposed))
                    UpdateGrid(smd, entry);
            }
        }
Exemple #7
0
        public void FillGrid(SpreadMatrixData smd, SecurityEntry entry)
        {
            int dMonth = GetDeltaMonth(smd.MinYearMonth, smd.MaxYearMonth);

            if (grid.ColumnDefinitions.Count != dMonth)
                CreateGrid(smd);
            else
                UpdateGrid(smd, entry);
        }
Exemple #8
0
        public void RequestSymbols(SpreadMatrixData spreadMatrixData)
        {
            QuickFix42.SecurityDefinitionRequest message = new QuickFix42.SecurityDefinitionRequest(new SecurityReqID(DateTime.Now.ToString()), new SecurityRequestType(SecurityRequestType.REQUEST_LIST_SECURITIES));
            message.setField(new Symbol(spreadMatrixData.Symbol));
            message.setField(new SecurityExchange(spreadMatrixData.Exchange));

            try
            {
                Session.sendToTarget(message, GetPriceSession());
            }
            catch (SessionNotFound exception)
            {
                AddText(exception.Message + Environment.NewLine);
                throw;
            }
        }