Esempio n. 1
0
        private void dgvList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            S_CandleItemData data = dgvList.Rows[e.RowIndex].Tag as S_CandleItemData;

            selCandleData = data;

            if (e.ColumnIndex == 1)
            {
                var pInfo = PatternUtil.GetTwoPatternInfo(selCandleData);
                pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                pInfo.Product      = selectedType;
                pInfo.Item         = selectedItem;
                var pList = twoPatterns.GetMatchPatterns(pInfo);

                dgv.Rows.Clear();
                if (pList.Count > 0)
                {
                    lbNoResult.Visible = false;
                }
                else
                {
                    lbNoResult.Visible = true;
                }

                foreach (var p in pList.OrderByDescending(t => t.CandlePatternType))
                {
                    int idx = dgv.Rows.Add(p.Item
                                           , getIntervalToString(p.TimeInterval)
                                           , p.EndDT.ToString("yy.MM.dd HH:mm")
                                           , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType)));

                    var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType));

                    if (type == CandlePatternTypeEnum.Up)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.Down)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.StrongUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkRed;
                    }
                    else if (type == CandlePatternTypeEnum.StrongDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkBlue;
                    }

                    dgv.Rows[idx].Tag = p;
                }
            }
            if (e.ColumnIndex == 2)
            {
                var pInfo = PatternUtil.GetThreePatternInfo(selCandleData);
                pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                pInfo.Product      = selectedType;
                pInfo.Item         = selectedItem;

                var pList = threePatterns.GetMatchPatterns(pInfo);

                dgv.Rows.Clear();
                if (pList.Count > 0)
                {
                    lbNoResult.Visible = false;
                }
                else
                {
                    lbNoResult.Visible = true;
                }

                foreach (var p in pList.OrderByDescending(t => t.CandlePatternType))
                {
                    int idx = dgv.Rows.Add(p.Item
                                           , getIntervalToString(p.TimeInterval)
                                           , p.EndDT.ToString("yy.MM.dd HH:mm")
                                           , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType)));

                    var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType));

                    if (type == CandlePatternTypeEnum.Up)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.Down)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.StrongUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkRed;
                    }
                    else if (type == CandlePatternTypeEnum.StrongDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkBlue;
                    }

                    dgv.Rows[idx].Tag = p;
                }
            }
            if (e.ColumnIndex == 3)
            {
                var pInfo = PatternUtil.GetFourPatternInfo(selCandleData);
                pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                pInfo.Product      = selectedType;
                pInfo.Item         = selectedItem;

                var pList = fourPatterns.GetMatchPatterns(pInfo);

                dgv.Rows.Clear();
                if (pList.Count > 0)
                {
                    lbNoResult.Visible = false;
                }
                else
                {
                    lbNoResult.Visible = true;
                }

                foreach (var p in pList.OrderByDescending(t => t.CandlePatternType))
                {
                    int idx = dgv.Rows.Add(p.Item
                                           , getIntervalToString(p.TimeInterval)
                                           , p.EndDT.ToString("yy.MM.dd HH:mm")
                                           , Convert.ToString((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType)));

                    var type = ((CandlePatternTypeEnum)Convert.ToInt32(p.CandlePatternType));

                    if (type == CandlePatternTypeEnum.Up)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Red;
                    }
                    else if (type == CandlePatternTypeEnum.Down)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.Blue;
                    }
                    else if (type == CandlePatternTypeEnum.StrongUp)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkRed;
                    }
                    else if (type == CandlePatternTypeEnum.StrongDown)
                    {
                        dgv.Rows[idx].Cells[3].Style.ForeColor = Color.DarkBlue;
                    }

                    dgv.Rows[idx].Tag = p;
                }
            }

            chart1.ClearChartLabel("1");
            chart1.ClearChartLabel("2");
            chart1.DisplayChartLabel(data, Color.Black, "1");
            chart1.DisplayView();
        }
Esempio n. 2
0
        void loadSiseDataFromDaemon()
        {
            if (cbxProduct.SelectedIndex < 3)
            {
                selectedItem = (cbxItem.SelectedItem as ItemData).Code;
            }
            else
            {
                selectedItem = cbxItem.SelectedItem.ToString().Substring(0, 6);
            }

            sourceDatas = loadData(selectedType, selectedItem, selectedTimeInterval, null, null);

            if (sourceDatas == null || sourceDatas.Count == 0)
            {
                return;
            }

            for (int i = 0; i < sourceDatas.Count; i++)
            {
                int pIdx = i - 1 < 0 ? 0 : i - 1;
                int nIdx = i + 1 == sourceDatas.Count ? i : i + 1;

                sourceDatas[i].PreCandleItem  = sourceDatas[pIdx];
                sourceDatas[i].NextCandleItem = sourceDatas[nIdx];
            }

            this.Invoke(new Action(() =>
            {
                dgvList.Rows.Clear();
                dgv.Rows.Clear();
                lbNoResult.Visible = false;

                for (int i = sourceDatas.Count - 1; i >= sourceDatas.Count - 50; i--)
                {
                    var data = sourceDatas[i];

                    string date = Convert.ToDateTime(data.DTime).ToString("yy.MM.dd HH:mm");

                    int index = dgvList.Rows.Add(date, "찾기2", "찾기3", "찾기4");

                    dgvList.Rows[index].Tag = data;

                    {
                        var pInfo          = PatternUtil.GetTwoPatternInfo(data);
                        pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                        pInfo.Product      = selectedType;
                        pInfo.Item         = selectedItem;
                        var pList          = twoPatterns.GetMatchPatterns(pInfo);
                        if (pList.Count == 0)
                        {
                            ((DataGridViewButtonCell)dgvList.Rows[index].Cells[1]).Value = "";
                        }
                    }

                    {
                        var pInfo          = PatternUtil.GetThreePatternInfo(data);
                        pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                        pInfo.Product      = selectedType;
                        pInfo.Item         = selectedItem;

                        var pList = threePatterns.GetMatchPatterns(pInfo);
                        if (pList.Count == 0)
                        {
                            ((DataGridViewButtonCell)dgvList.Rows[index].Cells[2]).Value = "";
                        }
                    }

                    {
                        var pInfo          = PatternUtil.GetFourPatternInfo(data);
                        pInfo.TimeInterval = Convert.ToInt32(selectedTimeInterval);
                        pInfo.Product      = selectedType;
                        pInfo.Item         = selectedItem;
                        var pList          = fourPatterns.GetMatchPatterns(pInfo);
                        if (pList.Count == 0)
                        {
                            ((DataGridViewButtonCell)dgvList.Rows[index].Cells[3]).Value = "";
                        }
                    }
                }

                dgvList.ClearSelection();

                Display();
            }));
        }