Beispiel #1
0
        public override void loadData()
        {
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            var sourceDatas = PPContext.Instance.ClientContext.GetCandleSourceDataOrderByAsc(
                itemCode
                , base.timeInterval);

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

            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);

            //var averageDatas = PPUtils.GetAverageDatas(itemCode, sourceDatas, 9);
            var averageDatas = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, 4);

            sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
            chart.LoadDataAndApply(itemCode, sourceDatas, averageDatas, base.timeInterval, 9);
            chart2.LoadDataAndApply(itemCode, averageDatas, averageDatas, base.timeInterval, 9);
        }
Beispiel #2
0
        private void dgv_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            string code = dgv.Rows[e.RowIndex].Cells[0].Value as string;
            string name = dgv.Rows[e.RowIndex].Cells[1].Value as string;

            tbSelectedCode2.Text = code;
            tbSelectedName2.Text = name;

            Task.Factory.StartNew(() => {
                var sourceDatas = XingContext.Instance.ClientContext.GetJongmokSiseData(code, "2", "0", "300");
                if (sourceDatas == null || sourceDatas.Count == 0)
                {
                    return;
                }
                int totalCnt = sourceDatas.Count;
                if (totalCnt > 300)
                {
                    sourceDatas.RemoveRange(0, totalCnt - 300);
                }
                var averageDatas = PPUtils.GetBalancedAverageDatas(code, sourceDatas, 4);
                sourceDatas      = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);

                chart.LoadDataAndApply(code, sourceDatas, averageDatas, TimeIntervalEnum.Day, 9);
                chart.SetYFormat("N0");
            });
        }
        public override void loadData()
        {
            if (isLoading)
            {
                return;
            }
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            string selectedType = this.SelectedType;

            if (string.IsNullOrEmpty(selectedType))
            {
                selectedType = SharedData.SelectedType;
            }

            isLoading = true;
            List <S_CandleItemData> sourceDatas = LoadData(itemCode, selectedType);

            isLoading = false;

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

            int averageCount = 9;

            if (timeInterval == TimeIntervalEnum.Minute_01 ||
                timeInterval == TimeIntervalEnum.Minute_05 ||
                timeInterval == TimeIntervalEnum.Minute_10 ||
                timeInterval == TimeIntervalEnum.Minute_30)
            {
                averageCount = 9;
            }

            var averageDatas1 = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, averageCount);

            //국내지수인 경우 시간갭이 크기 때문에.. 전일종가를 당일시가로 해야한다.
            var removeGapSourceDatas = PPUtils.RemoveGapPrice(sourceDatas);

            var averageDatas2 = PPUtils.GetBalancedAverageDatas(itemCode, removeGapSourceDatas, averageCount);

            chart1.LoadDataAndApply(itemCode, averageDatas1, averageDatas1, timeInterval, 5);

            chart2.LoadDataAndApply(itemCode, averageDatas2, averageDatas2, timeInterval, 5);
        }
Beispiel #4
0
        public override void loadData()
        {
            if (isLoading)
            {
                return;
            }
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            string selectedType = this.SelectedType;

            if (string.IsNullOrEmpty(selectedType))
            {
                selectedType = SharedData.SelectedType;
            }

            isLoading = true;
            List <S_CandleItemData> sourceDatas = LoadData(itemCode, selectedType);

            isLoading = false;

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

            var averageDatas  = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, 9);
            var averageDatas2 = PPUtils.GetMovingAverageDurationFlow(itemCode, averageDatas, isStrengthed, inflectionPoint);
            var sourceDatas2  = PPUtils.GetDurationSum(itemCode, averageDatas2, sourceDatas);

            chart.LoadDataAndApply(itemCode, sourceDatas2, base.timeInterval, 9);
            chart2.LoadDataAndApply(itemCode, averageDatas2, base.timeInterval, 9);

            chart2.SetYFormat("N0");
        }
Beispiel #5
0
        public override void loadData()
        {
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            TimeIntervalEnum timeInterval = TimeIntervalEnum.Minute_60;

            var sourceDatas = PPContext.Instance.ClientContext.GetCandleSourceDataOrderByAsc(
                base.SelectedItemData.Code
                , timeInterval);

            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);
            //국내지수인 경우 시간갭이 크기 때문에.. 전일종가를 당일시가로 해야한다.
            SetChangeOpenPrice(itemCode, sourceDatas);

            if (sourceDatas != null && sourceDatas.Count > 0)
            {
                var averageDatas1 = PPUtils.GetAverageDatas(itemCode, sourceDatas, 9);
                var averageDatas2 = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, 9);
                var averageDatas3 = PPUtils.GetAccumulatedAverageDatas(itemCode, sourceDatas, 9);

                sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas1[0].DTime);

                qMin1.LoadDataAndApply(itemCode, sourceDatas, timeInterval, 3);
                qMin2.LoadDataAndApply(itemCode, averageDatas1, timeInterval, 3);
                qMin3.LoadDataAndApply(itemCode, averageDatas2, timeInterval, 3);
                qMin4.LoadDataAndApply(itemCode, averageDatas3, timeInterval, 3);
            }
        }
Beispiel #6
0
        public override void loadData()
        {
            if (isLoading)
            {
                return;
            }
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            string selectedType = this.SelectedType;

            if (string.IsNullOrEmpty(selectedType))
            {
                selectedType = SharedData.SelectedType;
            }

            isLoading = true;
            List <S_CandleItemData> sourceDatas = LoadData(itemCode, selectedType);

            isLoading = false;

            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 - 1 ? sourceDatas.Count - 1 : i + 1;

                sourceDatas[i].PreCandleItem  = sourceDatas[pIdx];
                sourceDatas[i].NextCandleItem = sourceDatas[nIdx];
            }
            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);
            //국내지수인 경우 시간갭이 크기 때문에.. 전일종가를 당일시가로 해야한다.
            //var removeGapSourceDatas = PPUtils.RemoveGapPrice(sourceDatas);

            int averageCount = 9;

            if (timeInterval == TimeIntervalEnum.Minute_01 ||
                timeInterval == TimeIntervalEnum.Minute_05 ||
                timeInterval == TimeIntervalEnum.Minute_10 ||
                timeInterval == TimeIntervalEnum.Minute_30)
            {
                averageCount = 9;
            }

            var averageDatas = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, averageCount);

            sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
            chart.LoadDataAndApply(itemCode, sourceDatas, averageDatas, base.timeInterval, 5);
        }
Beispiel #7
0
        public override void loadData()
        {
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            var sourceDatas = PPContext.Instance.ClientContext.GetCandleSourceDataOrderByAsc(
                itemCode
                , base.timeInterval);

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

            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);

            string chartTitle = "양자::";

            if (OriginSourceType == OriginSourceTypeEnum.Normal)
            {
                chartTitle += "Orgin::";
            }
            if (OriginSourceType == OriginSourceTypeEnum.Whim)
            {
                sourceDatas = PPUtils.GetRecreateWhimDatas(itemCode, sourceDatas, true);
                chartTitle += "Whim::";
            }
            if (OriginSourceType == OriginSourceTypeEnum.Second)
            {
                sourceDatas = PPUtils.GetRecreateSecondDatas(itemCode, sourceDatas, 5, false);
                chartTitle += "Second::";
            }
            if (OriginSourceType == OriginSourceTypeEnum.SecondQutum)
            {
                sourceDatas = PPUtils.GetRecreateSecondDatas(itemCode, sourceDatas, 5, true);
                chart1.SetCandleColor(0, "Blue", "Red");
                chart2.SetCandleColor(0, "Blue", "Red");
                chart3.SetCandleColor(0, "Blue", "Red");
                chart4.SetCandleColor(0, "Blue", "Red");

                chartTitle += "SQutum::";
            }

            if (true || AverageType == AverageTypeEnum.Normal)
            {
                var averageDatas = PPUtils.GetAverageDatas(itemCode, sourceDatas, 5);
                sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
                chart1.LoadDataAndApply(itemCode, sourceDatas, averageDatas, base.timeInterval, 5);
                chart2.LoadDataAndApply(itemCode, averageDatas, averageDatas, base.timeInterval, 5);
                chart1.Title = chartTitle + "Normal";
                chart2.Title = chartTitle + "Normal";
            }
            if (true || AverageType == AverageTypeEnum.Balanced)
            {
                var averageDatas = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, 4);
                sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
                chart3.LoadDataAndApply(itemCode, sourceDatas, averageDatas, base.timeInterval, 5);
                chart3.Title = chartTitle + "Balanced";
            }
            if (true || AverageType == AverageTypeEnum.Accumulated)
            {
                var averageDatas = PPUtils.GetAccumulatedAverageDatas(itemCode, sourceDatas, 9);
                sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
                chart4.LoadDataAndApply(itemCode, sourceDatas, averageDatas, base.timeInterval, 5);
                chart4.Title = chartTitle + "Accumulated";
            }
        }
Beispiel #8
0
        private void dgvList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            string code = dgvList.Rows[e.RowIndex].Tag as string;
            string name = dgvList.Rows[e.RowIndex].Cells[0].Value as string;

            tbSelectedCode.Text = code;
            tbSelectedName.Text = name;

            Task.Factory.StartNew(() => {
                var sourceDatas = XingContext.Instance.ClientContext.GetUpJongSiseData(code, "2", "0", "100");
                if (sourceDatas == null || sourceDatas.Count == 0)
                {
                    return;
                }
                int totalCnt = sourceDatas.Count;
                if (totalCnt > 100)
                {
                    sourceDatas.RemoveRange(0, totalCnt - 100);
                }
                var averageDatas = PPUtils.GetBalancedAverageDatas(code, sourceDatas, 4);
                sourceDatas      = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
                chart.LoadDataAndApply(code, sourceDatas, averageDatas, TimeIntervalEnum.Day, 9);
                chart.SetYFormat("N0");
            });

            dgv.Rows.Clear();
            Task.Factory.StartNew(() => {
                var sourceDatas = XingContext.Instance.ClientContext.GetUpJongJongMokData(code);
                if (sourceDatas == null || sourceDatas.Count == 0)
                {
                    return;
                }

                foreach (var item in sourceDatas)
                {
                    this.Invoke(new Action(() => {
                        int rIdx = dgv.Rows.Add(item.종목코드
                                                , item.종목명
                                                , item.시가
                                                , item.고가
                                                , item.저가
                                                , item.현재가
                                                , item.전일대비구분
                                                , item.등락율 + "%"
                                                , item.전일대비
                                                , item.외인순매수
                                                , item.기관순매수
                                                , item.거래대금
                                                , item.거래증가율
                                                , item.시가총액
                                                );

                        // 1:상한 2:상승 3:보합 4:하한 5:하락
                        if (item.전일대비구분 == "1")
                        {
                            dgv.Rows[rIdx].Cells[6].Value                   = "▲";
                            dgv.Rows[rIdx].Cells[6].Style.ForeColor         =
                                dgv.Rows[rIdx].Cells[7].Style.ForeColor     =
                                    dgv.Rows[rIdx].Cells[8].Style.ForeColor = Color.Red;
                        }
                        else if (item.전일대비구분 == "2")
                        {
                            dgv.Rows[rIdx].Cells[6].Value                   = "△";
                            dgv.Rows[rIdx].Cells[6].Style.ForeColor         =
                                dgv.Rows[rIdx].Cells[7].Style.ForeColor     =
                                    dgv.Rows[rIdx].Cells[8].Style.ForeColor = Color.Red;
                        }
                        else if (item.전일대비구분 == "3")
                        {
                            dgv.Rows[rIdx].Cells[6].Value = "◇";
                        }
                        else if (item.전일대비구분 == "5")
                        {
                            dgv.Rows[rIdx].Cells[6].Value                   = "▽";
                            dgv.Rows[rIdx].Cells[6].Style.ForeColor         =
                                dgv.Rows[rIdx].Cells[7].Style.ForeColor     =
                                    dgv.Rows[rIdx].Cells[8].Style.ForeColor = Color.Blue;
                        }
                        else if (item.전일대비구분 == "4")
                        {
                            dgv.Rows[rIdx].Cells[6].Value                   = "▼";
                            dgv.Rows[rIdx].Cells[6].Style.ForeColor         =
                                dgv.Rows[rIdx].Cells[7].Style.ForeColor     =
                                    dgv.Rows[rIdx].Cells[8].Style.ForeColor = Color.Blue;
                        }

                        if (item.거래증가율 > 0)
                        {
                            dgv.Rows[rIdx].Cells[11].Style.ForeColor
                                = dgv.Rows[rIdx].Cells[12].Style.ForeColor = Color.Red;
                        }
                        else if (item.거래증가율 < 0)
                        {
                            dgv.Rows[rIdx].Cells[11].Style.ForeColor
                                = dgv.Rows[rIdx].Cells[12].Style.ForeColor = Color.Blue;
                        }
                    }));
                }
            });
        }
Beispiel #9
0
        private void btnSearchJongmok_Click(object sender, EventArgs e)
        {
            if (!isRunningJongmok)
            {
                isRunningJongmok = true;
            }
            else
            {
                isRunningJongmok = false;
                return;
            }

            Task.Factory.StartNew(() =>
            {
                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (!isRunningJongmok)
                    {
                        return;
                    }
                    string code = row.Cells[0].Value as string;

                    Task.Factory.StartNew(() =>
                    {
                        var sourceDatas = XingContext.Instance.ClientContext.GetJongmokSiseData(code, "2", "0", "20");
                        if (sourceDatas == null || sourceDatas.Count == 0)
                        {
                            return;
                        }
                        var averageDatas = PPUtils.GetBalancedAverageDatas(code, sourceDatas, 4);

                        List <SmartCandleData> smartDataList   = new List <SmartCandleData>();
                        List <WisdomCandleData> wisdomDataList = new List <WisdomCandleData>();
                        SmartCandleData preSmartData           = null;
                        WisdomCandleData preWisdomData         = null;
                        for (int i = 0; i < averageDatas.Count; i++)
                        {
                            var cData = averageDatas[i];
                            SmartCandleData smartData = new SmartCandleData(cData.ItemCode, cData.OpenPrice, cData.HighPrice, cData.LowPrice, cData.ClosePrice, cData.Volume, cData.DTime, preSmartData);
                            smartDataList.Add(smartData);
                            preSmartData = smartData;
                            WisdomCandleData wisdomData = new WisdomCandleData(cData.ItemCode, cData.OpenPrice, cData.HighPrice, cData.LowPrice, cData.ClosePrice, cData.Volume, cData.DTime, preWisdomData);
                            wisdomDataList.Add(wisdomData);
                            preWisdomData = wisdomData;
                        }

                        var sR0 = getSmartLine(0, smartDataList);
                        var sR1 = getSmartLine(1, smartDataList);
                        var sR2 = getSmartLine(2, smartDataList);
                        var sR3 = getSmartLine(3, smartDataList);

                        var swR4 = getSmartWisdomLine(4, smartDataList, wisdomDataList);
                        var swR3 = getSmartWisdomLine(3, smartDataList, wisdomDataList);
                        var swR2 = getSmartWisdomLine(2, smartDataList, wisdomDataList);
                        var swR1 = getSmartWisdomLine(1, smartDataList, wisdomDataList);
                        var swR0 = getSmartWisdomLine(0, smartDataList, wisdomDataList);

                        //this.Invoke(new Action(() => {
                        row.Cells["IS3"].Value           = sR3.Item1;
                        row.Cells["IS3"].Style.ForeColor = sR3.Item2;
                        row.Cells["IS2"].Value           = sR2.Item1;
                        row.Cells["IS2"].Style.ForeColor = sR2.Item2;
                        row.Cells["IS1"].Value           = sR1.Item1;
                        row.Cells["IS1"].Style.ForeColor = sR1.Item2;
                        row.Cells["IS0"].Value           = sR0.Item1;
                        row.Cells["IS0"].Style.ForeColor = sR0.Item2;

                        row.Cells["ISW4"].Value           = swR4.Item1;
                        row.Cells["ISW4"].Style.ForeColor = swR4.Item2;
                        row.Cells["ISW3"].Value           = swR3.Item1;
                        row.Cells["ISW3"].Style.ForeColor = swR3.Item2;
                        row.Cells["ISW2"].Value           = swR2.Item1;
                        row.Cells["ISW2"].Style.ForeColor = swR2.Item2;
                        row.Cells["ISW1"].Value           = swR1.Item1;
                        row.Cells["ISW1"].Style.ForeColor = swR1.Item2;
                        row.Cells["ISW0"].Value           = swR0.Item1;
                        row.Cells["ISW0"].Style.ForeColor = swR0.Item2;
                    });

                    System.Threading.Thread.Sleep(2000);
                }
            });
        }
Beispiel #10
0
        public override void loadData()
        {
            if (isLoading)
            {
                return;
            }
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            string selectedType = this.SelectedType;

            if (string.IsNullOrEmpty(selectedType))
            {
                selectedType = SharedData.SelectedType;
            }

            isLoading = true;
            List <S_CandleItemData> sourceDatas = LoadData(itemCode, selectedType);

            isLoading = false;

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

            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);

            int averageCount = 4;

            if (timeInterval == TimeIntervalEnum.Minute_01 ||
                timeInterval == TimeIntervalEnum.Minute_05 ||
                timeInterval == TimeIntervalEnum.Minute_10 ||
                timeInterval == TimeIntervalEnum.Minute_30)
            {
                averageCount = 8;
            }

            //var averageDatas = PPUtils.GetAverageDatas(itemCode, sourceDatas, averageCount, false);
            var averageDatas = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, averageCount);

            sourceDatas = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
            chart1.LoadDataAndApply(itemCode, sourceDatas, averageDatas, base.timeInterval, averageCount);

            //var removeGapSourceDatas = PPUtils.RemoveGapPrice(sourceDatas);
            //var averageDatas2 = PPUtils.GetBalancedAverageDatas(itemCode, removeGapSourceDatas, 4);

            averageDatas.RemoveAt(0);
            averageDatas.RemoveAt(0);
            averageDatas.RemoveAt(0);
            averageDatas.RemoveAt(0);
            chart2.LoadDataAndApply(itemCode, averageDatas, averageDatas, timeInterval, averageCount);
        }
        public override void loadData()
        {
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            var sourceDatas = PPContext.Instance.ClientContext.GetCandleSourceDataOrderByAsc(
                itemCode
                , base.timeInterval);

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

            //표시할 갯수를 맞춘다.
            //RemoveSourceData(sourceDatas);

            bool isUseWhim = false;

            if (isUseWhim)
            {
                double rate = 0.0;
                if (timeInterval == TimeIntervalEnum.Week)
                {
                    rate = 2.5;
                }
                if (timeInterval == TimeIntervalEnum.Day)
                {
                    rate = 1.0;
                }
                if (timeInterval == TimeIntervalEnum.Hour_03)
                {
                    rate = 0.7;
                }
                if (timeInterval == TimeIntervalEnum.Hour_02)
                {
                    rate = 0.5;
                }
                if (timeInterval == TimeIntervalEnum.Hour_01)
                {
                    rate = 0.3;
                }
                sourceDatas = PPUtils.GetRecreateWhimDatas(itemCode, sourceDatas, true, rate, null);
            }


            List <S_CandleItemData> averageDatas = null;

            if (averageType == "일반")
            {
                averageDatas = PPUtils.GetAverageDatas(itemCode, sourceDatas, 9);
            }
            else if (averageType == "밸런스")
            {
                averageDatas = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, 9);
            }
            else //if (averageType == "가중")
            {
                averageDatas = PPUtils.GetAccumulatedAverageDatas(itemCode, sourceDatas, 9);
            }

            var averageDatas2 = PPUtils.GetMovingAverageDurationFlow(itemCode, averageDatas, isStrengthed, inflectionPoint);
            var sourceDatas2  = PPUtils.GetDurationSum(itemCode, averageDatas2, sourceDatas);

            chart.LoadDataAndApply(itemCode, sourceDatas2, base.timeInterval, 9);
            chart2.LoadDataAndApply(itemCode, averageDatas2, base.timeInterval, 9);

            chart2.SetYFormat("N0");
        }
Beispiel #12
0
        public override void loadData()
        {
            if (isLoading)
            {
                return;
            }
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            string selectedType = this.SelectedType;

            if (string.IsNullOrEmpty(selectedType))
            {
                selectedType = SharedData.SelectedType;
            }

            chart.SelectedPType = selectedType;

            isLoading = true;
            List <S_CandleItemData> sourceDatas = LoadData(itemCode, selectedType);

            isLoading = false;

            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 - 1 ? sourceDatas.Count - 1 : i + 1;

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

            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);

            CreateVirtualData(sourceDatas);

            int averageCount = 9;

            if (timeInterval == TimeIntervalEnum.Minute_01 ||
                timeInterval == TimeIntervalEnum.Minute_05 ||
                timeInterval == TimeIntervalEnum.Minute_10 ||
                timeInterval == TimeIntervalEnum.Minute_15 ||
                timeInterval == TimeIntervalEnum.Minute_30)
            {
                averageCount = 9;
            }

            int averageBCount = 4;

            if (timeInterval == TimeIntervalEnum.Minute_01 ||
                timeInterval == TimeIntervalEnum.Minute_05 ||
                timeInterval == TimeIntervalEnum.Minute_10 ||
                timeInterval == TimeIntervalEnum.Minute_15 ||
                timeInterval == TimeIntervalEnum.Minute_30)
            {
                averageBCount = 8;
            }

            var averageDatas  = PPUtils.GetAverageDatas(itemCode, sourceDatas, averageCount, false);
            var averageBDatas = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, averageBCount, false);

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

                averageDatas[i].PreCandleItem  = averageDatas[pIdx];
                averageDatas[i].NextCandleItem = averageDatas[nIdx];
            }
            for (int i = 0; i < averageBDatas.Count; i++)
            {
                int pIdx = i - 1 < 0 ? 0 : i - 1;
                int nIdx = i + 1 > averageBDatas.Count - 1 ? averageBDatas.Count - 1 : i + 1;

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

            sourceDatas   = PPUtils.GetCutDatas(sourceDatas, averageDatas[0].DTime);
            averageBDatas = PPUtils.GetCutDatas(averageBDatas, averageDatas[0].DTime);

            chart.LoadDataAndApply(itemCode, sourceDatas, averageDatas, averageBDatas, base.timeInterval, 5);
        }
Beispiel #13
0
        public override void loadData()
        {
            if (base.SelectedItemData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(base.SelectedItemData.Code))
            {
                return;
            }

            string itemCode = base.SelectedItemData.Code;

            var sourceDatas = PPContext.Instance.ClientContext.GetCandleSourceDataOrderByAsc(
                itemCode
                , base.timeInterval);

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

            //표시할 갯수를 맞춘다.
            RemoveSourceData(sourceDatas);
            //국내지수인 경우 시간갭이 크기 때문에.. 전일종가를 당일시가로 해야한다.

            var quantumDatas      = PPUtils.GetANodeDatas(sourceDatas);
            var plusQuantumDatas  = quantumDatas.plusList;
            var minusQuantumDatas = quantumDatas.minusList;

            //SetChangeOpenPrice(itemCode, plusQuantumDatas);
            //SetChangeOpenPrice(itemCode, minusQuantumDatas);

            string chartTitle = "ANode::";

            if (OriginSourceType == OriginSourceTypeEnum.Normal)
            {
                chartTitle += "Orgin::";
            }
            if (OriginSourceType == OriginSourceTypeEnum.Whim)
            {
                plusQuantumDatas  = PPUtils.GetRecreateWhimDatas(itemCode, plusQuantumDatas, true);
                minusQuantumDatas = PPUtils.GetRecreateWhimDatas(itemCode, minusQuantumDatas, true);
                chartTitle       += "Whim::";
            }
            if (OriginSourceType == OriginSourceTypeEnum.Second)
            {
                plusQuantumDatas  = PPUtils.GetRecreateSecondDatas(itemCode, plusQuantumDatas, 5, false);
                minusQuantumDatas = PPUtils.GetRecreateSecondDatas(itemCode, minusQuantumDatas, 5, false);
                chartTitle       += "Second::";
            }
            if (OriginSourceType == OriginSourceTypeEnum.SecondQutum)
            {
                plusQuantumDatas  = PPUtils.GetRecreateSecondDatas(itemCode, plusQuantumDatas, 5, true);
                minusQuantumDatas = PPUtils.GetRecreateSecondDatas(itemCode, minusQuantumDatas, 5, true);
                chartTitle       += "SQutum::";
            }

            if (true || AverageType == AverageTypeEnum.Normal)
            {
                var averageDatas  = PPUtils.GetAverageDatas(itemCode, sourceDatas, 5);
                var pAverageDatas = PPUtils.GetAverageDatas(itemCode, plusQuantumDatas, 5);
                var mAverageDatas = PPUtils.GetAverageDatas(itemCode, minusQuantumDatas, 5);

                sourceDatas = PPUtils.GetCutDatas(sourceDatas, pAverageDatas[0].DTime);
                chart1.LoadDataAndApply(itemCode, sourceDatas, pAverageDatas, mAverageDatas, base.timeInterval, 5);
                chart2.LoadDataAndApply(itemCode, averageDatas, pAverageDatas, mAverageDatas, base.timeInterval, 5);
                chart1.Title = chartTitle + "Normal";
                chart2.Title = chartTitle + "Normal";
            }
            if (true || AverageType == AverageTypeEnum.Balanced)
            {
                var averageDatas  = PPUtils.GetBalancedAverageDatas(itemCode, sourceDatas, 4);
                var pAverageDatas = PPUtils.GetBalancedAverageDatas(itemCode, plusQuantumDatas, 4);
                var mAverageDatas = PPUtils.GetBalancedAverageDatas(itemCode, minusQuantumDatas, 4);

                sourceDatas = PPUtils.GetCutDatas(sourceDatas, pAverageDatas[0].DTime);
                chart3.LoadDataAndApply(itemCode, sourceDatas, pAverageDatas, mAverageDatas, base.timeInterval, 5);
                chart3.Title = chartTitle + "Balanced";
            }
            if (true || AverageType == AverageTypeEnum.Accumulated)
            {
                var averageDatas  = PPUtils.GetAccumulatedAverageDatas(itemCode, sourceDatas, 9);
                var pAverageDatas = PPUtils.GetAccumulatedAverageDatas(itemCode, plusQuantumDatas, 9);
                var mAverageDatas = PPUtils.GetAccumulatedAverageDatas(itemCode, minusQuantumDatas, 9);

                sourceDatas = PPUtils.GetCutDatas(sourceDatas, pAverageDatas[0].DTime);
                chart4.LoadDataAndApply(itemCode, sourceDatas, pAverageDatas, mAverageDatas, base.timeInterval, 5);
                chart4.Title = chartTitle + "Accumulated";
            }
        }