From 8908ed4264cf2114028524490b407d840ad72ebe Mon Sep 17 00:00:00 2001 From: jwlee Date: Wed, 10 May 2023 16:33:58 +0900 Subject: [PATCH 01/25] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HunterSubForm/TestBoardForm.Designer.cs | 36 +++- Million Hunter/HunterSubForm/TestBoardForm.cs | 159 +++++++++++++----- 2 files changed, 150 insertions(+), 45 deletions(-) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs index fe3b486..d9cc598 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs @@ -38,11 +38,15 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_Reset = new DevExpress.XtraEditors.SimpleButton(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.simpleButton_찬 = new DevExpress.XtraEditors.SimpleButton(); + this.checkEdit_구름떼상한선하락시판매 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 = new DevExpress.XtraEditors.CheckEdit(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).BeginInit(); this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).BeginInit(); this.SuspendLayout(); // // simpleButton_FullInsertCandle @@ -68,6 +72,8 @@ namespace Million_Hunter.HunterSubForm // // groupBox2 // + this.groupBox2.Controls.Add(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매); + this.groupBox2.Controls.Add(this.checkEdit_구름떼상한선하락시판매); this.groupBox2.Controls.Add(this.checkEdit_구매이전봉볼린저40_1이하); this.groupBox2.Controls.Add(this.checkEdit_이전봉40_2볼린저이하); this.groupBox2.Location = new System.Drawing.Point(12, 90); @@ -103,14 +109,15 @@ namespace Million_Hunter.HunterSubForm this.groupBox3.Size = new System.Drawing.Size(154, 63); this.groupBox3.TabIndex = 4; this.groupBox3.TabStop = false; - this.groupBox3.Text = "데이터 채우기"; + this.groupBox3.Text = "관리"; // // simpleButton_Reset // - this.simpleButton_Reset.Location = new System.Drawing.Point(0, 0); + this.simpleButton_Reset.Location = new System.Drawing.Point(6, 21); this.simpleButton_Reset.Name = "simpleButton_Reset"; - this.simpleButton_Reset.Size = new System.Drawing.Size(75, 23); + this.simpleButton_Reset.Size = new System.Drawing.Size(109, 32); this.simpleButton_Reset.TabIndex = 0; + this.simpleButton_Reset.Text = "Reset"; // // progressBar1 // @@ -129,6 +136,24 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_찬.Text = "찬테스트"; this.simpleButton_찬.Click += new System.EventHandler(this.simpleButton_찬_Click); // + // checkEdit_구름떼상한선하락시판매 + // + this.checkEdit_구름떼상한선하락시판매.Location = new System.Drawing.Point(379, 22); + this.checkEdit_구름떼상한선하락시판매.Name = "checkEdit_구름떼상한선하락시판매"; + this.checkEdit_구름떼상한선하락시판매.Properties.Caption = "구름떼 상한선 하락시 판매 (1%)"; + this.checkEdit_구름떼상한선하락시판매.Size = new System.Drawing.Size(179, 19); + this.checkEdit_구름떼상한선하락시판매.TabIndex = 2; + this.checkEdit_구름떼상한선하락시판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 + // + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Location = new System.Drawing.Point(19, 47); + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Name = "checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매"; + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties.Caption = "구매 전봉 기준 가중이동평균 5봉이 40봉 크로스 이후 구매"; + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Size = new System.Drawing.Size(310, 19); + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.TabIndex = 3; + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // // TestBoardForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); @@ -136,6 +161,7 @@ namespace Million_Hunter.HunterSubForm this.ClientSize = new System.Drawing.Size(853, 297); this.Controls.Add(this.progressBar1); this.Controls.Add(this.simpleButton_찬); + this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "TestBoardForm"; @@ -145,6 +171,8 @@ namespace Million_Hunter.HunterSubForm ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit(); this.groupBox3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).EndInit(); this.ResumeLayout(false); } @@ -161,5 +189,7 @@ namespace Million_Hunter.HunterSubForm private System.Windows.Forms.GroupBox groupBox3; private DevExpress.XtraEditors.SimpleButton simpleButton_Reset; private DevExpress.XtraEditors.CheckEdit checkEdit_구매이전봉볼린저40_1이하; + private DevExpress.XtraEditors.CheckEdit checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매; + private DevExpress.XtraEditors.CheckEdit checkEdit_구름떼상한선하락시판매; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index 329e132..85157c7 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -195,28 +195,9 @@ namespace Million_Hunter.HunterSubForm var 구매이전봉 = startDate; //차트 Date Time 설정하기 - var StartDateInterval = 1; + var StartDateInterval = -1; - switch (MCandleTimeType) - { - case CommonProperty.MCandleTimeType.H1: - 구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval, 0, 0); - break; - case CommonProperty.MCandleTimeType.H4: - 구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval * 4, 0, 0); - break; - case CommonProperty.MCandleTimeType.M1: - break; - case CommonProperty.MCandleTimeType.M10: - case CommonProperty.MCandleTimeType.M15: - case CommonProperty.MCandleTimeType.M3: - case CommonProperty.MCandleTimeType.M30: - case CommonProperty.MCandleTimeType.M5: - break; - case CommonProperty.MCandleTimeType.D1: - 구매이전봉 = Convert.ToDateTime(endDate.ToString("yyyy-MM-dd")) - new TimeSpan(StartDateInterval, 0, 0, 0); - break; - } + 구매이전봉 = changeDatetimeFormat(구매이전봉, StartDateInterval); var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉); // 시간대 캔들이 없으면 결과에서 제외 @@ -264,28 +245,9 @@ namespace Million_Hunter.HunterSubForm var 구매이전봉 = startDate; //차트 Date Time 설정하기 - var StartDateInterval = 1; + var StartDateInterval = -1; - switch (MCandleTimeType) - { - case CommonProperty.MCandleTimeType.H1: - 구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval, 0, 0); - break; - case CommonProperty.MCandleTimeType.H4: - 구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval * 4, 0, 0); - break; - case CommonProperty.MCandleTimeType.M1: - break; - case CommonProperty.MCandleTimeType.M10: - case CommonProperty.MCandleTimeType.M15: - case CommonProperty.MCandleTimeType.M3: - case CommonProperty.MCandleTimeType.M30: - case CommonProperty.MCandleTimeType.M5: - break; - case CommonProperty.MCandleTimeType.D1: - 구매이전봉 = Convert.ToDateTime(endDate.ToString("yyyy-MM-dd")) - new TimeSpan(StartDateInterval, 0, 0, 0); - break; - } + 구매이전봉 = changeDatetimeFormat(구매이전봉, StartDateInterval); var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉); // 시간대 캔들이 없으면 결과에서 제외 @@ -318,12 +280,125 @@ namespace Million_Hunter.HunterSubForm } } } + + if (checkEdit_구름떼상한선하락시판매.Checked) + { + // 평균 승률 계산하기 + double winRate = 0; + // 평균 수익률 계산하기 + double profitRate = 0; + + var count__ = 0; + var count_2 = 0; + var count_3 = 0; + + foreach (var analysisData in parentForm._analysisDatas) + { + if (!analysisData.Inclusion) continue; + + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var endDate = changeDatetimeFormat(analysisData.EndDate, 0); + + var candleData = analysisData.CandleDatas.First().Value.Find(item => item.DateTime >= startDate && + item.IndicatorDic["Ich2695226"]?.value != null && item.IndicatorDic["Ich2695226"]?.value > item.LowValue); + + + if(candleData != null) + { + var endResut = changeDatetimeFormat(candleData.DateTime, 0); + var ichValue = ((IchimokData)candleData.IndicatorDic["Ich2695226"]).GetOverValue(); + + // 판매 시간 이전에 하락 시 다시 계산 + if (endDate > endResut) + { + // 수익이면 + if (analysisData.BuyValue > ichValue) + { + winRate++; + count__++; + } + + //var profitRate1 = profitRate1 + (-100 + (Convert.ToDouble(ichValue) / Convert.ToDouble(analysisData.BuyValue) * 100)); + profitRate += -1 * ((analysisData.BuyValue - ichValue) / analysisData.BuyValue * 100); + + } + else + { + if (analysisData.WinFlag) + { + winRate++; + count_2++; + } + + profitRate = profitRate + analysisData.EarningRate; + } + } + else + { + if(startDate != endDate) + { + + } + + if (analysisData.WinFlag) + { + count_2++; + winRate++; + } + else { } + + profitRate = profitRate + analysisData.EarningRate; + } + } + + var allCount = parentForm._analysisDatas.Count(item => item.Inclusion == true); + + winRate = winRate * 100 / allCount; + + MessageBox.Show(string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}", + double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), allCount.ToString()) ); + } parentForm.treeList_ResultData.RefreshDataSource(); parentForm.CalcurateProfitAndWinRate(); } + + /// + /// 시간/분/일 등의 Datetime 과 비교하기 위한 Format String 변경 함수 + /// + /// + /// + /// + public DateTime changeDatetimeFormat(DateTime dateTime, int StartDateInterval) + { + var _dateTime = dateTime; + + switch (MCandleTimeType) + { + case CommonProperty.MCandleTimeType.H1: + _dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd HH:00")) + new TimeSpan(0, StartDateInterval, 0, 0); + break; + case CommonProperty.MCandleTimeType.H4: + _dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd HH:00")) + new TimeSpan(0, StartDateInterval * 4, 0, 0); + break; + case CommonProperty.MCandleTimeType.M1: + break; + case CommonProperty.MCandleTimeType.M10: + case CommonProperty.MCandleTimeType.M15: + case CommonProperty.MCandleTimeType.M3: + case CommonProperty.MCandleTimeType.M30: + case CommonProperty.MCandleTimeType.M5: + break; + case CommonProperty.MCandleTimeType.D1: + _dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd")) + new TimeSpan(StartDateInterval, 0, 0, 0); + break; + } + + return _dateTime; + } + /// /// 이전봉40_2볼린저이하 /// From 1fb5d2aeb437372426950869ae719212e56f8ca0 Mon Sep 17 00:00:00 2001 From: jwlee Date: Mon, 15 May 2023 13:03:33 +0900 Subject: [PATCH 02/25] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=8F=BC?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResultViewerForm.Designer.cs | 21 +++- .../HunterSubForm/ResultViewerForm.cs | 40 +++++++- .../HunterSubForm/TestBoardForm.Designer.cs | 68 +++++++++---- Million Hunter/HunterSubForm/TestBoardForm.cs | 98 ++++++++++++++++++- Million/Data/AnalysisData.cs | 4 + 5 files changed, 199 insertions(+), 32 deletions(-) diff --git a/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs b/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs index d55fc39..fb4266e 100644 --- a/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs +++ b/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs @@ -76,6 +76,7 @@ namespace Million.HunterSubForm this.simpleButton_resetData = new DevExpress.XtraEditors.SimpleButton(); this.simpleButton_LoadAnalysisResultData = new DevExpress.XtraEditors.SimpleButton(); this.simpleButton_SavaAnalysisData = new DevExpress.XtraEditors.SimpleButton(); + this.treeListColumn_PurchasedCount = new DevExpress.XtraTreeList.Columns.TreeListColumn(); ((System.ComponentModel.ISupportInitialize)(this.panelControl_IndicatorCondition)).BeginInit(); this.panelControl_IndicatorCondition.SuspendLayout(); this.groupBox_.SuspendLayout(); @@ -388,17 +389,18 @@ namespace Million.HunterSubForm this.treeListColumn_SellValue, this.treeListColumn_WinFlag, this.treeListColumn_EarningRate, + this.treeListColumn_PurchasedCount, this.treeListColumn_AnalysisDescrption, this.treeListColumn_OriginalData}); this.treeList_ResultData.Cursor = System.Windows.Forms.Cursors.Default; this.treeList_ResultData.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeList_ResultData.Location = new System.Drawing.Point(0, 275); + this.treeList_ResultData.Location = new System.Drawing.Point(0, 301); this.treeList_ResultData.Name = "treeList_ResultData"; this.treeList_ResultData.OptionsFilter.ShowAllValuesInFilterPopup = true; this.treeList_ResultData.OptionsSelection.MultiSelect = true; this.treeList_ResultData.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { this.repositoryItemCheckEdit_Inclustion}); - this.treeList_ResultData.Size = new System.Drawing.Size(1271, 636); + this.treeList_ResultData.Size = new System.Drawing.Size(1271, 610); this.treeList_ResultData.TabIndex = 5; this.treeList_ResultData.KeyUp += new System.Windows.Forms.KeyEventHandler(this.treeList_ResultData_KeyUp); this.treeList_ResultData.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeList_ResultData_MouseDoubleClick); @@ -600,7 +602,7 @@ namespace Million.HunterSubForm this.treeListColumn_AnalysisDescrption.FieldName = "Description"; this.treeListColumn_AnalysisDescrption.Name = "treeListColumn_AnalysisDescrption"; this.treeListColumn_AnalysisDescrption.Visible = true; - this.treeListColumn_AnalysisDescrption.VisibleIndex = 11; + this.treeListColumn_AnalysisDescrption.VisibleIndex = 12; this.treeListColumn_AnalysisDescrption.Width = 375; // // treeListColumn_OriginalData @@ -622,7 +624,7 @@ namespace Million.HunterSubForm this.panelControl1.Dock = System.Windows.Forms.DockStyle.Top; this.panelControl1.Location = new System.Drawing.Point(0, 231); this.panelControl1.Name = "panelControl1"; - this.panelControl1.Size = new System.Drawing.Size(1271, 44); + this.panelControl1.Size = new System.Drawing.Size(1271, 70); this.panelControl1.TabIndex = 4; // // simpleButton_TestBoard @@ -639,7 +641,7 @@ namespace Million.HunterSubForm // labelControl_WinRateProfitRate // this.labelControl_WinRateProfitRate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelControl_WinRateProfitRate.Location = new System.Drawing.Point(369, 15); + this.labelControl_WinRateProfitRate.Location = new System.Drawing.Point(652, 50); this.labelControl_WinRateProfitRate.Name = "labelControl_WinRateProfitRate"; this.labelControl_WinRateProfitRate.Size = new System.Drawing.Size(19, 14); this.labelControl_WinRateProfitRate.TabIndex = 2; @@ -705,6 +707,14 @@ namespace Million.HunterSubForm this.simpleButton_SavaAnalysisData.Text = "결과 저장"; this.simpleButton_SavaAnalysisData.Click += new System.EventHandler(this.simpleButton_SavaAnalysisData_Click); // + // treeListColumn_PurchasedCount + // + this.treeListColumn_PurchasedCount.Caption = "구종목 보유 수"; + this.treeListColumn_PurchasedCount.FieldName = "PurchasedCount"; + this.treeListColumn_PurchasedCount.Name = "treeListColumn_PurchasedCount"; + this.treeListColumn_PurchasedCount.Visible = true; + this.treeListColumn_PurchasedCount.VisibleIndex = 11; + // // ResultViewerForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); @@ -796,5 +806,6 @@ namespace Million.HunterSubForm private DevExpress.XtraEditors.SimpleButton simpleButton_WinRateProfitRate; public DevExpress.XtraEditors.SimpleButton simpleButton_TestBoard; public DevExpress.XtraTreeList.TreeList treeList_ResultData; + private DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn_PurchasedCount; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/ResultViewerForm.cs b/Million Hunter/HunterSubForm/ResultViewerForm.cs index cfb4c76..f596aaa 100644 --- a/Million Hunter/HunterSubForm/ResultViewerForm.cs +++ b/Million Hunter/HunterSubForm/ResultViewerForm.cs @@ -92,10 +92,27 @@ namespace Million.HunterSubForm _analysisDatas.Add(analysisData); } + var evaeragePurchasedCount = 0; + + // 보유한 종목 수 계산 + foreach (var item in _analysisDatas) + { + // Ts <= Os <= Te + // Ts <= Oe <= Te + var count = _analysisDatas.Count(target => (target.StartDate <= item.StartDate && target.EndDate >= item.StartDate) || + (target.StartDate <= item.EndDate && target.EndDate >= item.EndDate) + ); + + item.PurchasedCount = count; + evaeragePurchasedCount += count; + } + + evaeragePurchasedCount /= _analysisDatas.Count(); + winRate = winRate * 100 / _analysisDatas.Count(); - labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}", - double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), _analysisDatas.Count()); + labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2} 평균 보유 수 : {3}" , + double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), _analysisDatas.Count(), evaeragePurchasedCount); treeList_ResultData.DataSource = _analysisDatas; treeList_ResultData.RefreshDataSource(); @@ -228,6 +245,8 @@ namespace Million.HunterSubForm double winRate = 0; // 평균 수익률 계산하기 double profitRate = 0; + // 종목 보유 수 + var evaeragePurchasedCount = 0; // 값이 있으면 저장 if (nodeList != null && nodeList.Count() > 0) @@ -242,14 +261,27 @@ namespace Million.HunterSubForm // 수익률 계산하기 profitRate += data.EarningRate; + + // 종목 보유 수 계산하기 + // Ts <= Os <= Te + // Ts <= Oe <= Te + + var count = nodeList.Count(target => (Convert.ToDateTime(target["StartDate"]) <= data.StartDate && Convert.ToDateTime(target["EndDate"]) >= data.StartDate) || + (Convert.ToDateTime(target["StartDate"]) <= data.EndDate && Convert.ToDateTime(target["EndDate"]) >= data.EndDate) + ); + + evaeragePurchasedCount += count; + data.PurchasedCount = count; } winRate = winRate * 100 / nodeList.Count(); + evaeragePurchasedCount /= nodeList.Count(); } - labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}", - double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), nodeList.Count()); + labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2} 평균 보유 수 : {3}", + double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), nodeList.Count(), evaeragePurchasedCount); } + private void treeList_ResultData_KeyUp(object sender, KeyEventArgs e) { switch (e.KeyCode) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs index d9cc598..f4167a3 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs @@ -32,21 +32,25 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_FullInsertCandle = new DevExpress.XtraEditors.SimpleButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_구름떼상한선하락시판매 = new DevExpress.XtraEditors.CheckEdit(); this.checkEdit_구매이전봉볼린저40_1이하 = new DevExpress.XtraEditors.CheckEdit(); this.checkEdit_이전봉40_2볼린저이하 = new DevExpress.XtraEditors.CheckEdit(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.simpleButton_Reset = new DevExpress.XtraEditors.SimpleButton(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.simpleButton_찬 = new DevExpress.XtraEditors.SimpleButton(); - this.checkEdit_구름떼상한선하락시판매 = new DevExpress.XtraEditors.CheckEdit(); - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.CheckEdit(); + this.textEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.TextEdit(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).BeginInit(); this.groupBox3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).BeginInit(); this.SuspendLayout(); // // simpleButton_FullInsertCandle @@ -72,6 +76,8 @@ namespace Million_Hunter.HunterSubForm // // groupBox2 // + this.groupBox2.Controls.Add(this.textEdit_종목보유수별수익률계산); + this.groupBox2.Controls.Add(this.checkEdit_종목보유수별수익률계산); this.groupBox2.Controls.Add(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매); this.groupBox2.Controls.Add(this.checkEdit_구름떼상한선하락시판매); this.groupBox2.Controls.Add(this.checkEdit_구매이전봉볼린저40_1이하); @@ -83,6 +89,24 @@ namespace Million_Hunter.HunterSubForm this.groupBox2.TabStop = false; this.groupBox2.Text = "지표"; // + // checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 + // + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Location = new System.Drawing.Point(19, 47); + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Name = "checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매"; + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties.Caption = "구매 전봉 기준 가중이동평균 5봉이 40봉 크로스 이후 구매"; + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Size = new System.Drawing.Size(310, 19); + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.TabIndex = 3; + this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_구름떼상한선하락시판매 + // + this.checkEdit_구름떼상한선하락시판매.Location = new System.Drawing.Point(379, 22); + this.checkEdit_구름떼상한선하락시판매.Name = "checkEdit_구름떼상한선하락시판매"; + this.checkEdit_구름떼상한선하락시판매.Properties.Caption = "구름떼 상한선 하락시 판매 (1%)"; + this.checkEdit_구름떼상한선하락시판매.Size = new System.Drawing.Size(179, 19); + this.checkEdit_구름떼상한선하락시판매.TabIndex = 2; + this.checkEdit_구름떼상한선하락시판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // // checkEdit_구매이전봉볼린저40_1이하 // this.checkEdit_구매이전봉볼린저40_1이하.Location = new System.Drawing.Point(204, 22); @@ -118,6 +142,7 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_Reset.Size = new System.Drawing.Size(109, 32); this.simpleButton_Reset.TabIndex = 0; this.simpleButton_Reset.Text = "Reset"; + this.simpleButton_Reset.Click += new System.EventHandler(this.simpleButton_Reset_Click); // // progressBar1 // @@ -136,23 +161,22 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_찬.Text = "찬테스트"; this.simpleButton_찬.Click += new System.EventHandler(this.simpleButton_찬_Click); // - // checkEdit_구름떼상한선하락시판매 + // checkEdit_종목보유수별수익률계산 // - this.checkEdit_구름떼상한선하락시판매.Location = new System.Drawing.Point(379, 22); - this.checkEdit_구름떼상한선하락시판매.Name = "checkEdit_구름떼상한선하락시판매"; - this.checkEdit_구름떼상한선하락시판매.Properties.Caption = "구름떼 상한선 하락시 판매 (1%)"; - this.checkEdit_구름떼상한선하락시판매.Size = new System.Drawing.Size(179, 19); - this.checkEdit_구름떼상한선하락시판매.TabIndex = 2; - this.checkEdit_구름떼상한선하락시판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + this.checkEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(19, 72); + this.checkEdit_종목보유수별수익률계산.Name = "checkEdit_종목보유수별수익률계산"; + this.checkEdit_종목보유수별수익률계산.Properties.Caption = "종목 보유수 별 수익률 계산"; + this.checkEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(310, 19); + this.checkEdit_종목보유수별수익률계산.TabIndex = 3; + this.checkEdit_종목보유수별수익률계산.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); // - // checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 + // textEdit_종목보유수별수익률계산 // - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Location = new System.Drawing.Point(19, 47); - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Name = "checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매"; - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties.Caption = "구매 전봉 기준 가중이동평균 5봉이 40봉 크로스 이후 구매"; - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Size = new System.Drawing.Size(310, 19); - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.TabIndex = 3; - this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + this.textEdit_종목보유수별수익률계산.EditValue = "1"; + this.textEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(175, 72); + this.textEdit_종목보유수별수익률계산.Name = "textEdit_종목보유수별수익률계산"; + this.textEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(42, 20); + this.textEdit_종목보유수별수익률계산.TabIndex = 4; // // TestBoardForm // @@ -168,11 +192,13 @@ namespace Million_Hunter.HunterSubForm this.Text = "TestBoard"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit(); this.groupBox3.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).EndInit(); this.ResumeLayout(false); } @@ -191,5 +217,7 @@ namespace Million_Hunter.HunterSubForm private DevExpress.XtraEditors.CheckEdit checkEdit_구매이전봉볼린저40_1이하; private DevExpress.XtraEditors.CheckEdit checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매; private DevExpress.XtraEditors.CheckEdit checkEdit_구름떼상한선하락시판매; + private DevExpress.XtraEditors.TextEdit textEdit_종목보유수별수익률계산; + private DevExpress.XtraEditors.CheckEdit checkEdit_종목보유수별수익률계산; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index c8adfe3..3bb244d 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -358,10 +358,102 @@ namespace Million_Hunter.HunterSubForm MessageBox.Show(string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}", double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), allCount.ToString()) ); } - - parentForm.treeList_ResultData.RefreshDataSource(); - parentForm.CalcurateProfitAndWinRate(); + if (checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Checked) + { + var Interval_5 = 5; + var Interval_40 = 40; + + // 분모 구하기 + var 분모5일 = 0; + var 분모40일 = 0; + for (int i = 1; i <= Interval_5; i++) 분모5일 += i; + for (int i=1; i<=Interval_40; i++) 분모40일 += i; + + var ttt = parentForm._totalIndicator.First().MCandleTimeType; + + foreach (var analysisData in parentForm._analysisDatas) + { + // 현재 시간 데이터 포함 + var 구매이전봉_5일전거래시간 = changeDatetimeFormat(analysisData.StartDate, -Interval_5); + var 구매이전봉_40일전거래시간 = changeDatetimeFormat(analysisData.StartDate, -Interval_40); + var 구매이전봉_거래시간 = changeDatetimeFormat(analysisData.StartDate, -1); + + var 가중이동평균5일 = 0.0; + var 가중이동평균40일 = 0.0; + + + int count_40 = Interval_40; + int count_5 = Interval_5; + var curDateTime = 구매이전봉_거래시간; + while (curDateTime >= 구매이전봉_40일전거래시간) + { + var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == curDateTime); + + var 거래량 = 0.0; + + // 데이터가 없으면 거래량 0으로 사용 + if (candleData == null) 거래량 = 0; + else 거래량 = Convert.ToDouble(candleData.MoneyVolume); + + // 5일치 누적 및 계산이 끝났으면 그만 계산 + if (curDateTime >= 구매이전봉_5일전거래시간) + { + 가중이동평균5일 += count_5 * 거래량; + } + // 5일 계산 + if (curDateTime == 구매이전봉_5일전거래시간) + { + 가중이동평균5일 /= 분모5일; + // 5일 계산 + 거래량 = 0.0; + } + + // 40일 누적 + 가중이동평균40일 += count_40 * 거래량; + // 40일 계산 + if (curDateTime == 구매이전봉_40일전거래시간) + { + 가중이동평균40일 /= 분모40일; + } + + curDateTime = changeDatetimeFormat(curDateTime, -1); + count_40--; + count_5--; + } + + // 제외된 조건인 아닌 경우 (만족 조건 중에서만 검색) + if (analysisData.Inclusion) + { + var result = false; + if (가중이동평균5일 > 가중이동평균40일) + { + result = true; + analysisData.Inclusion = true; + } + else + { + result = false; + analysisData.Inclusion = false; + } + + analysisData.Description = string.Format("[{0},5일:{1:0.0},40일:{2:0.0}]",result, 가중이동평균5일, 가중이동평균40일); + } + + } + + if (checkEdit_종목보유수별수익률계산.Checked) + { + var coinCount = Convert.ToInt32(textEdit_종목보유수별수익률계산.Text); + + //inCount = + + + } + + parentForm.CalcurateProfitAndWinRate(); + parentForm.treeList_ResultData.RefreshDataSource(); + } } diff --git a/Million/Data/AnalysisData.cs b/Million/Data/AnalysisData.cs index cdb531a..ca94096 100644 --- a/Million/Data/AnalysisData.cs +++ b/Million/Data/AnalysisData.cs @@ -46,6 +46,10 @@ namespace Million.Data // 기타 기입 내용 public string Description { get; set; } + // 현재 시간으로 구매된 종목 개수 + [field: NonSerialized] + public int PurchasedCount { get; set; } + [field: NonSerialized] public Dictionary> CandleDatas { get; set; } From fb52c11b0338cd071e3553f04febadcf32b43188 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 16 May 2023 13:12:03 +0900 Subject: [PATCH 03/25] =?UTF-8?q?=EC=97=AC=EB=9F=AC=20=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=EB=B4=89=20=EA=B4=80=EB=A0=A8=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterMainForm.cs | 107 ++++++++++----------- Million/CommonProperty.cs | 10 ++ Million/Manager/DataManager.cs | 156 +++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+), 53 deletions(-) diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index ca8c729..e6a54a6 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -350,10 +350,10 @@ namespace Million sellExceptionScript.regularExpressionString = savedResult.SellExceptionRegularExpression; var dic = new Dictionary>(); - Parallel.For(0, tableList.Count, i => - { - //for (var i = 0; i < tableList.Count; i++) + //Parallel.For(0, tableList.Count, i => //{ + for (var i = 0; i < tableList.Count; i++) + { var market = tableList[i]; var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicator); @@ -369,12 +369,12 @@ namespace Million market, distinctIndicator, overlapBuyManagementList, buyScript, sellScript, sellExceptionScript); dic[market.CoinFullName] = list; } - //} - }); + } + //}); foreach (var item in dic.Keys) { - if(dic.ContainsKey(item)) + if (dic.ContainsKey(item)) totalResultList.AddRange(dic[item]); } @@ -451,7 +451,13 @@ namespace Million private List CalculateHunterRealtime(List totalIndicator, DateTime startDate, DateTime endDate, MarketData market, List distinctIndicator, Dictionary overlapBuyManagementList, InteratorScripter buyScript, InteratorScripter sellScript, InteratorScripter sellExceptionScript) - { + { + var totalCandleTypeList = totalIndicator.Select(t => t.MCandleTimeType).ToList(); + var maxCandleType = totalCandleTypeList.Max(); + + var minMaxCandleType = totalCandleTypeList.Where(t => t < MCandleTimeType.H1).Max(); + + var buyList = new List(); var subBuyList = new List(); var item = market.CoinFullName; @@ -460,24 +466,42 @@ namespace Million var resultData = new List(); - var startMiniuteDate = startDate.AddMinutes(-100); - var startHourDate = startDate.AddHours(-100); + var startMiniuteDate = startDate.AddMinutes((int)minMaxCandleType * -80); var mCandleTypeList = new List(); mCandleTypeList.Add(CommonProperty.MCandleTimeType.M1); - var hCandleTypeList = new List(); - hCandleTypeList.Add(CommonProperty.MCandleTimeType.H1); var standardData = DataManager.GetStandardData(totalIndicator, startMiniuteDate, startDate, market, distinctIndicator, true, mCandleTypeList); - var hStandardData = DataManager.GetStandardData(totalIndicator, startHourDate, startDate, market, distinctIndicator, true, hCandleTypeList); + totalCandleTypeList.AddRange(mCandleTypeList); + + if (maxCandleType >= MCandleTimeType.H1) + { + var startHourDate = startDate.AddHours((int)maxCandleType / 60 * -80); + var hCandleTypeList = new List(); + hCandleTypeList.Add(CommonProperty.MCandleTimeType.H1); + var hStandardData = DataManager.GetStandardData(totalIndicator, startHourDate, startDate, market, distinctIndicator, true, hCandleTypeList); + standardData.Add(CommonProperty.MCandleTimeType.H1, hStandardData[CommonProperty.MCandleTimeType.H1]); + totalCandleTypeList.AddRange(hCandleTypeList); + } + + totalCandleTypeList = totalCandleTypeList.Distinct().ToList(); + + foreach(var candleTimeType in totalCandleTypeList) + { + if (standardData.ContainsKey(candleTimeType)) continue; + + var candleDataList = standardData[MCandleTimeType.M1]; + if (candleTimeType >= MCandleTimeType.H1) + candleDataList = standardData[MCandleTimeType.H1]; + + standardData[candleTimeType] = DataManager.GetConvertCandleDataList(candleDataList, candleTimeType); + } - standardData.Add(CommonProperty.MCandleTimeType.H1, hStandardData[CommonProperty.MCandleTimeType.H1]); - //속도 및 메모리 부하를 줄이기 위한 로직 추가 //db 전체 데이터 불러오는 로직 -> 1분봉 데이터 하나도 안빠져있다는 가정 - + #region 개선 후 - + var standardStartDate = startDate; var standardEndDate = startDate.AddDays(7); @@ -524,43 +548,22 @@ namespace Million } //remove - if (standardData[CommonProperty.MCandleTimeType.M1].Count > 150) - standardData[CommonProperty.MCandleTimeType.M1].RemoveAt(0); - if (standardData[CommonProperty.MCandleTimeType.H1].Count > 150) - standardData[CommonProperty.MCandleTimeType.H1].RemoveAt(0); + foreach (var key in standardData.Keys) { + if (standardData[key].Count > 150) + standardData[key].RemoveAt(0); + } - //1분씩 증가하면서 1h 처리 + //1분씩 증가하면서 나머지 처리 minData.RecentlyDataFlag = true; standardData[CommonProperty.MCandleTimeType.M1].Add(minData); - var compareHour = standardData[CommonProperty.MCandleTimeType.H1].LastOrDefault(); - - - if (compareHour.DateTime.Hour != minData.DateTime.Hour) + foreach (var key in standardData.Keys) { - var candle = new CandleData(); - candle.CandleTimeType = (int)MCandleTimeType.H1; - candle.StartValue = minData.StartValue; - candle.HighValue = minData.HighValue; - candle.LowValue = minData.LowValue; - candle.RecentlyDataFlag = true; - candle.EndValue = minData.EndValue; - candle.MoneyVolume = minData.MoneyVolume; - var date = compareHour.DateTime.AddHours(1); - date = date.AddMinutes(-1 * date.Minute); - date = date.AddSeconds(-1 * date.Second); - - candle.DateTime = date; - - standardData[CommonProperty.MCandleTimeType.H1].Add(candle); - } - else - { - compareHour.HighValue = compareHour.HighValue < minData.HighValue ? minData.HighValue : compareHour.HighValue; - compareHour.LowValue = compareHour.LowValue < minData.LowValue ? compareHour.LowValue : minData.LowValue; - compareHour.EndValue = minData.EndValue; - compareHour.RecentlyDataFlag = true; - compareHour.MoneyVolume += minData.MoneyVolume; + var compareData = standardData[key].LastOrDefault(); + var newFlag = false; + var candleData = DataManager.GetRecentlyCandleData(minData, compareData, key, ref newFlag); + if (newFlag) + standardData[key].Add(candleData); } standardData = DataManager.GetExecuteData(standardData, totalIndicator); @@ -584,11 +587,9 @@ namespace Million mDataList.CandleDataLists_Im.RemoveAt(0); continue; } - var recentlyDate = recentlyData.DateTime; - recentlyDate = recentlyDate.AddMinutes(recentlyDate.Minute * -1); - recentlyDate = recentlyDate.AddHours( -1); - //before 데이터 가져오는 함수 - var beforeData = standardData[MCandleTimeType.H1].FirstOrDefault(t => t.DateTime == recentlyDate); + + //before 데이터 가져오는 함수 -> 사는 케이스만 + var beforeData = standardData[maxCandleType].LastOrDefault(); if (!buyList.Any(t => t.ConGoodsData.CoinFullName == item)) { diff --git a/Million/CommonProperty.cs b/Million/CommonProperty.cs index 854dfd5..a1e3252 100644 --- a/Million/CommonProperty.cs +++ b/Million/CommonProperty.cs @@ -137,13 +137,23 @@ namespace Million public enum MCandleTimeType { M1 = 1, + M2 = 2, M3 = 3, + M4 = 4, M5 = 5, + M6 = 6, M10 = 10, + M12 = 12, M15 = 15, + M20 = 20, M30 = 30, H1 = 60, + H2 = 120, + H3 = 180, H4 = 240, + H6 = 360, + H8 = 480, + H12 = 720, D1 = 1000, W1 = 10000, MT1 = 100000 diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 54b7e12..c3e8a7d 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -219,5 +219,161 @@ namespace Million.Manager result.SellCount = sellCandleData.BuyCount; return result; } + + + /// + /// CandleList 만들어주는거 + /// + /// + /// + /// + public static List GetConvertCandleDataList(List currentCandleList, MCandleTimeType mCandleTimeType) { + + var returnData = new List(); + + var timeFlag = "minute"; + var timeFlagValue = 0; + if(mCandleTimeType < MCandleTimeType.H1) + { + timeFlagValue = (int)mCandleTimeType; + } + else if(mCandleTimeType < MCandleTimeType.D1) + { + timeFlag = "hour"; + timeFlagValue = ((int) mCandleTimeType) / 60; + } + + var firstFlag = true; + + foreach(var item in currentCandleList) + { + var flag = false; + var recentlyData = returnData.LastOrDefault(); + if (recentlyData != null) + { + if (timeFlag == "minute") + { + if (item.DateTime.Minute % timeFlagValue == 0) + { + if (recentlyData.DateTime.Minute != item.DateTime.Minute) + flag = true; + } + } + else if (timeFlag == "hour") + { + if (item.DateTime.Hour % timeFlagValue == 0) + { + if (recentlyData.DateTime.Hour != item.DateTime.Hour) + flag = true; + } + } + } + + if (firstFlag) + { + firstFlag = false; + flag = true; + } + + //새로 생성 + if (flag) + { + returnData.Add(item); + } + //기존 데이터 엎어쓰기 + else + { + recentlyData.HighValue = recentlyData.HighValue < item.HighValue ? item.HighValue : recentlyData.HighValue; + recentlyData.LowValue = recentlyData.LowValue < item.LowValue ? recentlyData.LowValue : item.LowValue; + recentlyData.EndValue = item.EndValue; + recentlyData.MoneyVolume += item.MoneyVolume; + } + } + + + return returnData; + } + + /// + /// 최근 데이터 업데이트 하는 로직 + /// + /// + /// + /// + /// + /// + public static CandleData GetRecentlyCandleData(CandleData candleData, CandleData recentlyData, MCandleTimeType mCandleTimeType, ref bool newFlag) + { + var timeFlag = "minute"; + var timeFlagValue = 0; + if (mCandleTimeType < MCandleTimeType.H1) + { + timeFlagValue = (int)mCandleTimeType; + } + else if (mCandleTimeType < MCandleTimeType.D1) + { + timeFlag = "hour"; + timeFlagValue = ((int)mCandleTimeType) / 60; + } + + var flag = false; + + if (recentlyData != null) + { + if (timeFlag == "minute") + { + if (candleData.DateTime.Minute % timeFlagValue == 0) + { + if (recentlyData.DateTime.Minute != candleData.DateTime.Minute) + flag = true; + } + } + else if (timeFlag == "hour") + { + if (candleData.DateTime.Hour % timeFlagValue == 0) + { + if (recentlyData.DateTime.Hour != candleData.DateTime.Hour) + flag = true; + } + } + } + //새로 생성 + if (flag) + { + newFlag = true; + var candle = new CandleData(); + candle.CandleTimeType = (int)mCandleTimeType; + candle.StartValue = candleData.StartValue; + candle.HighValue = candleData.HighValue; + candle.LowValue = candleData.LowValue; + candle.RecentlyDataFlag = true; + candle.EndValue = candleData.EndValue; + candle.MoneyVolume = candleData.MoneyVolume; + + if (timeFlag == "minute") + { + var date = recentlyData.DateTime.AddMinutes((int)mCandleTimeType); + date = date.AddSeconds(-1 * date.Second); + candle.DateTime = date; + } + else if (timeFlag == "hour") + { + var date = recentlyData.DateTime.AddHours((int)mCandleTimeType/60); + date = date.AddMinutes(-1 * date.Minute); + date = date.AddSeconds(-1 * date.Second); + candle.DateTime = date; + } + return candle; + } + //기존 데이터 엎어쓰기 + else + { + recentlyData.HighValue = recentlyData.HighValue < candleData.HighValue ? candleData.HighValue : recentlyData.HighValue; + recentlyData.LowValue = recentlyData.LowValue < candleData.LowValue ? recentlyData.LowValue : candleData.LowValue; + recentlyData.EndValue = candleData.EndValue; + recentlyData.MoneyVolume += candleData.MoneyVolume; + return recentlyData; + } + } } } From 1d3929b84df19389e8244c81b0e20da9e2cd64da Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 16 May 2023 13:14:09 +0900 Subject: [PATCH 04/25] =?UTF-8?q?=EB=B3=91=EB=A0=AC=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EC=9B=90=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterMainForm.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index e6a54a6..655fe89 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -350,10 +350,10 @@ namespace Million sellExceptionScript.regularExpressionString = savedResult.SellExceptionRegularExpression; var dic = new Dictionary>(); - //Parallel.For(0, tableList.Count, i => - //{ - for (var i = 0; i < tableList.Count; i++) + Parallel.For(0, tableList.Count, i => { + // for (var i = 0; i < tableList.Count; i++) + //{ var market = tableList[i]; var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicator); @@ -369,8 +369,8 @@ namespace Million market, distinctIndicator, overlapBuyManagementList, buyScript, sellScript, sellExceptionScript); dic[market.CoinFullName] = list; } - } - //}); + //} + }); foreach (var item in dic.Keys) { From b1ece2225897956f7720ddae7e4b6b30338227be Mon Sep 17 00:00:00 2001 From: jwlee Date: Tue, 16 May 2023 13:16:25 +0900 Subject: [PATCH 05/25] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EA=B8=B0=EB=8A=A5=20=EC=9E=91=EC=84=B1=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HunterSubForm/TestBoardForm.Designer.cs | 124 +++++++++++++++--- Million Hunter/HunterSubForm/TestBoardForm.cs | 92 +++++++++++-- 2 files changed, 184 insertions(+), 32 deletions(-) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs index f4167a3..f01094d 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs @@ -32,6 +32,12 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_FullInsertCandle = new DevExpress.XtraEditors.SimpleButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.textEdit_종가시간판매 = new DevExpress.XtraEditors.TextEdit(); + this.checkEdit_종가시간판매 = new DevExpress.XtraEditors.CheckEdit(); + this.textEdit1 = new DevExpress.XtraEditors.TextEdit(); + this.textEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.TextEdit(); + this.checkEdit1 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.CheckEdit(); this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 = new DevExpress.XtraEditors.CheckEdit(); this.checkEdit_구름떼상한선하락시판매 = new DevExpress.XtraEditors.CheckEdit(); this.checkEdit_구매이전봉볼린저40_1이하 = new DevExpress.XtraEditors.CheckEdit(); @@ -40,17 +46,23 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_Reset = new DevExpress.XtraEditors.SimpleButton(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.simpleButton_찬 = new DevExpress.XtraEditors.SimpleButton(); - this.checkEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.CheckEdit(); - this.textEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.TextEdit(); + this.checkEdit_시가구름떼위에서시작 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_시가가볼린저401보다작음 = new DevExpress.XtraEditors.CheckEdit(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_종가시간판매.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종가시간판매.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit1.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).BeginInit(); this.groupBox3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).BeginInit(); this.SuspendLayout(); // // simpleButton_FullInsertCandle @@ -76,7 +88,13 @@ namespace Million_Hunter.HunterSubForm // // groupBox2 // + this.groupBox2.Controls.Add(this.checkEdit_시가가볼린저401보다작음); + this.groupBox2.Controls.Add(this.checkEdit_시가구름떼위에서시작); + this.groupBox2.Controls.Add(this.textEdit_종가시간판매); + this.groupBox2.Controls.Add(this.checkEdit_종가시간판매); + this.groupBox2.Controls.Add(this.textEdit1); this.groupBox2.Controls.Add(this.textEdit_종목보유수별수익률계산); + this.groupBox2.Controls.Add(this.checkEdit1); this.groupBox2.Controls.Add(this.checkEdit_종목보유수별수익률계산); this.groupBox2.Controls.Add(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매); this.groupBox2.Controls.Add(this.checkEdit_구름떼상한선하락시판매); @@ -84,11 +102,64 @@ namespace Million_Hunter.HunterSubForm this.groupBox2.Controls.Add(this.checkEdit_이전봉40_2볼린저이하); this.groupBox2.Location = new System.Drawing.Point(12, 90); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(829, 123); + this.groupBox2.Size = new System.Drawing.Size(829, 151); this.groupBox2.TabIndex = 3; this.groupBox2.TabStop = false; this.groupBox2.Text = "지표"; // + // textEdit_종가시간판매 + // + this.textEdit_종가시간판매.EditValue = "0"; + this.textEdit_종가시간판매.Location = new System.Drawing.Point(660, 20); + this.textEdit_종가시간판매.Name = "textEdit_종가시간판매"; + this.textEdit_종가시간판매.Properties.Mask.EditMask = "d"; + this.textEdit_종가시간판매.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; + this.textEdit_종가시간판매.Size = new System.Drawing.Size(42, 20); + this.textEdit_종가시간판매.TabIndex = 6; + // + // checkEdit_종가시간판매 + // + this.checkEdit_종가시간판매.Location = new System.Drawing.Point(564, 21); + this.checkEdit_종가시간판매.Name = "checkEdit_종가시간판매"; + this.checkEdit_종가시간판매.Properties.Caption = "종가(시간)판매"; + this.checkEdit_종가시간판매.Size = new System.Drawing.Size(150, 19); + this.checkEdit_종가시간판매.TabIndex = 5; + this.checkEdit_종가시간판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // textEdit1 + // + this.textEdit1.EditValue = "1"; + this.textEdit1.Location = new System.Drawing.Point(298, 72); + this.textEdit1.Name = "textEdit1"; + this.textEdit1.Size = new System.Drawing.Size(42, 20); + this.textEdit1.TabIndex = 4; + // + // textEdit_종목보유수별수익률계산 + // + this.textEdit_종목보유수별수익률계산.EditValue = "1"; + this.textEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(175, 72); + this.textEdit_종목보유수별수익률계산.Name = "textEdit_종목보유수별수익률계산"; + this.textEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(42, 20); + this.textEdit_종목보유수별수익률계산.TabIndex = 4; + // + // checkEdit1 + // + this.checkEdit1.Location = new System.Drawing.Point(233, 73); + this.checkEdit1.Name = "checkEdit1"; + this.checkEdit1.Properties.Caption = "거래대금"; + this.checkEdit1.Size = new System.Drawing.Size(150, 19); + this.checkEdit1.TabIndex = 3; + this.checkEdit1.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_종목보유수별수익률계산 + // + this.checkEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(19, 72); + this.checkEdit_종목보유수별수익률계산.Name = "checkEdit_종목보유수별수익률계산"; + this.checkEdit_종목보유수별수익률계산.Properties.Caption = "종목 보유수 별 수익률 계산"; + this.checkEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(150, 19); + this.checkEdit_종목보유수별수익률계산.TabIndex = 3; + this.checkEdit_종목보유수별수익률계산.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // // checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 // this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Location = new System.Drawing.Point(19, 47); @@ -161,22 +232,23 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_찬.Text = "찬테스트"; this.simpleButton_찬.Click += new System.EventHandler(this.simpleButton_찬_Click); // - // checkEdit_종목보유수별수익률계산 + // checkEdit_시가구름떼위에서시작 // - this.checkEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(19, 72); - this.checkEdit_종목보유수별수익률계산.Name = "checkEdit_종목보유수별수익률계산"; - this.checkEdit_종목보유수별수익률계산.Properties.Caption = "종목 보유수 별 수익률 계산"; - this.checkEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(310, 19); - this.checkEdit_종목보유수별수익률계산.TabIndex = 3; - this.checkEdit_종목보유수별수익률계산.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + this.checkEdit_시가구름떼위에서시작.Location = new System.Drawing.Point(19, 97); + this.checkEdit_시가구름떼위에서시작.Name = "checkEdit_시가구름떼위에서시작"; + this.checkEdit_시가구름떼위에서시작.Properties.Caption = "시가 구름떼 위에서 시작"; + this.checkEdit_시가구름떼위에서시작.Size = new System.Drawing.Size(150, 19); + this.checkEdit_시가구름떼위에서시작.TabIndex = 7; + this.checkEdit_시가구름떼위에서시작.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); // - // textEdit_종목보유수별수익률계산 + // checkEdit_시가가볼린저401보다작음 // - this.textEdit_종목보유수별수익률계산.EditValue = "1"; - this.textEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(175, 72); - this.textEdit_종목보유수별수익률계산.Name = "textEdit_종목보유수별수익률계산"; - this.textEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(42, 20); - this.textEdit_종목보유수별수익률계산.TabIndex = 4; + this.checkEdit_시가가볼린저401보다작음.Location = new System.Drawing.Point(164, 97); + this.checkEdit_시가가볼린저401보다작음.Name = "checkEdit_시가가볼린저401보다작음"; + this.checkEdit_시가가볼린저401보다작음.Properties.Caption = "시가가 볼린저 40 1 보다 작음"; + this.checkEdit_시가가볼린저401보다작음.Size = new System.Drawing.Size(150, 19); + this.checkEdit_시가가볼린저401보다작음.TabIndex = 8; + this.checkEdit_시가가볼린저401보다작음.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); // // TestBoardForm // @@ -192,13 +264,19 @@ namespace Million_Hunter.HunterSubForm this.Text = "TestBoard"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_종가시간판매.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종가시간판매.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit1.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit(); this.groupBox3.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).EndInit(); this.ResumeLayout(false); } @@ -219,5 +297,11 @@ namespace Million_Hunter.HunterSubForm private DevExpress.XtraEditors.CheckEdit checkEdit_구름떼상한선하락시판매; private DevExpress.XtraEditors.TextEdit textEdit_종목보유수별수익률계산; private DevExpress.XtraEditors.CheckEdit checkEdit_종목보유수별수익률계산; + private DevExpress.XtraEditors.TextEdit textEdit_종가시간판매; + private DevExpress.XtraEditors.CheckEdit checkEdit_종가시간판매; + private DevExpress.XtraEditors.TextEdit textEdit1; + private DevExpress.XtraEditors.CheckEdit checkEdit1; + private DevExpress.XtraEditors.CheckEdit checkEdit_시가구름떼위에서시작; + private DevExpress.XtraEditors.CheckEdit checkEdit_시가가볼린저401보다작음; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index 3bb244d..3d50efa 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -441,19 +441,87 @@ namespace Million_Hunter.HunterSubForm } } - - if (checkEdit_종목보유수별수익률계산.Checked) - { - var coinCount = Convert.ToInt32(textEdit_종목보유수별수익률계산.Text); - - //inCount = - - - } - - parentForm.CalcurateProfitAndWinRate(); - parentForm.treeList_ResultData.RefreshDataSource(); } + + + if (checkEdit_종목보유수별수익률계산.Checked) + { + var coinCount = Convert.ToInt32(textEdit_종목보유수별수익률계산.Text); + //r Con + //inCount = + + + } + // 종가 판매 + if (checkEdit_종가시간판매.Checked) + { + // 종가 판매 봉기준 + var candleInterval = Convert.ToInt32(textEdit_종가시간판매.Text); + + foreach (var analysisData in parentForm._analysisDatas) + { + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var endDate = changeDatetimeFormat(analysisData.EndDate, 0); + var 종가판매기준시간 = changeDatetimeFormat(startDate, candleInterval); + + if (analysisData.Inclusion) + { + if (changeDatetimeFormat(endDate, 0) > 종가판매기준시간) + { + var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == 종가판매기준시간); + if(data == null) + { + var date = new DateTime(); + date = 종가판매기준시간; + while (data == null) + { + date = changeDatetimeFormat(date, -1); + data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == date); + + } + } + + // 수익률 구하기 + analysisData.EarningRate = (-100 + (data.EndValue / analysisData.BuyValue) * 100); + + + analysisData.WinFlag = analysisData.EarningRate > 0 ? true : false; + analysisData.SellValue = data.EndValue; + } + } + + continue; + } + } + + if(checkEdit_시가구름떼위에서시작.Checked) + { + foreach (var analysisData in parentForm._analysisDatas) + { + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate); + + var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2); + + if (analysisData.Inclusion) + if (maxich >= data.StartValue) analysisData.Inclusion = false; + } + } + + if (checkEdit_시가가볼린저401보다작음.Checked) + { + foreach (var analysisData in parentForm._analysisDatas) + { + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate); + + if (analysisData.Inclusion) + if (data.IndicatorDic["Bol401"].value <= data.StartValue) analysisData.Inclusion = false; + } + } + + parentForm.CalcurateProfitAndWinRate(); + parentForm.treeList_ResultData.RefreshDataSource(); } From b614d31df97fab7ea1b3f0a576640df22af974c6 Mon Sep 17 00:00:00 2001 From: JHLEE Date: Tue, 16 May 2023 13:22:30 +0900 Subject: [PATCH 06/25] =?UTF-8?q?update=20server=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B8=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EA=B8=B8=EC=9D=B4=20?= =?UTF-8?q?=EB=8A=98=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Update Server/App.config | 6 +-- Million Update Server/Form1.Designer.cs | 1 + Million Update Server/Form1.cs | 47 +++-------------- .../Million Update Server.csproj | 39 +++++++++++++- .../Million Update Server.csproj.user | 13 +++++ .../Properties/Resources.Designer.cs | 52 ++++++++----------- .../Properties/Settings.Designer.cs | 30 +++++------ 7 files changed, 97 insertions(+), 91 deletions(-) create mode 100644 Million Update Server/Million Update Server.csproj.user diff --git a/Million Update Server/App.config b/Million Update Server/App.config index 88fa402..4bfa005 100644 --- a/Million Update Server/App.config +++ b/Million Update Server/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Million Update Server/Form1.Designer.cs b/Million Update Server/Form1.Designer.cs index 530a5a1..b90e8da 100644 --- a/Million Update Server/Form1.Designer.cs +++ b/Million Update Server/Form1.Designer.cs @@ -39,6 +39,7 @@ this.textBox_log.Location = new System.Drawing.Point(12, 12); this.textBox_log.Multiline = true; this.textBox_log.Name = "textBox_log"; + this.textBox_log.ReadOnly = true; this.textBox_log.Size = new System.Drawing.Size(284, 579); this.textBox_log.TabIndex = 0; // diff --git a/Million Update Server/Form1.cs b/Million Update Server/Form1.cs index 74441d4..7e54691 100644 --- a/Million Update Server/Form1.cs +++ b/Million Update Server/Form1.cs @@ -1,14 +1,8 @@ using System; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.IO; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; using Newtonsoft.Json; @@ -28,7 +22,7 @@ namespace Million_Update_Server private void writeLog(string text) { - log = text + log; + log = text+"\r\n" + log; Invoke(new MethodInvoker(delegate () { @@ -72,43 +66,18 @@ namespace Million_Update_Server try { - // 수신한 데이터를 저장할 버퍼 - byte[] messageBuffer = new byte[4096]; - // 받은 데이터의 총 길이 - int bytesRead; - - while (true) + string data = ""; + do { - bytesRead = 0; - try - { - // 클라이언트에서 데이터 수신 대기 - bytesRead = clientStream.Read(messageBuffer, 0, 4096); - } - catch - { - // 연결이 끊어졌을 경우 예외 발생 - break; - } + byte[] buffer = new byte[tcpClient.ReceiveBufferSize]; + int bytesRead = clientStream.Read(buffer, 0, buffer.Length); + data += Encoding.UTF8.GetString(buffer, 0, bytesRead); + } while (clientStream.DataAvailable); - // 수신한 데이터가 없을 경우 - if (bytesRead == 0) - { - // 연결이 끊어졌음을 알리기 위해 예외 발생 - throw new Exception("연결이 끊어졌습니다."); - } + var receivedPeople = JsonConvert.DeserializeObject(data); - // 수신한 데이터를 문자열로 변환 - string message = Encoding.UTF8.GetString(messageBuffer, 0, bytesRead); - // 문자열을 Person 객체로 역직렬화 - /*Person person = JsonConvert.DeserializeObject(message); - // 수신한 Person 객체를 출력 - Console.WriteLine("수신한 Person 객체:"); - Console.WriteLine("이름: " + person.Name); - Console.WriteLine("나이: " + person.Age);*/ - } } catch (Exception ex) { diff --git a/Million Update Server/Million Update Server.csproj b/Million Update Server/Million Update Server.csproj index 5eb4e47..8f8e0df 100644 --- a/Million Update Server/Million Update Server.csproj +++ b/Million Update Server/Million Update Server.csproj @@ -8,13 +8,29 @@ WinExe Million_Update_Server Million Update Server - v4.5.2 + v4.8 512 true true + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true - AnyCPU + x64 true full false @@ -68,6 +84,7 @@ True Resources.resx + True @@ -83,5 +100,23 @@ + + + {10ef08cb-bf38-4882-a92a-30db34e8e8bd} + Million Core + + + + + False + Microsoft .NET Framework 4.8%28x86 및 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/Million Update Server/Million Update Server.csproj.user b/Million Update Server/Million Update Server.csproj.user new file mode 100644 index 0000000..58b4d25 --- /dev/null +++ b/Million Update Server/Million Update Server.csproj.user @@ -0,0 +1,13 @@ + + + + publish\ + + + + + + ko-KR + false + + \ No newline at end of file diff --git a/Million Update Server/Properties/Resources.Designer.cs b/Million Update Server/Properties/Resources.Designer.cs index 7f0077b..74a969f 100644 --- a/Million Update Server/Properties/Resources.Designer.cs +++ b/Million Update Server/Properties/Resources.Designer.cs @@ -8,62 +8,54 @@ // //------------------------------------------------------------------------------ -namespace Million_Update_Server.Properties -{ - - +namespace Million_Update_Server.Properties { + using System; + + /// /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. /// // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder // 클래스에서 자동으로 생성되었습니다. - // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 - // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 + // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Million_Update_Server.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 - /// 재정의합니다. + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대한 현재 스레드의 CurrentUICulture + /// 속성을 재정의합니다. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/Million Update Server/Properties/Settings.Designer.cs b/Million Update Server/Properties/Settings.Designer.cs index 142b0ed..94dd5ae 100644 --- a/Million Update Server/Properties/Settings.Designer.cs +++ b/Million Update Server/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. // //------------------------------------------------------------------------------ -namespace Million_Update_Server.Properties -{ - - +namespace Million_Update_Server.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } From 5e868ae37374eec20ce2b643b8ea7305e1e43706 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 16 May 2023 13:25:36 +0900 Subject: [PATCH 07/25] =?UTF-8?q?=EB=B6=84=EB=B4=89=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterMainForm.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index 655fe89..4e1e8f3 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -455,8 +455,11 @@ namespace Million var totalCandleTypeList = totalIndicator.Select(t => t.MCandleTimeType).ToList(); var maxCandleType = totalCandleTypeList.Max(); - var minMaxCandleType = totalCandleTypeList.Where(t => t < MCandleTimeType.H1).Max(); + var list = totalCandleTypeList.Where(t => t < MCandleTimeType.H1).ToList(); + var minMaxCandleType = MCandleTimeType.M1; + if (!(list == null || list.Count == 0)) + minMaxCandleType = list.Max(); var buyList = new List(); var subBuyList = new List(); From 514b95abca942bc5b71f693360ffafb014777391 Mon Sep 17 00:00:00 2001 From: jwlee Date: Tue, 16 May 2023 13:31:32 +0900 Subject: [PATCH 08/25] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/Million Hunter.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Million Hunter/Million Hunter.csproj b/Million Hunter/Million Hunter.csproj index b7b5765..ba766f1 100644 --- a/Million Hunter/Million Hunter.csproj +++ b/Million Hunter/Million Hunter.csproj @@ -153,6 +153,7 @@ TestBoardForm.cs + ResXFileCodeGenerator Resources.Designer.cs From 7115197522b543701cf900fffef3258a97eba667 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 16 May 2023 16:09:26 +0900 Subject: [PATCH 09/25] =?UTF-8?q?MCandledatatype=20day=EB=8F=84=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/Manager/DataManager.cs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index c3e8a7d..829a2f5 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -242,6 +242,11 @@ namespace Million.Manager timeFlag = "hour"; timeFlagValue = ((int) mCandleTimeType) / 60; } + else if(mCandleTimeType < MCandleTimeType.W1) + { + timeFlag = "day"; + timeFlagValue = 1; + } var firstFlag = true; @@ -267,6 +272,11 @@ namespace Million.Manager flag = true; } } + else if(timeFlag == "day") + { + if (recentlyData.DateTime.Day != item.DateTime.Day) + flag = true; + } } if (firstFlag) @@ -315,6 +325,11 @@ namespace Million.Manager timeFlag = "hour"; timeFlagValue = ((int)mCandleTimeType) / 60; } + else if(mCandleTimeType < MCandleTimeType.W1) + { + timeFlag = "day"; + timeFlagValue = 1; + } var flag = false; @@ -336,6 +351,11 @@ namespace Million.Manager flag = true; } } + else if(timeFlag == "day") + { + if (recentlyData.DateTime.Day != candleData.DateTime.Day) + flag = true; + } } //새로 생성 if (flag) @@ -352,13 +372,21 @@ namespace Million.Manager if (timeFlag == "minute") { - var date = recentlyData.DateTime.AddMinutes((int)mCandleTimeType); + var date = recentlyData.DateTime.AddMinutes((int)mCandleTimeType); date = date.AddSeconds(-1 * date.Second); candle.DateTime = date; } else if (timeFlag == "hour") { - var date = recentlyData.DateTime.AddHours((int)mCandleTimeType/60); + var date = recentlyData.DateTime.AddHours((int)mCandleTimeType / 60); + date = date.AddMinutes(-1 * date.Minute); + date = date.AddSeconds(-1 * date.Second); + candle.DateTime = date; + } + else if (timeFlag == "day") + { + var date = recentlyData.DateTime.AddDays(1); + date = date.AddHours(-1 * date.Hour); date = date.AddMinutes(-1 * date.Minute); date = date.AddSeconds(-1 * date.Second); candle.DateTime = date; From 3f000635f5b53ff8a51e00841df33649e1dc4655 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 16 May 2023 16:10:29 +0900 Subject: [PATCH 10/25] =?UTF-8?q?1440=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/CommonProperty.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Million/CommonProperty.cs b/Million/CommonProperty.cs index a1e3252..ab108da 100644 --- a/Million/CommonProperty.cs +++ b/Million/CommonProperty.cs @@ -154,7 +154,7 @@ namespace Million H6 = 360, H8 = 480, H12 = 720, - D1 = 1000, + D1 = 1440, W1 = 10000, MT1 = 100000 } From 3749475412cd8cf83dd59d08865f519247c11828 Mon Sep 17 00:00:00 2001 From: jwlee Date: Wed, 17 May 2023 00:02:33 +0900 Subject: [PATCH 11/25] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HunterSubForm/TestBoardForm.Designer.cs | 122 +++++++++++++----- Million Hunter/HunterSubForm/TestBoardForm.cs | 88 ++++++++++++- 2 files changed, 176 insertions(+), 34 deletions(-) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs index f01094d..ee0356b 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs @@ -32,6 +32,10 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_FullInsertCandle = new DevExpress.XtraEditors.SimpleButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.checkEdit_4시간_8시간구름떼위_양봉 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_4시간_8시간구름떼위 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_시가가볼린저401보다작음 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_시가구름떼위에서시작 = new DevExpress.XtraEditors.CheckEdit(); this.textEdit_종가시간판매 = new DevExpress.XtraEditors.TextEdit(); this.checkEdit_종가시간판매 = new DevExpress.XtraEditors.CheckEdit(); this.textEdit1 = new DevExpress.XtraEditors.TextEdit(); @@ -46,10 +50,14 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_Reset = new DevExpress.XtraEditors.SimpleButton(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.simpleButton_찬 = new DevExpress.XtraEditors.SimpleButton(); - this.checkEdit_시가구름떼위에서시작 = new DevExpress.XtraEditors.CheckEdit(); - this.checkEdit_시가가볼린저401보다작음 = new DevExpress.XtraEditors.CheckEdit(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위_양봉.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit_종가시간판매.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종가시간판매.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit(); @@ -61,8 +69,8 @@ namespace Million_Hunter.HunterSubForm ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).BeginInit(); this.groupBox3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).BeginInit(); + this.groupBox4.SuspendLayout(); + this.groupBox5.SuspendLayout(); this.SuspendLayout(); // // simpleButton_FullInsertCandle @@ -81,17 +89,17 @@ namespace Million_Hunter.HunterSubForm this.groupBox1.Controls.Add(this.simpleButton_FullInsertCandle); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(154, 63); + this.groupBox1.Size = new System.Drawing.Size(340, 63); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "데이터 채우기"; // // groupBox2 // + this.groupBox2.Controls.Add(this.groupBox5); + this.groupBox2.Controls.Add(this.groupBox4); this.groupBox2.Controls.Add(this.checkEdit_시가가볼린저401보다작음); this.groupBox2.Controls.Add(this.checkEdit_시가구름떼위에서시작); - this.groupBox2.Controls.Add(this.textEdit_종가시간판매); - this.groupBox2.Controls.Add(this.checkEdit_종가시간판매); this.groupBox2.Controls.Add(this.textEdit1); this.groupBox2.Controls.Add(this.textEdit_종목보유수별수익률계산); this.groupBox2.Controls.Add(this.checkEdit1); @@ -100,17 +108,53 @@ namespace Million_Hunter.HunterSubForm this.groupBox2.Controls.Add(this.checkEdit_구름떼상한선하락시판매); this.groupBox2.Controls.Add(this.checkEdit_구매이전봉볼린저40_1이하); this.groupBox2.Controls.Add(this.checkEdit_이전봉40_2볼린저이하); - this.groupBox2.Location = new System.Drawing.Point(12, 90); + this.groupBox2.Location = new System.Drawing.Point(12, 110); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(829, 151); + this.groupBox2.Size = new System.Drawing.Size(1006, 230); this.groupBox2.TabIndex = 3; this.groupBox2.TabStop = false; this.groupBox2.Text = "지표"; // + // checkEdit_4시간_8시간구름떼위_양봉 + // + this.checkEdit_4시간_8시간구름떼위_양봉.Location = new System.Drawing.Point(6, 46); + this.checkEdit_4시간_8시간구름떼위_양봉.Name = "checkEdit_4시간_8시간구름떼위_양봉"; + this.checkEdit_4시간_8시간구름떼위_양봉.Properties.Caption = "4시간, 8시간 구름떼위 양봉 (1시간 기준)"; + this.checkEdit_4시간_8시간구름떼위_양봉.Size = new System.Drawing.Size(221, 19); + this.checkEdit_4시간_8시간구름떼위_양봉.TabIndex = 9; + this.checkEdit_4시간_8시간구름떼위_양봉.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_4시간_8시간구름떼위 + // + this.checkEdit_4시간_8시간구름떼위.Location = new System.Drawing.Point(6, 21); + this.checkEdit_4시간_8시간구름떼위.Name = "checkEdit_4시간_8시간구름떼위"; + this.checkEdit_4시간_8시간구름떼위.Properties.Caption = "4시간, 8시간구름떼위 (1시간 기준)"; + this.checkEdit_4시간_8시간구름떼위.Size = new System.Drawing.Size(195, 19); + this.checkEdit_4시간_8시간구름떼위.TabIndex = 9; + this.checkEdit_4시간_8시간구름떼위.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_시가가볼린저401보다작음 + // + this.checkEdit_시가가볼린저401보다작음.Location = new System.Drawing.Point(164, 97); + this.checkEdit_시가가볼린저401보다작음.Name = "checkEdit_시가가볼린저401보다작음"; + this.checkEdit_시가가볼린저401보다작음.Properties.Caption = "시가가 볼린저 40 1 보다 작음"; + this.checkEdit_시가가볼린저401보다작음.Size = new System.Drawing.Size(165, 19); + this.checkEdit_시가가볼린저401보다작음.TabIndex = 8; + this.checkEdit_시가가볼린저401보다작음.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_시가구름떼위에서시작 + // + this.checkEdit_시가구름떼위에서시작.Location = new System.Drawing.Point(19, 97); + this.checkEdit_시가구름떼위에서시작.Name = "checkEdit_시가구름떼위에서시작"; + this.checkEdit_시가구름떼위에서시작.Properties.Caption = "시가 구름떼 위에서 시작"; + this.checkEdit_시가구름떼위에서시작.Size = new System.Drawing.Size(150, 19); + this.checkEdit_시가구름떼위에서시작.TabIndex = 7; + this.checkEdit_시가구름떼위에서시작.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // // textEdit_종가시간판매 // this.textEdit_종가시간판매.EditValue = "0"; - this.textEdit_종가시간판매.Location = new System.Drawing.Point(660, 20); + this.textEdit_종가시간판매.Location = new System.Drawing.Point(108, 21); this.textEdit_종가시간판매.Name = "textEdit_종가시간판매"; this.textEdit_종가시간판매.Properties.Mask.EditMask = "d"; this.textEdit_종가시간판매.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; @@ -119,10 +163,10 @@ namespace Million_Hunter.HunterSubForm // // checkEdit_종가시간판매 // - this.checkEdit_종가시간판매.Location = new System.Drawing.Point(564, 21); + this.checkEdit_종가시간판매.Location = new System.Drawing.Point(6, 21); this.checkEdit_종가시간판매.Name = "checkEdit_종가시간판매"; this.checkEdit_종가시간판매.Properties.Caption = "종가(시간)판매"; - this.checkEdit_종가시간판매.Size = new System.Drawing.Size(150, 19); + this.checkEdit_종가시간판매.Size = new System.Drawing.Size(102, 19); this.checkEdit_종가시간판매.TabIndex = 5; this.checkEdit_종가시간판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); // @@ -199,7 +243,7 @@ namespace Million_Hunter.HunterSubForm // groupBox3 // this.groupBox3.Controls.Add(this.simpleButton_Reset); - this.groupBox3.Location = new System.Drawing.Point(187, 12); + this.groupBox3.Location = new System.Drawing.Point(373, 12); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(154, 63); this.groupBox3.TabIndex = 4; @@ -218,43 +262,47 @@ namespace Million_Hunter.HunterSubForm // progressBar1 // this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar1.Location = new System.Drawing.Point(0, 275); + this.progressBar1.Location = new System.Drawing.Point(2, 474); this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(852, 23); + this.progressBar1.Size = new System.Drawing.Size(1029, 23); this.progressBar1.TabIndex = 5; // // simpleButton_찬 // - this.simpleButton_찬.Location = new System.Drawing.Point(737, 33); + this.simpleButton_찬.Location = new System.Drawing.Point(914, 23); this.simpleButton_찬.Name = "simpleButton_찬"; this.simpleButton_찬.Size = new System.Drawing.Size(104, 32); this.simpleButton_찬.TabIndex = 4; this.simpleButton_찬.Text = "찬테스트"; this.simpleButton_찬.Click += new System.EventHandler(this.simpleButton_찬_Click); // - // checkEdit_시가구름떼위에서시작 + // groupBox4 // - this.checkEdit_시가구름떼위에서시작.Location = new System.Drawing.Point(19, 97); - this.checkEdit_시가구름떼위에서시작.Name = "checkEdit_시가구름떼위에서시작"; - this.checkEdit_시가구름떼위에서시작.Properties.Caption = "시가 구름떼 위에서 시작"; - this.checkEdit_시가구름떼위에서시작.Size = new System.Drawing.Size(150, 19); - this.checkEdit_시가구름떼위에서시작.TabIndex = 7; - this.checkEdit_시가구름떼위에서시작.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + this.groupBox4.Controls.Add(this.checkEdit_4시간_8시간구름떼위); + this.groupBox4.Controls.Add(this.checkEdit_4시간_8시간구름떼위_양봉); + this.groupBox4.Location = new System.Drawing.Point(379, 49); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(444, 83); + this.groupBox4.TabIndex = 10; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "상위 시간 구름떼 / 볼린저 (시가 기준)"; // - // checkEdit_시가가볼린저401보다작음 + // groupBox5 // - this.checkEdit_시가가볼린저401보다작음.Location = new System.Drawing.Point(164, 97); - this.checkEdit_시가가볼린저401보다작음.Name = "checkEdit_시가가볼린저401보다작음"; - this.checkEdit_시가가볼린저401보다작음.Properties.Caption = "시가가 볼린저 40 1 보다 작음"; - this.checkEdit_시가가볼린저401보다작음.Size = new System.Drawing.Size(150, 19); - this.checkEdit_시가가볼린저401보다작음.TabIndex = 8; - this.checkEdit_시가가볼린저401보다작음.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + this.groupBox5.Controls.Add(this.checkEdit_종가시간판매); + this.groupBox5.Controls.Add(this.textEdit_종가시간판매); + this.groupBox5.Location = new System.Drawing.Point(19, 123); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(335, 100); + this.groupBox5.TabIndex = 11; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "데이터 변경 (봉 채우기 재필요)"; // // TestBoardForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(853, 297); + this.ClientSize = new System.Drawing.Size(1030, 497); this.Controls.Add(this.progressBar1); this.Controls.Add(this.simpleButton_찬); this.Controls.Add(this.groupBox3); @@ -264,6 +312,10 @@ namespace Million_Hunter.HunterSubForm this.Text = "TestBoard"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위_양봉.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit_종가시간판매.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_종가시간판매.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit(); @@ -275,8 +327,8 @@ namespace Million_Hunter.HunterSubForm ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit(); this.groupBox3.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).EndInit(); + this.groupBox4.ResumeLayout(false); + this.groupBox5.ResumeLayout(false); this.ResumeLayout(false); } @@ -303,5 +355,9 @@ namespace Million_Hunter.HunterSubForm private DevExpress.XtraEditors.CheckEdit checkEdit1; private DevExpress.XtraEditors.CheckEdit checkEdit_시가구름떼위에서시작; private DevExpress.XtraEditors.CheckEdit checkEdit_시가가볼린저401보다작음; + private DevExpress.XtraEditors.CheckEdit checkEdit_4시간_8시간구름떼위_양봉; + private DevExpress.XtraEditors.CheckEdit checkEdit_4시간_8시간구름떼위; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.GroupBox groupBox4; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index 3d50efa..f8634b2 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -94,6 +94,8 @@ namespace Million_Hunter.HunterSubForm var chartStartDate = startDate; var chartEndDate = endDate; + // Default : 1 시간 + // 추가 : 4, 8, switch (candleTypes.First()) { case CommonProperty.MCandleTimeType.H1: @@ -130,7 +132,13 @@ namespace Million_Hunter.HunterSubForm var dic = DataManager.GetStandardData(_chartIndicatorCoditionSetups, chartStartDate, chartEndDate, analysisData.OriginalSearchResult.MarketData , _chartIndicatorCoditionSetups, true, candleTypes); - if(analysisData.CandleDatas != null) + var dic_4 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H4); + var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8); + + dic.Add(CommonProperty.MCandleTimeType.H4, dic_4); + dic.Add(CommonProperty.MCandleTimeType.H8, dic_8); + + if (analysisData.CandleDatas != null) { analysisData.CandleDatas.Clear(); analysisData.CandleDatas = null; @@ -520,6 +528,84 @@ namespace Million_Hunter.HunterSubForm } } + if(checkEdit_4시간_8시간구름떼위.Checked) + { + foreach (var analysisData in parentForm._analysisDatas) + { + if (!analysisData.Inclusion) continue; + + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var data = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H1].Find(item => item.DateTime == startDate); + var data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(startDate, -4) <= item.DateTime && item.DateTime <= startDate); + if (data4 == null) + { + var dateT4 = new DateTime(); + dateT4 = startDate; + while (data4 == null) + { + data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(dateT4, -4) <= item.DateTime && item.DateTime <= dateT4); + dateT4 = changeDatetimeFormat(dateT4, -4); + } + } + var data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(startDate, -8) <= item.DateTime && item.DateTime <= startDate); + if (data8 == null) + { + var dateT8 = new DateTime(); + dateT8 = startDate; + while (data8 == null) + { + data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(dateT8, -8) <= item.DateTime && item.DateTime <= dateT8); + dateT8 = changeDatetimeFormat(dateT8, -8); + } + } + var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2); + var maxich4 = Math.Max(((IchimokData)data4.IndicatorDic["Ich2695226"]).value, ((IchimokData)data4.IndicatorDic["Ich2695226"]).value2); + var maxich8 = Math.Max(((IchimokData)data8.IndicatorDic["Ich2695226"]).value, ((IchimokData)data8.IndicatorDic["Ich2695226"]).value2); + + if(analysisData.Inclusion) + if (maxich8 >= data8.StartValue || maxich4 >= data4.StartValue) analysisData.Inclusion = false; + } + } + + if(checkEdit_4시간_8시간구름떼위_양봉.Checked) + { + foreach (var analysisData in parentForm._analysisDatas) + { + if (!analysisData.Inclusion) continue; + + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var data = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H1].Find(item => item.DateTime == startDate); + var data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(startDate, -4) <= item.DateTime && item.DateTime <= startDate); + if (data4 == null) + { + var dateT4 = new DateTime(); + dateT4 = startDate; + while (data4 == null) + { + data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(dateT4, -4) <= item.DateTime && item.DateTime <= dateT4); + dateT4 = changeDatetimeFormat(dateT4, -4); + } + } + var data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(startDate, -8) <= item.DateTime && item.DateTime <= startDate); + if (data8 == null) + { + var dateT8 = new DateTime(); + dateT8 = startDate; + while (data8 == null) + { + data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(dateT8, -8) <= item.DateTime && item.DateTime <= dateT8); + dateT8 = changeDatetimeFormat(dateT8, -8); + } + } + var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2); + var maxich4 = Math.Max(((IchimokData)data4.IndicatorDic["Ich2695226"]).value, ((IchimokData)data4.IndicatorDic["Ich2695226"]).value2); + var maxich8 = Math.Max(((IchimokData)data8.IndicatorDic["Ich2695226"]).value, ((IchimokData)data8.IndicatorDic["Ich2695226"]).value2); + + if (analysisData.Inclusion) + if (maxich8 >= data8.StartValue || maxich4 >= data4.StartValue) analysisData.Inclusion = false; + } + } + parentForm.CalcurateProfitAndWinRate(); parentForm.treeList_ResultData.RefreshDataSource(); } From dd264b0cc51bbe1a81332320680641e6b14db47e Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Wed, 17 May 2023 15:31:55 +0900 Subject: [PATCH 12/25] =?UTF-8?q?buyer=EC=97=90=20=EC=97=AC=EB=9F=AC=20MCa?= =?UTF-8?q?ndleTimeType=ED=98=B8=ED=99=98=20=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/Manager/DataManager.cs | 41 ++ Million/Manager/RealtimeDataSettingManager.cs | 370 ++++++++++-------- 2 files changed, 242 insertions(+), 169 deletions(-) diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 829a2f5..1ff1a8f 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -1,4 +1,5 @@ using Million.Data; +using Million.Data.Upbit; using Million.DbManagement; using Million.IndicatorConditionSetup; using System; @@ -399,9 +400,49 @@ namespace Million.Manager recentlyData.HighValue = recentlyData.HighValue < candleData.HighValue ? candleData.HighValue : recentlyData.HighValue; recentlyData.LowValue = recentlyData.LowValue < candleData.LowValue ? recentlyData.LowValue : candleData.LowValue; recentlyData.EndValue = candleData.EndValue; + recentlyData.RecentlyDataFlag = true; recentlyData.MoneyVolume += candleData.MoneyVolume; return recentlyData; } } + + /// + /// Tick List를 + /// + /// + /// + public static List GetOneMinuteCandleDataFromTickList(List tickList) + { + var returnData = new List(); + + var dateTimeList = tickList.Select(t => t.DateTime.Minute).Distinct().ToList(); + + foreach (var item in dateTimeList) + { + var list = tickList.Where(t => t.DateTime.Minute == item).ToList(); + if (list.Count > 0) + { + var valueList = list.Select(t => t.TradePrice).ToList(); + var startValue = list[0].TradePrice; + var endValue = list[list.Count - 1].TradePrice; + var highValue = valueList.Max(); + var lowValue = valueList.Min(); + var candle = new CandleData(); + candle.DateTime = list[0].DateTime; + candle.DateTime.AddSeconds(candle.DateTime.Second * -1); + candle.CandleTimeType = 1; + candle.StartValue = startValue; + candle.HighValue = highValue; + candle.LowValue = lowValue; + candle.RecentlyDataFlag = true; + candle.EndValue = endValue; + + returnData.Add(candle); + } + } + + return returnData; + } + } } diff --git a/Million/Manager/RealtimeDataSettingManager.cs b/Million/Manager/RealtimeDataSettingManager.cs index 419c4bc..c30343b 100644 --- a/Million/Manager/RealtimeDataSettingManager.cs +++ b/Million/Manager/RealtimeDataSettingManager.cs @@ -234,179 +234,210 @@ namespace Million.Manager tickList = cloneTickList.Where(t => t.CoinFullName == coinFullName).OrderBy(t=>t.DateTime).ToList(); - // 호출 당시 시, 분, 초 - var callH = basicDateTime.Hour; - var callM = basicDateTime.Minute; - var callS = basicDateTime.Second; - try + #region 여러 Type 다 호환 되도록 새로 구성 + /* + * 1. Tick -> 1분봉으로 모두 변환(시가는 제일 작은거로 처리 + * 2. 기존에 가지고 있는 봉 마지막꺼를 포함한 모든 데이터를 가지고 GetConvertCandleDataList로 처리 + * 3. 마지막 봉삭제 후 모두 Addrange + * 4. 이후 300개 이상일 경우 삭제 처리 + */ + + var returnList = DataManager.GetOneMinuteCandleDataFromTickList(tickList); + if(item.CandleDataLists_Im.Count > 0) { - if (type == MCandleTimeType.M1) - { - var equalMinuteList = tickList.Where(t => t.DateTime.Minute == callM).ToList(); - - //해당 분 고가 - if (equalMinuteList.Count != 0) - { - var equalListM = equalMinuteList.Select(t => t.TradePrice).ToList(); - double equalListMax = 0; - if (equalListM.Count != 0) - { - equalListMax = equalListM.Max(); - } - - //해당 분 저가 - var equalListL = equalMinuteList.Select(t => t.TradePrice).ToList(); - - double equalListMin = 0; - if (equalListL.Count != 0) - { - equalListMin = equalListL.Min(); - } - if (item.CandleDataLists_Im.Count != 0) - { - if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0) - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax; - if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0) - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin; - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true; - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice; - } - else - { - var candle = new CandleData(); - candle.CandleTimeType = (int)MCandleTimeType.M1; - candle.StartValue = equalMinuteList[0].TradePrice; - candle.HighValue = equalListMax; - candle.LowValue = equalListMin; - candle.RecentlyDataFlag = true; - candle.EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice; - var date = basicDateTime.AddMinutes(1); - date = date.AddSeconds(-1 * callS); - candle.DateTime = date; - if (item.CandleDataLists_Im.Count > 300) - item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300); - item.CandleDataLists_Im.Add(candle); - } - } - - var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Minute != basicDateTime.Minute).ToList(); - - if (list.Count > 0) - { - // 데이터 가져올떄 1분 이상 걸릴 시 처리할 데이터 - var minList = list.Select(t => t.DateTime.Minute).Distinct().ToList(); - minList.Sort(); - - foreach (var min in minList) - { - var equalList = list.Where(t => t.DateTime.Minute == min).OrderBy(t => t.DateTime).ToList(); - - //해당 분 고가 - var max = equalList.Select(t => t.TradePrice).ToList().Max(); - //해당 분 저가 - var low = equalList.Select(t => t.TradePrice).ToList().Min(); - - var candle = new CandleData(); - candle.CandleTimeType = (int)MCandleTimeType.M1; - candle.StartValue = equalList[0].TradePrice; - candle.HighValue = max; - candle.LowValue = low; - candle.RecentlyDataFlag = true; - candle.EndValue = equalList[equalList.Count - 1].TradePrice; - - var intervalMin = min - callM; - - var date = basicDateTime.AddMinutes(intervalMin); - if(intervalMin < 0) date = date.AddHours(1); - - date = date.AddSeconds(-1 * callS); - candle.DateTime = date; - if (item.CandleDataLists_Im.Count > 300) - item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300); - item.CandleDataLists_Im.Add(candle); - - } - } - } - else if (type == MCandleTimeType.H1) - { - var equalHourList = tickList.Where(t => t.DateTime.Hour == callH).ToList(); - if (equalHourList.Count != 0) - { - var equalListM = equalHourList.Select(t => t.TradePrice).ToList(); - double equalListMax = 0; - if (equalListM.Count != 0) - { - equalListMax = equalListM.Max(); - } - - //해당 분 저가 - var equalListL = equalHourList.Select(t => t.TradePrice).ToList(); - double equalListMin = 0; - if (equalListL.Count != 0) - { - equalListMin = equalListL.Min(); - } - if (item.CandleDataLists_Im.Count > 0) - { - if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0) - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax; - if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0) - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin; - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true; - item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalHourList[equalHourList.Count - 1].TradePrice; - } - else - { - var candle = new CandleData(); - candle.CandleTimeType = (int)MCandleTimeType.H1; - candle.StartValue = equalHourList[0].TradePrice; - candle.HighValue = equalListMax; - candle.LowValue = equalListMin; - candle.RecentlyDataFlag = true; - candle.EndValue = equalHourList[equalHourList.Count - 1].TradePrice; - - var date = basicDateTime.AddHours(1); - date = date.AddMinutes(-1 * callM); - date = date.AddSeconds(-1 * callS); - candle.DateTime = date; - if (item.CandleDataLists_Im.Count > 300) - item.CandleDataLists_Im.RemoveRange(0, 100); - item.CandleDataLists_Im.Add(candle); - } - } - - var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Hour != basicDateTime.Hour).ToList(); - if (list.Count > 0) - { - //해당 분 고가 - var max = list.Select(t => t.TradePrice).ToList().Max(); - //해당 분 저가 - var low = list.Select(t => t.TradePrice).ToList().Min(); - - var candle = new CandleData(); - candle.CandleTimeType = (int)MCandleTimeType.H1; - candle.StartValue = list[0].TradePrice; - candle.HighValue = max; - candle.LowValue = low; - candle.RecentlyDataFlag = true; - candle.EndValue = list[list.Count - 1].TradePrice; - - var date = basicDateTime.AddHours(1); - date = date.AddMinutes(-1 * callM); - date = date.AddSeconds(-1 * callS); - - candle.DateTime = date; - if (item.CandleDataLists_Im.Count > 300) - item.CandleDataLists_Im.RemoveRange(0, 100); - item.CandleDataLists_Im.Add(candle); - } - } + var lastData = item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1]; + returnList.Insert(0, lastData); } - catch (Exception e) + + var dataList = DataManager.GetConvertCandleDataList(returnList, type); + + if (item.CandleDataLists_Im.Count > 0) { - throw; + item.CandleDataLists_Im.Remove(item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1]); } + + item.CandleDataLists_Im.AddRange(dataList); + if(item.CandleDataLists_Im.Count > 150) + { + item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 150); + } + + #endregion + #region 옛날 소스 + //// 호출 당시 시, 분, 초 + //var callH = basicDateTime.Hour; + //var callM = basicDateTime.Minute; + //var callS = basicDateTime.Second; + //try + //{ + // if (type == MCandleTimeType.M1) + // { + // var equalMinuteList = tickList.Where(t => t.DateTime.Minute == callM).ToList(); + + // //해당 분 고가 + // if (equalMinuteList.Count != 0) + // { + // var equalListM = equalMinuteList.Select(t => t.TradePrice).ToList(); + // double equalListMax = 0; + // if (equalListM.Count != 0) + // { + // equalListMax = equalListM.Max(); + // } + + // //해당 분 저가 + // var equalListL = equalMinuteList.Select(t => t.TradePrice).ToList(); + + // double equalListMin = 0; + // if (equalListL.Count != 0) + // { + // equalListMin = equalListL.Min(); + // } + // if (item.CandleDataLists_Im.Count != 0) + // { + // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0) + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax; + // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0) + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin; + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true; + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice; + // } + // else + // { + // var candle = new CandleData(); + // candle.CandleTimeType = (int)MCandleTimeType.M1; + // candle.StartValue = equalMinuteList[0].TradePrice; + // candle.HighValue = equalListMax; + // candle.LowValue = equalListMin; + // candle.RecentlyDataFlag = true; + // candle.EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice; + // var date = basicDateTime.AddMinutes(1); + // date = date.AddSeconds(-1 * callS); + // candle.DateTime = date; + // if (item.CandleDataLists_Im.Count > 300) + // item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300); + // item.CandleDataLists_Im.Add(candle); + // } + // } + + // var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Minute != basicDateTime.Minute).ToList(); + + // if (list.Count > 0) + // { + // // 데이터 가져올떄 1분 이상 걸릴 시 처리할 데이터 + // var minList = list.Select(t => t.DateTime.Minute).Distinct().ToList(); + // minList.Sort(); + + // foreach (var min in minList) + // { + // var equalList = list.Where(t => t.DateTime.Minute == min).OrderBy(t => t.DateTime).ToList(); + + // //해당 분 고가 + // var max = equalList.Select(t => t.TradePrice).ToList().Max(); + // //해당 분 저가 + // var low = equalList.Select(t => t.TradePrice).ToList().Min(); + + // var candle = new CandleData(); + // candle.CandleTimeType = (int)MCandleTimeType.M1; + // candle.StartValue = equalList[0].TradePrice; + // candle.HighValue = max; + // candle.LowValue = low; + // candle.RecentlyDataFlag = true; + // candle.EndValue = equalList[equalList.Count - 1].TradePrice; + + // var intervalMin = min - callM; + + // var date = basicDateTime.AddMinutes(intervalMin); + // if(intervalMin < 0) date = date.AddHours(1); + + // date = date.AddSeconds(-1 * callS); + // candle.DateTime = date; + // if (item.CandleDataLists_Im.Count > 300) + // item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300); + // item.CandleDataLists_Im.Add(candle); + + // } + // } + // } + // else if (type == MCandleTimeType.H1) + // { + // var equalHourList = tickList.Where(t => t.DateTime.Hour == callH).ToList(); + // if (equalHourList.Count != 0) + // { + // var equalListM = equalHourList.Select(t => t.TradePrice).ToList(); + // double equalListMax = 0; + // if (equalListM.Count != 0) + // { + // equalListMax = equalListM.Max(); + // } + + // //해당 분 저가 + // var equalListL = equalHourList.Select(t => t.TradePrice).ToList(); + // double equalListMin = 0; + // if (equalListL.Count != 0) + // { + // equalListMin = equalListL.Min(); + // } + // if (item.CandleDataLists_Im.Count > 0) + // { + // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0) + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax; + // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0) + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin; + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true; + // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalHourList[equalHourList.Count - 1].TradePrice; + // } + // else + // { + // var candle = new CandleData(); + // candle.CandleTimeType = (int)MCandleTimeType.H1; + // candle.StartValue = equalHourList[0].TradePrice; + // candle.HighValue = equalListMax; + // candle.LowValue = equalListMin; + // candle.RecentlyDataFlag = true; + // candle.EndValue = equalHourList[equalHourList.Count - 1].TradePrice; + + // var date = basicDateTime.AddHours(1); + // date = date.AddMinutes(-1 * callM); + // date = date.AddSeconds(-1 * callS); + // candle.DateTime = date; + // if (item.CandleDataLists_Im.Count > 300) + // item.CandleDataLists_Im.RemoveRange(0, 100); + // item.CandleDataLists_Im.Add(candle); + // } + // } + + // var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Hour != basicDateTime.Hour).ToList(); + // if (list.Count > 0) + // { + // //해당 분 고가 + // var max = list.Select(t => t.TradePrice).ToList().Max(); + // //해당 분 저가 + // var low = list.Select(t => t.TradePrice).ToList().Min(); + + // var candle = new CandleData(); + // candle.CandleTimeType = (int)MCandleTimeType.H1; + // candle.StartValue = list[0].TradePrice; + // candle.HighValue = max; + // candle.LowValue = low; + // candle.RecentlyDataFlag = true; + // candle.EndValue = list[list.Count - 1].TradePrice; + + // var date = basicDateTime.AddHours(1); + // date = date.AddMinutes(-1 * callM); + // date = date.AddSeconds(-1 * callS); + + // candle.DateTime = date; + // if (item.CandleDataLists_Im.Count > 300) + // item.CandleDataLists_Im.RemoveRange(0, 100); + // item.CandleDataLists_Im.Add(candle); + // } + // } + //} + //catch (Exception e) + //{ + // throw; + //} + #endregion } //}); } @@ -457,3 +488,4 @@ namespace Million.Manager } } } +; \ No newline at end of file From 09d8ea63fbcea77e44e0e440bfd1b3f25e958f28 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Thu, 18 May 2023 14:50:10 +0900 Subject: [PATCH 13/25] =?UTF-8?q?StartValue=20Low=20Overlap=20Up=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=B2=98=EB=A6=AC=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EC=A3=BC=EC=84=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Buyer/MainForm.cs | 2 +- Million Hunter/HunterMainForm.cs | 10 ++++++---- Million Update Server/Form1.cs | 2 +- Million/CommonProperty.cs | 2 +- Million/Data/SaveData/MultiSavedResultData.cs | 2 ++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Million Buyer/MainForm.cs b/Million Buyer/MainForm.cs index bad211f..4e4e180 100644 --- a/Million Buyer/MainForm.cs +++ b/Million Buyer/MainForm.cs @@ -527,7 +527,7 @@ namespace Million_Buyer continue; } - if (StarValueLowOverlapUp) + if (StarValueLowBuyValueUp) { if (recentlyData.StartValue < beforeData.HighValue) { diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index 4e1e8f3..f0b043a 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -273,7 +273,7 @@ namespace Million // 조건 검색을 반영하여 데이터 계산 private void simpleButton_CalcurateData_Click(object sender, EventArgs e) { - CommonProperty.StarValueLowOverlapUp = cb_StarValueLowOverlapUp.Checked; + CommonProperty.StarValueLowBuyValueUp = cb_StarValueLowOverlapUp.Checked; // 계산 결과 데이터 관련 클래스에 값 채우기 DeafultDataSet(); @@ -617,7 +617,7 @@ namespace Million recentlyData.BuyValue = OrderbookManager.GetAskPrice(CalculateManager.GetConditionValue(buyScript.regularExpressionString, valDic, recentlyData.CalculateFlag)); // 이전 전봉(H1)의 고가가 사려는 가격보다 높을경우 pass - if (StarValueLowOverlapUp) + if (StarValueLowBuyValueUp) { if (recentlyData.StartValue < beforeData.HighValue) { @@ -1031,8 +1031,7 @@ namespace Million /// /// private void bt_CalculateList_Click(object sender, EventArgs e) - { - CommonProperty.StarValueLowOverlapUp = cb_StarValueLowOverlapUp.Checked; + { if (multiSavedResultDatas.Count > 0) { LogManager.WriteLog("헌터 리스트 계산 시작", "Hunter List 계산"); @@ -1040,6 +1039,8 @@ namespace Million foreach (var item in multiSavedResultDatas) { + CommonProperty.StarValueLowBuyValueUp = item.StarValueLowOverlapUp; + CalculateDatas(item.SavedResultData, item.UpperMainIndicatorFlag, item.IncludeClearIndicator, item.DownBeforeValueFlag, item.HunterMode); LogManager.WriteLog("헌터 리스트 계산 완료. Name : " + item.SavedResultData.Name, "Hunter List 계산"); @@ -1086,6 +1087,7 @@ namespace Million data.HunterMode = rd_Hunter.Checked; data.IncludeClearIndicator = cb_IncludeClearIndicator.Checked; data.UpperMainIndicatorFlag = cb_UpperMainIndi.Checked; + data.StarValueLowOverlapUp = cb_StarValueLowOverlapUp.Checked; multiSavedResultDatas.Add(data); MessageBox.Show("추가 완료"); diff --git a/Million Update Server/Form1.cs b/Million Update Server/Form1.cs index 7e54691..fefd1b0 100644 --- a/Million Update Server/Form1.cs +++ b/Million Update Server/Form1.cs @@ -74,7 +74,7 @@ namespace Million_Update_Server data += Encoding.UTF8.GetString(buffer, 0, bytesRead); } while (clientStream.DataAvailable); - var receivedPeople = JsonConvert.DeserializeObject(data); + //var receivedPeople = JsonConvert.DeserializeObject(data); diff --git a/Million/CommonProperty.cs b/Million/CommonProperty.cs index ab108da..143bbb4 100644 --- a/Million/CommonProperty.cs +++ b/Million/CommonProperty.cs @@ -370,7 +370,7 @@ namespace Million #region Realtime Hunter Flag public static bool RealtimeHunterMode = false; - public static bool StarValueLowOverlapUp = false; + public static bool StarValueLowBuyValueUp = false; #endregion #region Realtime 관련 Sub data 사용하는 부분예외처리 diff --git a/Million/Data/SaveData/MultiSavedResultData.cs b/Million/Data/SaveData/MultiSavedResultData.cs index cb927be..d7265f7 100644 --- a/Million/Data/SaveData/MultiSavedResultData.cs +++ b/Million/Data/SaveData/MultiSavedResultData.cs @@ -19,6 +19,8 @@ namespace Million.Data.SaveData public bool UpperMainIndicatorFlag { get; set; } + public bool StarValueLowOverlapUp { get; set; } + public bool IncludeClearIndicator { get; set; } public bool DownBeforeValueFlag { get; set; } From eee350d247d6733f094cf3d7b186ae127e972bf5 Mon Sep 17 00:00:00 2001 From: jwlee Date: Mon, 22 May 2023 11:53:10 +0900 Subject: [PATCH 14/25] =?UTF-8?q?=ED=85=8C=EC=8A=A4,=ED=8A=B8=20=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HunterSubForm/TestBoardForm.Designer.cs | 208 +++++++++++++++++- Million Hunter/HunterSubForm/TestBoardForm.cs | 194 ++++++++++++---- Million/CommonProperty.cs | 1 - Million/SubForm/ChartViewerUI.cs | 9 +- 4 files changed, 352 insertions(+), 60 deletions(-) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs index ee0356b..f346254 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs @@ -52,6 +52,20 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_찬 = new DevExpress.XtraEditors.SimpleButton(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.checkEdit_1H = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_4H = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_8H = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_12H = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_1D = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_15M = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_10M = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_5M = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_1M = new DevExpress.XtraEditors.CheckEdit(); + this.comboBoxEdit_defaultTime = new DevExpress.XtraEditors.ComboBoxEdit(); + this.checkEdit_구름떼돌파몇봉이내 = new DevExpress.XtraEditors.CheckEdit(); + this.textEdit_구름떼돌파몇봉이내 = new DevExpress.XtraEditors.TextEdit(); + this.checkEdit_시가볼린저40_1아래 = new DevExpress.XtraEditors.CheckEdit(); + this.checkEdit_시가구름떼위 = new DevExpress.XtraEditors.CheckEdit(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위_양봉.Properties)).BeginInit(); @@ -71,6 +85,20 @@ namespace Million_Hunter.HunterSubForm this.groupBox3.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_1H.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4H.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_8H.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_12H.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_1D.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_15M.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_10M.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_5M.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_1M.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_defaultTime.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼돌파몇봉이내.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_구름떼돌파몇봉이내.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가볼린저40_1아래.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위.Properties)).BeginInit(); this.SuspendLayout(); // // simpleButton_FullInsertCandle @@ -81,21 +109,35 @@ namespace Million_Hunter.HunterSubForm this.simpleButton_FullInsertCandle.Name = "simpleButton_FullInsertCandle"; this.simpleButton_FullInsertCandle.Size = new System.Drawing.Size(121, 32); this.simpleButton_FullInsertCandle.TabIndex = 1; - this.simpleButton_FullInsertCandle.Text = "1시간봉 다 채우기"; + this.simpleButton_FullInsertCandle.Text = "시간봉 다 채우기"; this.simpleButton_FullInsertCandle.Click += new System.EventHandler(this.simpleButton_FullInsertCandle_Click); // // groupBox1 // + this.groupBox1.Controls.Add(this.comboBoxEdit_defaultTime); + this.groupBox1.Controls.Add(this.checkEdit_15M); + this.groupBox1.Controls.Add(this.checkEdit_10M); + this.groupBox1.Controls.Add(this.checkEdit_5M); + this.groupBox1.Controls.Add(this.checkEdit_1M); this.groupBox1.Controls.Add(this.simpleButton_FullInsertCandle); + this.groupBox1.Controls.Add(this.checkEdit_1D); + this.groupBox1.Controls.Add(this.checkEdit_12H); + this.groupBox1.Controls.Add(this.checkEdit_8H); + this.groupBox1.Controls.Add(this.checkEdit_4H); + this.groupBox1.Controls.Add(this.checkEdit_1H); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(340, 63); + this.groupBox1.Size = new System.Drawing.Size(255, 126); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "데이터 채우기"; // // groupBox2 // + this.groupBox2.Controls.Add(this.checkEdit_시가구름떼위); + this.groupBox2.Controls.Add(this.checkEdit_시가볼린저40_1아래); + this.groupBox2.Controls.Add(this.textEdit_구름떼돌파몇봉이내); + this.groupBox2.Controls.Add(this.checkEdit_구름떼돌파몇봉이내); this.groupBox2.Controls.Add(this.groupBox5); this.groupBox2.Controls.Add(this.groupBox4); this.groupBox2.Controls.Add(this.checkEdit_시가가볼린저401보다작음); @@ -108,7 +150,7 @@ namespace Million_Hunter.HunterSubForm this.groupBox2.Controls.Add(this.checkEdit_구름떼상한선하락시판매); this.groupBox2.Controls.Add(this.checkEdit_구매이전봉볼린저40_1이하); this.groupBox2.Controls.Add(this.checkEdit_이전봉40_2볼린저이하); - this.groupBox2.Location = new System.Drawing.Point(12, 110); + this.groupBox2.Location = new System.Drawing.Point(12, 162); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(1006, 230); this.groupBox2.TabIndex = 3; @@ -261,10 +303,10 @@ namespace Million_Hunter.HunterSubForm // // progressBar1 // - this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar1.Location = new System.Drawing.Point(2, 474); + this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.progressBar1.Location = new System.Drawing.Point(0, 395); this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(1029, 23); + this.progressBar1.Size = new System.Drawing.Size(1030, 23); this.progressBar1.TabIndex = 5; // // simpleButton_찬 @@ -298,11 +340,135 @@ namespace Million_Hunter.HunterSubForm this.groupBox5.TabStop = false; this.groupBox5.Text = "데이터 변경 (봉 채우기 재필요)"; // + // checkEdit_1H + // + this.checkEdit_1H.Location = new System.Drawing.Point(6, 76); + this.checkEdit_1H.Name = "checkEdit_1H"; + this.checkEdit_1H.Properties.Caption = "1H"; + this.checkEdit_1H.Size = new System.Drawing.Size(43, 19); + this.checkEdit_1H.TabIndex = 9; + this.checkEdit_1H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_4H + // + this.checkEdit_4H.Location = new System.Drawing.Point(55, 76); + this.checkEdit_4H.Name = "checkEdit_4H"; + this.checkEdit_4H.Properties.Caption = "4H"; + this.checkEdit_4H.Size = new System.Drawing.Size(43, 19); + this.checkEdit_4H.TabIndex = 9; + this.checkEdit_4H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_8H + // + this.checkEdit_8H.Location = new System.Drawing.Point(104, 76); + this.checkEdit_8H.Name = "checkEdit_8H"; + this.checkEdit_8H.Properties.Caption = "8H"; + this.checkEdit_8H.Size = new System.Drawing.Size(43, 19); + this.checkEdit_8H.TabIndex = 9; + this.checkEdit_8H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_12H + // + this.checkEdit_12H.Location = new System.Drawing.Point(155, 76); + this.checkEdit_12H.Name = "checkEdit_12H"; + this.checkEdit_12H.Properties.Caption = "12H"; + this.checkEdit_12H.Size = new System.Drawing.Size(43, 19); + this.checkEdit_12H.TabIndex = 9; + this.checkEdit_12H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_1D + // + this.checkEdit_1D.Location = new System.Drawing.Point(6, 99); + this.checkEdit_1D.Name = "checkEdit_1D"; + this.checkEdit_1D.Properties.Caption = "1D"; + this.checkEdit_1D.Size = new System.Drawing.Size(43, 19); + this.checkEdit_1D.TabIndex = 9; + this.checkEdit_1D.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_15M + // + this.checkEdit_15M.Location = new System.Drawing.Point(155, 54); + this.checkEdit_15M.Name = "checkEdit_15M"; + this.checkEdit_15M.Properties.Caption = "15M"; + this.checkEdit_15M.Size = new System.Drawing.Size(43, 19); + this.checkEdit_15M.TabIndex = 11; + // + // checkEdit_10M + // + this.checkEdit_10M.Location = new System.Drawing.Point(104, 54); + this.checkEdit_10M.Name = "checkEdit_10M"; + this.checkEdit_10M.Properties.Caption = "10M"; + this.checkEdit_10M.Size = new System.Drawing.Size(43, 19); + this.checkEdit_10M.TabIndex = 12; + // + // checkEdit_5M + // + this.checkEdit_5M.Location = new System.Drawing.Point(55, 54); + this.checkEdit_5M.Name = "checkEdit_5M"; + this.checkEdit_5M.Properties.Caption = "5M"; + this.checkEdit_5M.Size = new System.Drawing.Size(43, 19); + this.checkEdit_5M.TabIndex = 13; + // + // checkEdit_1M + // + this.checkEdit_1M.Location = new System.Drawing.Point(6, 54); + this.checkEdit_1M.Name = "checkEdit_1M"; + this.checkEdit_1M.Properties.Caption = "1M"; + this.checkEdit_1M.Size = new System.Drawing.Size(43, 19); + this.checkEdit_1M.TabIndex = 14; + // + // comboBoxEdit_defaultTime + // + this.comboBoxEdit_defaultTime.Location = new System.Drawing.Point(133, 28); + this.comboBoxEdit_defaultTime.Name = "comboBoxEdit_defaultTime"; + this.comboBoxEdit_defaultTime.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.comboBoxEdit_defaultTime.Size = new System.Drawing.Size(100, 20); + this.comboBoxEdit_defaultTime.TabIndex = 15; + this.comboBoxEdit_defaultTime.SelectedIndexChanged += new System.EventHandler(this.comboBoxEdit_defaultTime_SelectedIndexChanged); + // + // checkEdit_구름떼돌파몇봉이내 + // + this.checkEdit_구름떼돌파몇봉이내.Location = new System.Drawing.Point(385, 138); + this.checkEdit_구름떼돌파몇봉이내.Name = "checkEdit_구름떼돌파몇봉이내"; + this.checkEdit_구름떼돌파몇봉이내.Properties.Caption = "구름떼 돌파 후 몇봉 이내"; + this.checkEdit_구름떼돌파몇봉이내.Size = new System.Drawing.Size(141, 19); + this.checkEdit_구름떼돌파몇봉이내.TabIndex = 12; + this.checkEdit_구름떼돌파몇봉이내.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // textEdit_구름떼돌파몇봉이내 + // + this.textEdit_구름떼돌파몇봉이내.EditValue = "0"; + this.textEdit_구름떼돌파몇봉이내.Location = new System.Drawing.Point(532, 137); + this.textEdit_구름떼돌파몇봉이내.Name = "textEdit_구름떼돌파몇봉이내"; + this.textEdit_구름떼돌파몇봉이내.Properties.Mask.EditMask = "d"; + this.textEdit_구름떼돌파몇봉이내.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; + this.textEdit_구름떼돌파몇봉이내.Size = new System.Drawing.Size(42, 20); + this.textEdit_구름떼돌파몇봉이내.TabIndex = 13; + // + // checkEdit_시가볼린저40_1아래 + // + this.checkEdit_시가볼린저40_1아래.Location = new System.Drawing.Point(385, 163); + this.checkEdit_시가볼린저40_1아래.Name = "checkEdit_시가볼린저40_1아래"; + this.checkEdit_시가볼린저40_1아래.Properties.Caption = "시가 볼린저40 1 아래"; + this.checkEdit_시가볼린저40_1아래.Size = new System.Drawing.Size(141, 19); + this.checkEdit_시가볼린저40_1아래.TabIndex = 14; + this.checkEdit_시가볼린저40_1아래.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // checkEdit_시가구름떼위 + // + this.checkEdit_시가구름떼위.Location = new System.Drawing.Point(385, 188); + this.checkEdit_시가구름떼위.Name = "checkEdit_시가구름떼위"; + this.checkEdit_시가구름떼위.Properties.Caption = "시가 구름 떼 위"; + this.checkEdit_시가구름떼위.Size = new System.Drawing.Size(141, 19); + this.checkEdit_시가구름떼위.TabIndex = 14; + this.checkEdit_시가구름떼위.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // // TestBoardForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1030, 497); + this.ClientSize = new System.Drawing.Size(1030, 418); this.Controls.Add(this.progressBar1); this.Controls.Add(this.simpleButton_찬); this.Controls.Add(this.groupBox3); @@ -329,6 +495,20 @@ namespace Million_Hunter.HunterSubForm this.groupBox3.ResumeLayout(false); this.groupBox4.ResumeLayout(false); this.groupBox5.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_1H.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_4H.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_8H.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_12H.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_1D.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_15M.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_10M.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_5M.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_1M.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_defaultTime.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼돌파몇봉이내.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_구름떼돌파몇봉이내.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가볼린저40_1아래.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위.Properties)).EndInit(); this.ResumeLayout(false); } @@ -359,5 +539,19 @@ namespace Million_Hunter.HunterSubForm private DevExpress.XtraEditors.CheckEdit checkEdit_4시간_8시간구름떼위; private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.GroupBox groupBox4; + private DevExpress.XtraEditors.CheckEdit checkEdit_15M; + private DevExpress.XtraEditors.CheckEdit checkEdit_10M; + private DevExpress.XtraEditors.CheckEdit checkEdit_5M; + private DevExpress.XtraEditors.CheckEdit checkEdit_1M; + private DevExpress.XtraEditors.CheckEdit checkEdit_1D; + private DevExpress.XtraEditors.CheckEdit checkEdit_12H; + private DevExpress.XtraEditors.CheckEdit checkEdit_8H; + private DevExpress.XtraEditors.CheckEdit checkEdit_4H; + private DevExpress.XtraEditors.CheckEdit checkEdit_1H; + private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit_defaultTime; + private DevExpress.XtraEditors.CheckEdit checkEdit_구름떼돌파몇봉이내; + private DevExpress.XtraEditors.TextEdit textEdit_구름떼돌파몇봉이내; + private DevExpress.XtraEditors.CheckEdit checkEdit_시가구름떼위; + private DevExpress.XtraEditors.CheckEdit checkEdit_시가볼린저40_1아래; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index f8634b2..adebd64 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -34,6 +34,10 @@ namespace Million_Hunter.HunterSubForm parentForm = resultViewerForm; analysisDatas = parentForm._analysisDatas; + // 시간 단위 가져오기 + var candleTimeTypeList = Enum.GetNames(enumType: typeof(CommonProperty.MCandleTimeType)); + comboBoxEdit_defaultTime.Properties.Items.AddRange(candleTimeTypeList); + comboBoxEdit_defaultTime.SelectedText = "H1"; } @@ -80,10 +84,15 @@ namespace Million_Hunter.HunterSubForm }); #endregion - MCandleTimeType = candleTypes.First(); + /* + Enum.TryParse(comboBoxEdit_defaultTime.SelectedItem.ToString(), + out CommonProperty.MCandleTimeType mCandleTimeType); + */ + + MCandleTimeType = CommonProperty.MCandleTimeType.H1; //차트 Date Time 설정하기 - var StartDateInterval = 60; + var StartDateInterval = 60 * 30; var EndDateInterval = 100; foreach(var analysisData in parentForm._analysisDatas) @@ -116,10 +125,10 @@ namespace Million_Hunter.HunterSubForm chartEndDate = startDate + new TimeSpan(0, 0, EndDateInterval, 0); break; case CommonProperty.MCandleTimeType.M10: - case CommonProperty.MCandleTimeType.M15: + case CommonProperty.MCandleTimeType.M5: case CommonProperty.MCandleTimeType.M3: case CommonProperty.MCandleTimeType.M30: - case CommonProperty.MCandleTimeType.M5: + case CommonProperty.MCandleTimeType.M15: break; case CommonProperty.MCandleTimeType.D1: chartStartDate = startDate - new TimeSpan(StartDateInterval, 0, 0, 0); @@ -133,10 +142,14 @@ namespace Million_Hunter.HunterSubForm , _chartIndicatorCoditionSetups, true, candleTypes); var dic_4 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H4); - var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8); + //var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8); + //var dic_12 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H12); + //var dic_1d = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.D1); - dic.Add(CommonProperty.MCandleTimeType.H4, dic_4); - dic.Add(CommonProperty.MCandleTimeType.H8, dic_8); + //dic.Add(CommonProperty.MCandleTimeType.H4, dic_4); + //dic.Add(CommonProperty.MCandleTimeType.H8, dic_8); + //dic.Add(CommonProperty.MCandleTimeType.H12, dic_12); + //dic.Add(CommonProperty.MCandleTimeType.D1, dic_1d); if (analysisData.CandleDatas != null) { @@ -185,7 +198,6 @@ namespace Million_Hunter.HunterSubForm public void calcurateFilter() { - // 필터 초기화 resetFilter(); @@ -284,6 +296,10 @@ namespace Million_Hunter.HunterSubForm analysisData.Inclusion = false; } + } + else + { + } } } @@ -302,60 +318,35 @@ namespace Million_Hunter.HunterSubForm foreach (var analysisData in parentForm._analysisDatas) { + if (!analysisData.Inclusion) continue; var startDate = changeDatetimeFormat(analysisData.StartDate, 0); var endDate = changeDatetimeFormat(analysisData.EndDate, 0); - var candleData = analysisData.CandleDatas.First().Value.Find(item => item.DateTime >= startDate && - item.IndicatorDic["Ich2695226"]?.value != null && item.IndicatorDic["Ich2695226"]?.value > item.LowValue); + var candleData = analysisData.CandleDatas.First().Value.Find(item => item.DateTime > startDate && item.DateTime < endDate && + item.IndicatorDic["Ich2695226"]?.value != null && ((IchimokData)item.IndicatorDic["Ich2695226"]).GetOverValue() > item.LowValue); - - if(candleData != null) + if (candleData != null) { var endResut = changeDatetimeFormat(candleData.DateTime, 0); var ichValue = ((IchimokData)candleData.IndicatorDic["Ich2695226"]).GetOverValue(); - // 판매 시간 이전에 하락 시 다시 계산 - if (endDate > endResut) + if (ichValue > analysisData.BuyValue) { - // 수익이면 - if (analysisData.BuyValue > ichValue) - { - winRate++; - count__++; - } - - //var profitRate1 = profitRate1 + (-100 + (Convert.ToDouble(ichValue) / Convert.ToDouble(analysisData.BuyValue) * 100)); - profitRate += -1 * ((analysisData.BuyValue - ichValue) / analysisData.BuyValue * 100); - + analysisData.WinFlag = true; } else { - if (analysisData.WinFlag) - { - winRate++; - count_2++; - } - - profitRate = profitRate + analysisData.EarningRate; + analysisData.WinFlag = false; } - } - else - { - if(startDate != endDate) + + analysisData.EarningRate = analysisData.EarningRate = (-100 + (ichValue / analysisData.BuyValue) * 100); + + if (analysisData.EarningRate < -4) { } - - if (analysisData.WinFlag) - { - count_2++; - winRate++; - } - else { } - - profitRate = profitRate + analysisData.EarningRate; } } @@ -597,15 +588,117 @@ namespace Million_Hunter.HunterSubForm dateT8 = changeDatetimeFormat(dateT8, -8); } } + var data12 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H12].Find(item => changeDatetimeFormat(startDate, -12) <= item.DateTime && item.DateTime <= startDate); + if (data12 == null) + { + var dateT12 = new DateTime(); + dateT12 = startDate; + while (data12 == null) + { + data12 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H12].Find(item => changeDatetimeFormat(dateT12, -12) <= item.DateTime && item.DateTime <= dateT12); + dateT12 = changeDatetimeFormat(dateT12, -12); + } + } + var data24 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.D1].Find(item => changeDatetimeFormat(startDate, -24) <= item.DateTime && item.DateTime <= startDate); + if (data24 == null) + { + var dateT24 = new DateTime(); + dateT24 = startDate; + while (data24 == null) + { + data24 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.D1].Find(item => changeDatetimeFormat(dateT24, -24) <= item.DateTime && item.DateTime <= dateT24); + dateT24 = changeDatetimeFormat(dateT24, -24); + } + } + var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2); var maxich4 = Math.Max(((IchimokData)data4.IndicatorDic["Ich2695226"]).value, ((IchimokData)data4.IndicatorDic["Ich2695226"]).value2); var maxich8 = Math.Max(((IchimokData)data8.IndicatorDic["Ich2695226"]).value, ((IchimokData)data8.IndicatorDic["Ich2695226"]).value2); + var maxich12 = Math.Max(((IchimokData)data12.IndicatorDic["Ich2695226"]).value, ((IchimokData)data12.IndicatorDic["Ich2695226"]).value2); + var maxichD1 = Math.Max(((IchimokData)data24.IndicatorDic["Ich2695226"]).value, ((IchimokData)data24.IndicatorDic["Ich2695226"]).value2); if (analysisData.Inclusion) - if (maxich8 >= data8.StartValue || maxich4 >= data4.StartValue) analysisData.Inclusion = false; + { + if (!(maxichD1 < data24.StartValue && maxich12 < data12.StartValue && maxich8 < data8.StartValue && maxich4 < data4.StartValue + //&& data12.IndicatorDic["Bol401"].value < data12.StartValue + // && data8.IndicatorDic["Bol401"].value < data8.StartValue + // && data4.IndicatorDic["Bol401"].value < data4.StartValue + )) analysisData.Inclusion = false; + } + } } + if(checkEdit_구름떼돌파몇봉이내.Checked) + { + var timeInterval = Convert.ToInt32(textEdit_구름떼돌파몇봉이내.Text); + + foreach (var analysisData in parentForm._analysisDatas) + { + if (analysisData.Inclusion) + { + var 몇봉이내이전봉시간 = changeDatetimeFormat(analysisData.StartDate, -timeInterval -1); + var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == 몇봉이내이전봉시간); + if (data == null) + { + analysisData.Description += "데이터 없음" + analysisData.Description; + continue; + } + + var ichData = (IchimokData)data.IndicatorDic["Ich2695226"]; + if (data.HighValue < Math.Max(ichData.value2, ichData.value2)) + { + analysisData.Inclusion = true; + } + else analysisData.Inclusion = false; + + } + } + } + + if (checkEdit_시가볼린저40_1아래.Checked) + { + foreach (var analysisData in parentForm._analysisDatas) + { + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate); + if (data == null) + { + analysisData.Description += "데이터 없음" + analysisData.Description; + continue; + } + + if (analysisData.Inclusion) + { + if (data.StartValue < data.IndicatorDic["Bol401"].value) analysisData.Inclusion = true; + else analysisData.Inclusion = false; + } + } + } + + if (checkEdit_시가구름떼위.Checked) + { + foreach (var analysisData in parentForm._analysisDatas) + { + var startDate = changeDatetimeFormat(analysisData.StartDate, 0); + var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate); + if (data == null) + { + analysisData.Description += "데이터 없음" + analysisData.Description; + continue; + } + + if (analysisData.Inclusion) + { + var ichData = (IchimokData)data.IndicatorDic["Ich2695226"]; + + if (data.StartValue > Math.Max(ichData.value, ichData.value2)) analysisData.Inclusion = true; + else analysisData.Inclusion = false; + } + } + } + + parentForm.CalcurateProfitAndWinRate(); parentForm.treeList_ResultData.RefreshDataSource(); } @@ -632,10 +725,10 @@ namespace Million_Hunter.HunterSubForm case CommonProperty.MCandleTimeType.M1: break; case CommonProperty.MCandleTimeType.M10: - case CommonProperty.MCandleTimeType.M15: + case CommonProperty.MCandleTimeType.M5: case CommonProperty.MCandleTimeType.M3: case CommonProperty.MCandleTimeType.M30: - case CommonProperty.MCandleTimeType.M5: + case CommonProperty.MCandleTimeType.M15: break; case CommonProperty.MCandleTimeType.D1: _dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd")) + new TimeSpan(StartDateInterval, 0, 0, 0); @@ -743,5 +836,12 @@ namespace Million_Hunter.HunterSubForm aver.ToString(); } + + private void comboBoxEdit_defaultTime_SelectedIndexChanged(object sender, EventArgs e) + { + Enum.TryParse(comboBoxEdit_defaultTime.SelectedItem.ToString(), + out CommonProperty.MCandleTimeType mCandleTimeType); + + } } } \ No newline at end of file diff --git a/Million/CommonProperty.cs b/Million/CommonProperty.cs index ab108da..7756f50 100644 --- a/Million/CommonProperty.cs +++ b/Million/CommonProperty.cs @@ -143,7 +143,6 @@ namespace Million M5 = 5, M6 = 6, M10 = 10, - M12 = 12, M15 = 15, M20 = 20, M30 = 30, diff --git a/Million/SubForm/ChartViewerUI.cs b/Million/SubForm/ChartViewerUI.cs index 8338350..f2530c7 100644 --- a/Million/SubForm/ChartViewerUI.cs +++ b/Million/SubForm/ChartViewerUI.cs @@ -82,10 +82,10 @@ namespace Million.SubForm visualRangeStartValueFix = new TimeSpan(0, 0, 1, 0); break; case CommonProperty.MCandleTimeType.M10: - case CommonProperty.MCandleTimeType.M15: + case CommonProperty.MCandleTimeType.M5: case CommonProperty.MCandleTimeType.M3: case CommonProperty.MCandleTimeType.M30: - case CommonProperty.MCandleTimeType.M5: + case CommonProperty.MCandleTimeType.M15: visualRangeStartValueFix = new TimeSpan(0, 0, 1, 0); break; case CommonProperty.MCandleTimeType.D1: @@ -145,12 +145,11 @@ namespace Million.SubForm diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Hour; viewRangeEndDate = startTime + new TimeSpan(0, setTimeInterval, 0, 0); break; - case CommonProperty.MCandleTimeType.M1: case CommonProperty.MCandleTimeType.M10: - case CommonProperty.MCandleTimeType.M15: + case CommonProperty.MCandleTimeType.M5: case CommonProperty.MCandleTimeType.M3: case CommonProperty.MCandleTimeType.M30: - case CommonProperty.MCandleTimeType.M5: + case CommonProperty.MCandleTimeType.M15: diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Minute; viewRangeEndDate = startTime + new TimeSpan(0, 0, setTimeInterval, 0); break; From 54c78cf09eee1e4756f794b7547012160e954f78 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1A3P75F\\lee" Date: Mon, 22 May 2023 13:01:48 +0900 Subject: [PATCH 15/25] =?UTF-8?q?GetConvertCandleDataList=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/Manager/DataManager.cs | 99 +++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 1ff1a8f..30cc4a8 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -221,6 +221,51 @@ namespace Million.Manager return result; } + private static CandleData CreateCandleData( CandleData candle,int timeFlagValue, string timeFlag) + { + var firstData = candle; + if (timeFlag == "minute") + { + var minute = firstData.DateTime.Minute / timeFlagValue * timeFlagValue; + return new CandleData() + { + DateTime = new DateTime(firstData.DateTime.Year, firstData.DateTime.Month, firstData.DateTime.Day, firstData.DateTime.Hour, minute, 0), + HighValue = firstData.HighValue, + StartValue = firstData.StartValue, + LowValue = firstData.LowValue, + EndValue = firstData.EndValue, + MoneyVolume = firstData.MoneyVolume + }; + } + else if (timeFlag == "hour") + { + var hour = firstData.DateTime.Hour / timeFlagValue * timeFlagValue; + return new CandleData() + { + DateTime = new DateTime(firstData.DateTime.Year, firstData.DateTime.Month, firstData.DateTime.Day, hour, 0, 0), + HighValue = firstData.HighValue, + StartValue = firstData.StartValue, + LowValue = firstData.LowValue, + EndValue = firstData.EndValue, + MoneyVolume = firstData.MoneyVolume + }; + } + else //if (timeFlag == "day") + { + //var hour = firstData.DateTime.Day / timeFlagValue * timeFlagValue; + return new CandleData() + { + DateTime = new DateTime(firstData.DateTime.Year, firstData.DateTime.Month, firstData.DateTime.Day, 0, 0, 0), + HighValue = firstData.HighValue, + StartValue = firstData.StartValue, + LowValue = firstData.LowValue, + EndValue = firstData.EndValue, + MoneyVolume = firstData.MoneyVolume + }; + + } + } + /// /// CandleList 만들어주는거 @@ -249,56 +294,46 @@ namespace Million.Manager timeFlagValue = 1; } - var firstFlag = true; + if (currentCandleList == null || currentCandleList.Count == 0) + return null; - foreach(var item in currentCandleList) + var firstData = currentCandleList.FirstOrDefault(); + returnData.Add(CreateCandleData(firstData, timeFlagValue, timeFlag)); + + foreach (var item in currentCandleList) { var flag = false; var recentlyData = returnData.LastOrDefault(); - if (recentlyData != null) + var coverTime = recentlyData.DateTime; + if (timeFlag == "minute") { - if (timeFlag == "minute") + coverTime.AddMinutes(timeFlagValue); + } + else if (timeFlag == "hour") + { + coverTime.AddHours(timeFlagValue); + if (item.DateTime.Hour % timeFlagValue == 0) { - if (item.DateTime.Minute % timeFlagValue == 0) - { - if (recentlyData.DateTime.Minute != item.DateTime.Minute) - flag = true; - } - } - else if (timeFlag == "hour") - { - if (item.DateTime.Hour % timeFlagValue == 0) - { - if (recentlyData.DateTime.Hour != item.DateTime.Hour) - flag = true; - } - } - else if(timeFlag == "day") - { - if (recentlyData.DateTime.Day != item.DateTime.Day) + if (recentlyData.DateTime.Hour != item.DateTime.Hour) flag = true; } } - - if (firstFlag) + else if (timeFlag == "day") { - firstFlag = false; - flag = true; + coverTime.AddDays(timeFlagValue); } - //새로 생성 - if (flag) + if (!(recentlyData.DateTime < item.DateTime && item.DateTime < coverTime)) { - returnData.Add(item); + returnData.Add(CreateCandleData(item, timeFlagValue, timeFlag)); + continue; } - //기존 데이터 엎어쓰기 - else - { + + recentlyData.HighValue = recentlyData.HighValue < item.HighValue ? item.HighValue : recentlyData.HighValue; recentlyData.LowValue = recentlyData.LowValue < item.LowValue ? recentlyData.LowValue : item.LowValue; recentlyData.EndValue = item.EndValue; recentlyData.MoneyVolume += item.MoneyVolume; - } } From 437f66957f881054cea43ead0e1113074565d06d Mon Sep 17 00:00:00 2001 From: "DESKTOP-1A3P75F\\lee" Date: Mon, 22 May 2023 13:03:57 +0900 Subject: [PATCH 16/25] =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EC=9E=84=EC=8B=9C?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/Manager/DataManager.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 30cc4a8..59b38e1 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -312,11 +312,6 @@ namespace Million.Manager else if (timeFlag == "hour") { coverTime.AddHours(timeFlagValue); - if (item.DateTime.Hour % timeFlagValue == 0) - { - if (recentlyData.DateTime.Hour != item.DateTime.Hour) - flag = true; - } } else if (timeFlag == "day") { From 2c300a5608c100fc3023ab9b005eebc7bbbbe45b Mon Sep 17 00:00:00 2001 From: "DESKTOP-1A3P75F\\lee" Date: Mon, 22 May 2023 13:55:31 +0900 Subject: [PATCH 17/25] =?UTF-8?q?=EC=9D=BC=EB=B6=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterSubForm/TestBoardForm.cs | 6 ++++++ Million/Manager/DataManager.cs | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index adebd64..922de49 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -142,6 +142,12 @@ namespace Million_Hunter.HunterSubForm , _chartIndicatorCoditionSetups, true, candleTypes); var dic_4 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H4); + var indicatorSetUpList = _chartIndicatorCoditionSetups.Where(t => t.MCandleTimeType == CommonProperty.MCandleTimeType.H4).ToList(); + foreach (var setup in indicatorSetUpList) + { + setup.excute(dic_4); + } + //var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8); //var dic_12 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H12); //var dic_1d = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.D1); diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 59b38e1..90afc66 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -297,13 +297,16 @@ namespace Million.Manager if (currentCandleList == null || currentCandleList.Count == 0) return null; - var firstData = currentCandleList.FirstOrDefault(); - returnData.Add(CreateCandleData(firstData, timeFlagValue, timeFlag)); foreach (var item in currentCandleList) { - var flag = false; var recentlyData = returnData.LastOrDefault(); + if(recentlyData == null) + { + returnData.Add(CreateCandleData(item, timeFlagValue, timeFlag)); + continue; + } + var coverTime = recentlyData.DateTime; if (timeFlag == "minute") { @@ -325,10 +328,10 @@ namespace Million.Manager } - recentlyData.HighValue = recentlyData.HighValue < item.HighValue ? item.HighValue : recentlyData.HighValue; - recentlyData.LowValue = recentlyData.LowValue < item.LowValue ? recentlyData.LowValue : item.LowValue; - recentlyData.EndValue = item.EndValue; - recentlyData.MoneyVolume += item.MoneyVolume; + recentlyData.HighValue = recentlyData.HighValue < item.HighValue ? item.HighValue : recentlyData.HighValue; + recentlyData.LowValue = recentlyData.LowValue < item.LowValue ? recentlyData.LowValue : item.LowValue; + recentlyData.EndValue = item.EndValue; + recentlyData.MoneyVolume += item.MoneyVolume; } From 2d0355a5cb286507f2039c0d3022fb5362a8825d Mon Sep 17 00:00:00 2001 From: jwlee Date: Tue, 23 May 2023 09:27:20 +0900 Subject: [PATCH 18/25] =?UTF-8?q?GetConvertCandleDataList=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterSubForm/TestBoardForm.cs | 42 ++++++++++++------- Million/Manager/DataManager.cs | 6 +-- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index 922de49..34d6da9 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -92,7 +92,7 @@ namespace Million_Hunter.HunterSubForm MCandleTimeType = CommonProperty.MCandleTimeType.H1; //차트 Date Time 설정하기 - var StartDateInterval = 60 * 30; + var StartDateInterval = 80 * 30; var EndDateInterval = 100; foreach(var analysisData in parentForm._analysisDatas) @@ -142,20 +142,33 @@ namespace Million_Hunter.HunterSubForm , _chartIndicatorCoditionSetups, true, candleTypes); var dic_4 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H4); - var indicatorSetUpList = _chartIndicatorCoditionSetups.Where(t => t.MCandleTimeType == CommonProperty.MCandleTimeType.H4).ToList(); - foreach (var setup in indicatorSetUpList) + foreach (var setup in _chartIndicatorCoditionSetups) { setup.excute(dic_4); } - //var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8); - //var dic_12 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H12); - //var dic_1d = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.D1); + var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8); + foreach (var setup in _chartIndicatorCoditionSetups) + { + setup.excute(dic_8); + } - //dic.Add(CommonProperty.MCandleTimeType.H4, dic_4); - //dic.Add(CommonProperty.MCandleTimeType.H8, dic_8); - //dic.Add(CommonProperty.MCandleTimeType.H12, dic_12); - //dic.Add(CommonProperty.MCandleTimeType.D1, dic_1d); + var dic_12 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H12); + foreach (var setup in _chartIndicatorCoditionSetups) + { + setup.excute(dic_12); + } + + var dic_1d = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.D1); + foreach (var setup in _chartIndicatorCoditionSetups) + { + setup.excute(dic_1d); + } + + dic.Add(CommonProperty.MCandleTimeType.H4, dic_4); + dic.Add(CommonProperty.MCandleTimeType.H8, dic_8); + dic.Add(CommonProperty.MCandleTimeType.H12, dic_12); + dic.Add(CommonProperty.MCandleTimeType.D1, dic_1d); if (analysisData.CandleDatas != null) { @@ -621,14 +634,15 @@ namespace Million_Hunter.HunterSubForm var maxich4 = Math.Max(((IchimokData)data4.IndicatorDic["Ich2695226"]).value, ((IchimokData)data4.IndicatorDic["Ich2695226"]).value2); var maxich8 = Math.Max(((IchimokData)data8.IndicatorDic["Ich2695226"]).value, ((IchimokData)data8.IndicatorDic["Ich2695226"]).value2); var maxich12 = Math.Max(((IchimokData)data12.IndicatorDic["Ich2695226"]).value, ((IchimokData)data12.IndicatorDic["Ich2695226"]).value2); - var maxichD1 = Math.Max(((IchimokData)data24.IndicatorDic["Ich2695226"]).value, ((IchimokData)data24.IndicatorDic["Ich2695226"]).value2); + //var maxichD1 = Math.Max(((IchimokData)data24.IndicatorDic["Ich2695226"]).value, ((IchimokData)data24.IndicatorDic["Ich2695226"]).value2); if (analysisData.Inclusion) { - if (!(maxichD1 < data24.StartValue && maxich12 < data12.StartValue && maxich8 < data8.StartValue && maxich4 < data4.StartValue + //if (!(maxichD1 < data24.StartValue && maxich12 < data12.StartValue && maxich8 < data8.StartValue && maxich4 < data4.StartValue + if(!(maxich12 < data12.StartValue && maxich8 < data8.StartValue && maxich4 < data4.StartValue //&& data12.IndicatorDic["Bol401"].value < data12.StartValue - // && data8.IndicatorDic["Bol401"].value < data8.StartValue - // && data4.IndicatorDic["Bol401"].value < data4.StartValue + // && data8.IndicatorDic["Bol401"].value < data8.StartValue + // && data4.IndicatorDic["Bol401"].value < data4.StartValue )) analysisData.Inclusion = false; } diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 90afc66..d9737a0 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -310,15 +310,15 @@ namespace Million.Manager var coverTime = recentlyData.DateTime; if (timeFlag == "minute") { - coverTime.AddMinutes(timeFlagValue); + coverTime = coverTime.AddMinutes(timeFlagValue); } else if (timeFlag == "hour") { - coverTime.AddHours(timeFlagValue); + coverTime = coverTime.AddHours(timeFlagValue); } else if (timeFlag == "day") { - coverTime.AddDays(timeFlagValue); + coverTime = coverTime.AddDays(timeFlagValue); } if (!(recentlyData.DateTime < item.DateTime && item.DateTime < coverTime)) From 41b38948a06ca06c99025f5cb790c74a56e17634 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 23 May 2023 09:29:24 +0900 Subject: [PATCH 19/25] =?UTF-8?q?80=EA=B0=9C=EC=88=98=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/DbMangement/DBServiceFunctions.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Million/DbMangement/DBServiceFunctions.cs b/Million/DbMangement/DBServiceFunctions.cs index e9f9f66..96a404d 100644 --- a/Million/DbMangement/DBServiceFunctions.cs +++ b/Million/DbMangement/DBServiceFunctions.cs @@ -220,20 +220,20 @@ namespace Million.DbManagement if (candleTimeType == MCandleTimeType.M1 || candleTimeType == MCandleTimeType.M3 || candleTimeType == MCandleTimeType.M5 || candleTimeType == MCandleTimeType.M10 | candleTimeType == MCandleTimeType.M15|| candleTimeType == MCandleTimeType.M30) - startDate = startDate.AddMinutes(-72 * (int)candleTimeType); + startDate = startDate.AddMinutes(-80 * (int)candleTimeType); else if(candleTimeType == MCandleTimeType.H1 | candleTimeType == MCandleTimeType.H4) { var val = 1; if (candleTimeType == MCandleTimeType.H4) val = 4; - startDate = startDate.AddHours(-72 * val); + startDate = startDate.AddHours(-80 * val); } else if(candleTimeType == MCandleTimeType.D1) - startDate = startDate.AddDays(-72 * 1); + startDate = startDate.AddDays(-80 * 1); else if (candleTimeType == MCandleTimeType.W1) - startDate = startDate.AddDays(-72 * 7); + startDate = startDate.AddDays(-80 * 7); else if (candleTimeType == MCandleTimeType.MT1) - startDate = startDate.AddMonths(-72); + startDate = startDate.AddMonths(-80); var sqlQuery = string.Format(@"SELECT [DateTime],[StartValue],[EndValue],[HighValue],[LowValue],[MoneyVolume],[CandleTimeType] FROM [{0}] WHERE [DateTime] >= '{1}' AND [DateTime] < '{2}' AND [CandleTimeType] = {3} ORDER BY [DateTime] ASC", marketData.CoinFullName, startDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"), (int)candleTimeType); @@ -265,20 +265,20 @@ namespace Million.DbManagement if (candleTimeType == MCandleTimeType.M1 || candleTimeType == MCandleTimeType.M3 || candleTimeType == MCandleTimeType.M5 || candleTimeType == MCandleTimeType.M10 | candleTimeType == MCandleTimeType.M15 || candleTimeType == MCandleTimeType.M30) - startDate = startDate.AddMinutes(-72 * (int)candleTimeType); + startDate = startDate.AddMinutes(-80 * (int)candleTimeType); else if (candleTimeType == MCandleTimeType.H1 | candleTimeType == MCandleTimeType.H4) { var val = 1; if (candleTimeType == MCandleTimeType.H4) val = 4; - startDate = startDate.AddHours(-72 * val); + startDate = startDate.AddHours(-80 * val); } else if (candleTimeType == MCandleTimeType.D1) - startDate = startDate.AddDays(-72 * 1); + startDate = startDate.AddDays(-80 * 1); else if (candleTimeType == MCandleTimeType.W1) - startDate = startDate.AddDays(-72 * 7); + startDate = startDate.AddDays(-80 * 7); else if (candleTimeType == MCandleTimeType.MT1) - startDate = startDate.AddMonths(-72); + startDate = startDate.AddMonths(-80); var sqlQuery = string.Format(@"SELECT TOP({0}) [DateTime],[StartValue],[EndValue],[HighValue],[LowValue],[MoneyVolume],[CandleTimeType] FROM [{1}] WHERE [DateTime] >= '{2}' AND [CandleTimeType] = {3} ORDER BY [DateTime] ASC", count, marketData.CoinFullName, startDate.ToString("yyyy-MM-dd HH:mm:ss"), ((int)candleTimeType).ToString()); From 0f20d55d3fc66a6f3375ef54490c5fcd62833aa4 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Wed, 24 May 2023 09:54:33 +0900 Subject: [PATCH 20/25] =?UTF-8?q?1=EB=B6=84=EB=B4=89=201=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=EB=B4=89=20=EC=A0=9C=EC=99=B8=ED=95=98=EA=B3=A0=20=EB=8B=A4?= =?UTF-8?q?=EB=A5=B8=20=EB=B4=89=EB=A7=8C=20=EB=A7=8C=EB=93=A4=EC=88=98?= =?UTF-8?q?=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterMainForm.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index f0b043a..5e5e0a1 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -497,6 +497,8 @@ namespace Million if (candleTimeType >= MCandleTimeType.H1) candleDataList = standardData[MCandleTimeType.H1]; + if (candleTimeType == MCandleTimeType.M1 || candleTimeType == MCandleTimeType.H1) continue; + standardData[candleTimeType] = DataManager.GetConvertCandleDataList(candleDataList, candleTimeType); } From 6a95cdfb1460e01024d17e838906e28d7c553bd9 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Wed, 24 May 2023 16:22:24 +0900 Subject: [PATCH 21/25] asdf --- Million Hunter/HunterMainForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index 5e5e0a1..673eb27 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -626,7 +626,7 @@ namespace Million foreach (var indi in totalIndicator) subIndicatorStateManagement[indi.IndexString][item] = false; - overlapBuyManagementList[item] = false; + overlapBuyManagementList[item] = true; continue; } From f23c46436290962059c64b3c043b32ce48ab3fd8 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Thu, 25 May 2023 13:03:45 +0900 Subject: [PATCH 22/25] =?UTF-8?q?buyvalue=20=EA=B0=80=20=EA=B3=A0=EA=B0=80?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterMainForm.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Million Hunter/HunterMainForm.cs b/Million Hunter/HunterMainForm.cs index 673eb27..14bfd24 100644 --- a/Million Hunter/HunterMainForm.cs +++ b/Million Hunter/HunterMainForm.cs @@ -621,16 +621,7 @@ namespace Million // 이전 전봉(H1)의 고가가 사려는 가격보다 높을경우 pass if (StarValueLowBuyValueUp) { - if (recentlyData.StartValue < beforeData.HighValue) - { - foreach (var indi in totalIndicator) - subIndicatorStateManagement[indi.IndexString][item] = false; - - overlapBuyManagementList[item] = true; - continue; - } - - //if (recentlyData.BuyValue < beforeData.HighValue) + //if (recentlyData.StartValue < beforeData.HighValue) //{ // foreach (var indi in totalIndicator) // subIndicatorStateManagement[indi.IndexString][item] = false; @@ -638,6 +629,15 @@ namespace Million // overlapBuyManagementList[item] = true; // continue; //} + + if (recentlyData.BuyValue < beforeData.HighValue) + { + foreach (var indi in totalIndicator) + subIndicatorStateManagement[indi.IndexString][item] = false; + + overlapBuyManagementList[item] = true; + continue; + } } recentlyData.BuyTime = recentlyData.DateTime; From fdbe0fcd1c89b92af73f7ec1c49384b3e6d8cabb Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Wed, 7 Jun 2023 14:49:13 +0900 Subject: [PATCH 23/25] =?UTF-8?q?buyer=EC=9D=98=20ticker=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=ED=9B=84=20RealtimeConclusion=20=EA=B5=90=EC=B2=B4?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Buyer/MainForm.Designer.cs | 101 +---- Million Buyer/MainForm.cs | 103 ++--- Million Prototype/Form1.cs | 4 +- Million/CommonProperty.cs | 3 +- Million/Data/Upbit/RealtimeConclusion.cs | 57 +++ Million/Manager/DataManager.cs | 48 +- Million/Manager/RealtimeDataSettingManager.cs | 422 +++++------------- Million/Million Core.csproj | 1 + Million/WebMangement/Upbit/UpbitAPI.cs | 2 +- 9 files changed, 252 insertions(+), 489 deletions(-) create mode 100644 Million/Data/Upbit/RealtimeConclusion.cs diff --git a/Million Buyer/MainForm.Designer.cs b/Million Buyer/MainForm.Designer.cs index 11b7b16..f638617 100644 --- a/Million Buyer/MainForm.Designer.cs +++ b/Million Buyer/MainForm.Designer.cs @@ -28,7 +28,9 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.cb_StarValueLowOverlapUp = new System.Windows.Forms.CheckBox(); this.cb_DownBeforeValueFlag = new System.Windows.Forms.CheckBox(); this.cb_UpperMainIndi = new System.Windows.Forms.CheckBox(); this.cb_IncludeClearIndicator = new System.Windows.Forms.CheckBox(); @@ -69,10 +71,6 @@ this.lb_log = new System.Windows.Forms.ListBox(); this.bt_alive = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label5 = new System.Windows.Forms.Label(); - this.dt_End = new DevExpress.XtraEditors.DateEdit(); - this.dt_Start = new DevExpress.XtraEditors.DateEdit(); - this.rd_BuyerTickerMode = new System.Windows.Forms.RadioButton(); this.cb_AccountList = new System.Windows.Forms.ComboBox(); this.cb_UserList = new System.Windows.Forms.ComboBox(); this.label12 = new System.Windows.Forms.Label(); @@ -89,20 +87,15 @@ this.bt_BuyStop = new System.Windows.Forms.Button(); this.bt_BuyStart = new System.Windows.Forms.Button(); this.lb_BuyFlag = new System.Windows.Forms.Label(); - this.timer1 = new System.Windows.Forms.Timer(); + this.timer1 = new System.Windows.Forms.Timer(this.components); this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl(); this.splitContainerControl2 = new DevExpress.XtraEditors.SplitContainerControl(); this.bt_AllSell = new System.Windows.Forms.Button(); - this.cb_StarValueLowOverlapUp = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tl_BuyList)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tl_Result)).BeginInit(); this.groupBox3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties.CalendarTimeProperties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties.CalendarTimeProperties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tl_RealtimeOrder)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit(); this.splitContainerControl1.SuspendLayout(); @@ -125,13 +118,23 @@ this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Location = new System.Drawing.Point(12, 172); + this.groupBox1.Location = new System.Drawing.Point(12, 149); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(362, 230); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; this.groupBox1.Text = "데이터 Setting"; // + // cb_StarValueLowOverlapUp + // + this.cb_StarValueLowOverlapUp.AutoSize = true; + this.cb_StarValueLowOverlapUp.Location = new System.Drawing.Point(9, 199); + this.cb_StarValueLowOverlapUp.Name = "cb_StarValueLowOverlapUp"; + this.cb_StarValueLowOverlapUp.Size = new System.Drawing.Size(164, 16); + this.cb_StarValueLowOverlapUp.TabIndex = 15; + this.cb_StarValueLowOverlapUp.Text = "사는시점 전 고가<현 시가"; + this.cb_StarValueLowOverlapUp.UseVisualStyleBackColor = true; + // // cb_DownBeforeValueFlag // this.cb_DownBeforeValueFlag.AutoSize = true; @@ -250,7 +253,7 @@ this.groupBox2.Controls.Add(this.label10); this.groupBox2.Controls.Add(this.lb_BuyMarketCount); this.groupBox2.Controls.Add(this.label3); - this.groupBox2.Location = new System.Drawing.Point(12, 408); + this.groupBox2.Location = new System.Drawing.Point(12, 388); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(362, 72); this.groupBox2.TabIndex = 6; @@ -496,10 +499,10 @@ this.lb_log.FormattingEnabled = true; this.lb_log.HorizontalScrollbar = true; this.lb_log.ItemHeight = 12; - this.lb_log.Location = new System.Drawing.Point(12, 486); + this.lb_log.Location = new System.Drawing.Point(12, 474); this.lb_log.Name = "lb_log"; this.lb_log.ScrollAlwaysVisible = true; - this.lb_log.Size = new System.Drawing.Size(362, 256); + this.lb_log.Size = new System.Drawing.Size(362, 268); this.lb_log.TabIndex = 16; // // bt_alive @@ -515,10 +518,6 @@ // // groupBox3 // - this.groupBox3.Controls.Add(this.label5); - this.groupBox3.Controls.Add(this.dt_End); - this.groupBox3.Controls.Add(this.dt_Start); - this.groupBox3.Controls.Add(this.rd_BuyerTickerMode); this.groupBox3.Controls.Add(this.cb_AccountList); this.groupBox3.Controls.Add(this.cb_UserList); this.groupBox3.Controls.Add(this.label12); @@ -527,57 +526,11 @@ this.groupBox3.Controls.Add(this.rd_Realtime); this.groupBox3.Location = new System.Drawing.Point(12, 9); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(362, 157); + this.groupBox3.Size = new System.Drawing.Size(362, 134); this.groupBox3.TabIndex = 10; this.groupBox3.TabStop = false; this.groupBox3.Text = "계정 및 모드 선택"; // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(243, 123); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(14, 12); - this.label5.TabIndex = 18; - this.label5.Text = "~"; - // - // dt_End - // - this.dt_End.EditValue = null; - this.dt_End.Enabled = false; - this.dt_End.Location = new System.Drawing.Point(262, 120); - this.dt_End.Name = "dt_End"; - this.dt_End.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { - new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.dt_End.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { - new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.dt_End.Size = new System.Drawing.Size(94, 20); - this.dt_End.TabIndex = 17; - // - // dt_Start - // - this.dt_Start.EditValue = null; - this.dt_Start.Enabled = false; - this.dt_Start.Location = new System.Drawing.Point(148, 120); - this.dt_Start.Name = "dt_Start"; - this.dt_Start.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { - new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.dt_Start.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { - new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.dt_Start.Size = new System.Drawing.Size(89, 20); - this.dt_Start.TabIndex = 16; - // - // rd_BuyerTickerMode - // - this.rd_BuyerTickerMode.AutoSize = true; - this.rd_BuyerTickerMode.Location = new System.Drawing.Point(10, 123); - this.rd_BuyerTickerMode.Name = "rd_BuyerTickerMode"; - this.rd_BuyerTickerMode.Size = new System.Drawing.Size(131, 16); - this.rd_BuyerTickerMode.TabIndex = 15; - this.rd_BuyerTickerMode.Text = "Buyer Ticker Mode"; - this.rd_BuyerTickerMode.UseVisualStyleBackColor = true; - this.rd_BuyerTickerMode.CheckedChanged += new System.EventHandler(this.rd_BuyerTickerMode_CheckedChanged); - // // cb_AccountList // this.cb_AccountList.FormattingEnabled = true; @@ -773,16 +726,6 @@ this.bt_AllSell.UseVisualStyleBackColor = true; this.bt_AllSell.Click += new System.EventHandler(this.bt_AllSell_Click); // - // cb_StarValueLowOverlapUp - // - this.cb_StarValueLowOverlapUp.AutoSize = true; - this.cb_StarValueLowOverlapUp.Location = new System.Drawing.Point(9, 199); - this.cb_StarValueLowOverlapUp.Name = "cb_StarValueLowOverlapUp"; - this.cb_StarValueLowOverlapUp.Size = new System.Drawing.Size(164, 16); - this.cb_StarValueLowOverlapUp.TabIndex = 15; - this.cb_StarValueLowOverlapUp.Text = "사는시점 전 고가<현 시가"; - this.cb_StarValueLowOverlapUp.UseVisualStyleBackColor = true; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); @@ -811,10 +754,6 @@ ((System.ComponentModel.ISupportInitialize)(this.tl_Result)).EndInit(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties.CalendarTimeProperties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties.CalendarTimeProperties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tl_RealtimeOrder)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit(); this.splitContainerControl1.ResumeLayout(false); @@ -887,10 +826,6 @@ private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1; private DevExpress.XtraEditors.SplitContainerControl splitContainerControl2; private System.Windows.Forms.CheckBox cb_DownBeforeValueFlag; - private System.Windows.Forms.RadioButton rd_BuyerTickerMode; - private System.Windows.Forms.Label label5; - private DevExpress.XtraEditors.DateEdit dt_End; - private DevExpress.XtraEditors.DateEdit dt_Start; private System.Windows.Forms.Button bt_AllSell; private System.Windows.Forms.CheckBox cb_StarValueLowOverlapUp; } diff --git a/Million Buyer/MainForm.cs b/Million Buyer/MainForm.cs index 4e4e180..2442a06 100644 --- a/Million Buyer/MainForm.cs +++ b/Million Buyer/MainForm.cs @@ -88,9 +88,7 @@ namespace Million_Buyer private void rd_Realtime_CheckedChanged(object sender, EventArgs e) { programMode = BuyerMode.BuyerRealtime; - SetReadOnly(true); - dt_Start.Enabled = false; - dt_End.Enabled = false; + SetReadOnly(true); } /// @@ -101,18 +99,7 @@ namespace Million_Buyer private void rd_buyer_CheckedChanged(object sender, EventArgs e) { programMode = BuyerMode.Buyer; - SetReadOnly(false); - dt_Start.Enabled = false; - dt_End.Enabled = false; - } - - - private void rd_BuyerTickerMode_CheckedChanged(object sender, EventArgs e) - { - programMode = BuyerMode.BuyerTicker; - SetReadOnly(true); - dt_Start.Enabled = true; - dt_End.Enabled = true; + SetReadOnly(false); } /// @@ -196,9 +183,6 @@ namespace Million_Buyer cb_UpperMainIndi.Enabled = false; rd_buyer.Enabled = false; rd_Realtime.Enabled = false; - dt_Start.Enabled = false; - dt_End.Enabled = false; - rd_BuyerTickerMode.Enabled = false; cb_StarValueLowOverlapUp.Enabled = false; } } @@ -218,7 +202,6 @@ namespace Million_Buyer bt_Start.Enabled = true; rd_buyer.Enabled = true; rd_Realtime.Enabled = true; - rd_BuyerTickerMode.Enabled = true; if (rd_buyer.Checked) SetReadOnly(false); @@ -229,18 +212,8 @@ namespace Million_Buyer cb_UpperMainIndi.Enabled = true; cb_StarValueLowOverlapUp.Enabled = true; - if (programMode == BuyerMode.BuyerTicker) - { - dt_Start.Enabled = true; - dt_End.Enabled = true; - } - - /* - * 종료 된 후 데이터 처리 소스는 여기서 처리 - * 1. Grid에 Stop 후 데이터 처리 - * 2. 종료 후 데이터 저장 처리 - */ - + + } /// @@ -365,9 +338,7 @@ namespace Million_Buyer if (programMode == BuyerMode.BuyerRealtime) InsertLog("실시간 검증 구동 중.."); else if (programMode == BuyerMode.Buyer) - InsertLog("Buyer 구동 중.."); - else if (programMode == BuyerMode.BuyerTicker) - InsertLog("Buyer Ticker 구동 중.."); + InsertLog("Buyer 구동 중.."); var cnt = 0; sw.Start(); @@ -391,13 +362,7 @@ namespace Million_Buyer realTimeMsg = new RealtimeDataSettingManager(null, programMode, this.payment); var startDateTime = DateTime.Now; - var endDateTime = startDateTime; - - if (programMode == BuyerMode.BuyerTicker) - { - startDateTime = dt_Start.DateTime; - endDateTime = dt_End.DateTime; - } + var endDateTime = startDateTime; dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList, startDateTime, endDateTime, 200); @@ -406,7 +371,7 @@ namespace Million_Buyer InsertLog("Buyer Ticker List 종료"); break; } - + #region TODO 이미 구매되어 있는 종목에 대한 기본 데이터 Setting 필요 if (programMode == BuyerMode.Buyer) { buyList = InitManager.GetBuyListofAccounts(this.accounts, dataList); @@ -427,16 +392,12 @@ namespace Million_Buyer } lb_BuyMarketCount.Text = buyList.Count.ToString(); - - })); - - #region TODO 이미 구매되어 있는 종목에 대한 기본 데이터 Setting 필요 + })); #endregion firstFlag = false; - sw.Stop(); InsertLog("Deafult Data Setting 완료..\\r\n" + "Default 계산 시간 : " + sw.Elapsed.ToString()); LogManager.WriteLog("Default 계산 시간 : " + sw.Elapsed.ToString()); @@ -529,23 +490,23 @@ namespace Million_Buyer if (StarValueLowBuyValueUp) { - if (recentlyData.StartValue < beforeData.HighValue) + //if (recentlyData.StartValue < beforeData.HighValue) + //{ + // foreach (var indi in totalIndicatorList) + // subIndicatorStateManagement[indi.IndexString][item] = false; + + // overlapBuyManagementList[item] = false; + // continue; + //} + + if (recentlyData.BuyValue < beforeData.HighValue) { foreach (var indi in totalIndicatorList) subIndicatorStateManagement[indi.IndexString][item] = false; - overlapBuyManagementList[item] = false; + overlapBuyManagementList[item] = true; continue; } - - //if (recentlyData.BuyValue < beforeData.HighValue) - //{ - // foreach (var indi in totalIndicator) - // subIndicatorStateManagement[indi.IndexString][item] = false; - - // overlapBuyManagementList[item] = true; - // continue; - //} } @@ -614,19 +575,23 @@ namespace Million_Buyer } } else - { - //default sell - var flag = sellScript.DicExcuteScript(recentlyData.CalculateFlag); + { + var flag = false; var scriptStr = sellScript.regularExpressionString; + + if (sellExceptionScript.regularExpressionString != null && + sellExceptionScript.regularExpressionString.Length > 0) + { + //예외처리 로직 추가 + flag = sellExceptionScript.DicExcuteScript(recentlyData.CalculateFlag); + if (flag) scriptStr = sellExceptionScript.regularExpressionString; + } + if (!flag) { - if (sellExceptionScript.regularExpressionString != null && - sellExceptionScript.regularExpressionString.Length > 0) - { - //예외처리 로직 추가 - flag = sellExceptionScript.DicExcuteScript(recentlyData.CalculateFlag); - if (flag) scriptStr = sellExceptionScript.regularExpressionString; - } + //default sell + flag = sellScript.DicExcuteScript(recentlyData.CalculateFlag); + scriptStr = sellScript.regularExpressionString; } if (allSell) flag = true; @@ -743,6 +708,8 @@ namespace Million_Buyer } } + realTimeMsg.Flag = false; + SaveData(); InsertLog("Thread Out"); } diff --git a/Million Prototype/Form1.cs b/Million Prototype/Form1.cs index d0de0e1..417c20e 100644 --- a/Million Prototype/Form1.cs +++ b/Million Prototype/Form1.cs @@ -191,7 +191,7 @@ namespace Million_Prototype { if (firstFlag == 0) { - realTimeMsg = new RealtimeDataSettingManager(null, BuyerMode.BuyerTicker,PaymentType.KRW); + dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList,DateTime.Now, DateTime.Now, 200); foreach (var item in realTimeMsg.coinFullNameList) { @@ -210,7 +210,7 @@ namespace Million_Prototype if (DateTime.Now.Minute == 0 && saveFlag) { - realTimeMsg.ClearTicker(); + if (resultDataList.Count > 0) { diff --git a/Million/CommonProperty.cs b/Million/CommonProperty.cs index 2945262..233b059 100644 --- a/Million/CommonProperty.cs +++ b/Million/CommonProperty.cs @@ -360,8 +360,7 @@ namespace Million public enum BuyerMode { BuyerRealtime, - Buyer, - BuyerTicker, + Buyer, HunterRealtime } diff --git a/Million/Data/Upbit/RealtimeConclusion.cs b/Million/Data/Upbit/RealtimeConclusion.cs new file mode 100644 index 0000000..2174bda --- /dev/null +++ b/Million/Data/Upbit/RealtimeConclusion.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Million.Data.Upbit +{ + /// + /// 실시간 체결량 관련 Class + /// + public class RealtimeConclusion + { + public string type { get; set; } + public string code { get; set; } + public long timestamp { get; set; } + public string trade_date { get; set; } + public string trade_time { get; set; } + public long trade_timestamp { get; set; } + public double trade_price { get; set; } + public double trade_volume { get; set; } + public string ask_bid { get; set; } + public double prev_closing_price { get; set; } + public string change { get; set; } + public double change_price { get; set; } + public long sequential_id { get; set; } + public string stream_type { get; set; } + + public DateTime TradeDateTime { get; set; } + + public RealtimeConclusion Clone() + { + + var dt = new DateTime(1970, 1, 1); + dt = dt.AddMilliseconds(trade_timestamp); + dt = dt.AddHours(9); + return new RealtimeConclusion() + { + type = type, + code = code, + timestamp= timestamp, + trade_date = trade_date, + trade_time = trade_time, + trade_timestamp = trade_timestamp, + trade_price = trade_price, + trade_volume = trade_volume, + ask_bid = ask_bid, + prev_closing_price = prev_closing_price, + change = change, + change_price = change_price, + sequential_id = sequential_id, + stream_type = stream_type, + TradeDateTime = dt + }; + } + } +} diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index d9737a0..8a549d7 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -2,6 +2,8 @@ using Million.Data.Upbit; using Million.DbManagement; using Million.IndicatorConditionSetup; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; @@ -169,7 +171,7 @@ namespace Million.Manager { var recentlyList = orderList.Where(t => t.RecentlyDataFlag).ToList(); if (recentlyList.Count > 0) - returnData = recentlyList[0]; + returnData = recentlyList[0]; } else { @@ -234,6 +236,7 @@ namespace Million.Manager StartValue = firstData.StartValue, LowValue = firstData.LowValue, EndValue = firstData.EndValue, + RecentlyDataFlag = true, MoneyVolume = firstData.MoneyVolume }; } @@ -246,6 +249,7 @@ namespace Million.Manager HighValue = firstData.HighValue, StartValue = firstData.StartValue, LowValue = firstData.LowValue, + RecentlyDataFlag = true, EndValue = firstData.EndValue, MoneyVolume = firstData.MoneyVolume }; @@ -259,6 +263,7 @@ namespace Million.Manager HighValue = firstData.HighValue, StartValue = firstData.StartValue, LowValue = firstData.LowValue, + RecentlyDataFlag = true, EndValue = firstData.EndValue, MoneyVolume = firstData.MoneyVolume }; @@ -332,6 +337,7 @@ namespace Million.Manager recentlyData.LowValue = recentlyData.LowValue < item.LowValue ? recentlyData.LowValue : item.LowValue; recentlyData.EndValue = item.EndValue; recentlyData.MoneyVolume += item.MoneyVolume; + recentlyData.RecentlyDataFlag = true; } @@ -403,7 +409,7 @@ namespace Million.Manager candle.RecentlyDataFlag = true; candle.EndValue = candleData.EndValue; candle.MoneyVolume = candleData.MoneyVolume; - + if (timeFlag == "minute") { var date = recentlyData.DateTime.AddMinutes((int)mCandleTimeType); @@ -440,35 +446,36 @@ namespace Million.Manager } /// - /// Tick List를 + /// 실시간 체결 데이터 1분봉 처리 /// - /// + /// /// - public static List GetOneMinuteCandleDataFromTickList(List tickList) + public static List GetOneMinuteCandleDataFromConclusionList(List realtimeConclusions) { var returnData = new List(); - var dateTimeList = tickList.Select(t => t.DateTime.Minute).Distinct().ToList(); + var dateTimeList = realtimeConclusions.Select(t => t.TradeDateTime.Minute).Distinct().ToList(); foreach (var item in dateTimeList) { - var list = tickList.Where(t => t.DateTime.Minute == item).ToList(); + var list = realtimeConclusions.Where(t => t.TradeDateTime.Minute == item).ToList(); if (list.Count > 0) { - var valueList = list.Select(t => t.TradePrice).ToList(); - var startValue = list[0].TradePrice; - var endValue = list[list.Count - 1].TradePrice; + var valueList = list.Select(t => t.trade_price).ToList(); + var startValue = list[0].trade_price; + var endValue = list[list.Count - 1].trade_price; var highValue = valueList.Max(); var lowValue = valueList.Min(); var candle = new CandleData(); - candle.DateTime = list[0].DateTime; - candle.DateTime.AddSeconds(candle.DateTime.Second * -1); + candle.DateTime = list[0].TradeDateTime; + candle.DateTime = candle.DateTime.AddSeconds(candle.DateTime.Second * -1); candle.CandleTimeType = 1; candle.StartValue = startValue; candle.HighValue = highValue; candle.LowValue = lowValue; candle.RecentlyDataFlag = true; candle.EndValue = endValue; + candle.MoneyVolume = list.Select(t => t.trade_volume).Sum(); returnData.Add(candle); } @@ -477,5 +484,22 @@ namespace Million.Manager return returnData; } + /// + /// Json 검사 + /// + /// + /// + public static bool ValidateJSON(string s) + { + try + { + JToken.Parse(s); + return true; + } + catch (JsonReaderException) + { + return false; + } + } } } diff --git a/Million/Manager/RealtimeDataSettingManager.cs b/Million/Manager/RealtimeDataSettingManager.cs index c30343b..42176ba 100644 --- a/Million/Manager/RealtimeDataSettingManager.cs +++ b/Million/Manager/RealtimeDataSettingManager.cs @@ -2,12 +2,14 @@ using Million.Data.Upbit; using Million.DbManagement; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; +using System.Net.WebSockets; +using System.Text; using System.Threading; using System.Threading.Tasks; -using static Million.CommonProperty; namespace Million.Manager { @@ -15,34 +17,25 @@ namespace Million.Manager /// Data Setting하는 Manager Class /// public class RealtimeDataSettingManager - { - /// - /// Ticker에 들어갈 데이터 - /// - public List tickerList = new List(); - - /// - /// Buyer Ticker모드에서 사용할 전체 Tick List - /// - public List totalTickerList = new List(); + { + public List realtimeConclusions = new List(); private object obj = new object(); public List coinFullNameList = null; - public PaymentType buyType = PaymentType.KRW; + public CommonProperty.PaymentType buyType = CommonProperty.PaymentType.KRW; public DateTime basicDateTime { get; set; } - public BuyerMode buyerMode; + public CommonProperty.BuyerMode buyerMode; public DateTime startDateTime { get; set; } public DateTime endDateTime { get; set; } - - - public System.Threading.Timer timer = null; - public TimerCallback tc = null; - public bool flag = true; + /// + /// Websocket 관련 데이터 처리 + /// + public bool Flag { get; set; } = true; /// /// 생성자 /// - public RealtimeDataSettingManager(List coinFullNameList, BuyerMode buyerMode, PaymentType buyType, string tableName = "Upbit") + public RealtimeDataSettingManager(List coinFullNameList, CommonProperty.BuyerMode buyerMode, CommonProperty.PaymentType buyType, string tableName = "Upbit") { this.buyType = buyType; this.buyerMode = buyerMode; @@ -62,21 +55,23 @@ namespace Million.Manager //TODO Market ignore 처리 필요 -> 임시로 비트토랜트만 삭제 this.coinFullNameList.Remove("KRW-BTT"); if (CommonProperty.selectedMarketOfPlaceList != null) - CommonProperty.selectedMarketOfPlaceList.Remove(selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT")); + CommonProperty.selectedMarketOfPlaceList.Remove(CommonProperty.selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT")); if (CommonProperty.recentlyMarketOfPlaceList != null) - CommonProperty.recentlyMarketOfPlaceList.Remove(recentlyMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT")); + CommonProperty.recentlyMarketOfPlaceList.Remove(CommonProperty.recentlyMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT")); } /// - /// 실시간 데이터 가져오는 함수(Ticker와 CandleDataList두개를 Return 할 수 있도록 구성) + /// 실시간 데이터 가져오는 함수(Ticker와 CandleDataList두개를 Return 할 수 있도록 구성) => Ticker 에서 실시간 체결 데이터로 이전 /// /// /// /// /// - public List GetRecentlyCandleData() + public List GetRecentlyCandleData() { - return CommonProperty.UpbitApi.GetTickerList(coinFullNameList); + var returnData = new List(); + + return returnData; } /// @@ -86,16 +81,14 @@ namespace Million.Manager /// /// /// - public List GetBasicDataSetting(MCandleTimeType timeType, DateTime basicDateTime, int count = 200) + public List GetBasicDataSetting(CommonProperty.MCandleTimeType timeType, DateTime basicDateTime, int count = 200) { var returnData = new List(); - - var resultList = new List(); foreach (var item in coinFullNameList) { var val = new CandleDataList(); - val.ConGoodsData = selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == item); + val.ConGoodsData = CommonProperty.selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == item); val.CandleDataLists_Im = CommonProperty.UpbitApi.GetCandleStics(item, timeType, basicDateTime, count).OrderBy(t => t.DateTime).ToList(); returnData.Add(val); Thread.Sleep(400); @@ -103,34 +96,7 @@ namespace Million.Manager return returnData; } - - public void StartGetRealTimeTicker(object state, int duTime = 0, int period = 50) - { - if (this.timer != null) - { - flag = false; - - this.timer.Dispose(); - this.timer = null; - } - - this.tc = new TimerCallback(TimerEvent); // 이벤트 발생 처리 루틴 - - //0.5초 마다 쌓는거 진행 -> DB데이터 가지고와서 부터 데이터 처리 - this.timer = new System.Threading.Timer(tc, null, 0, 500); - flag = true; - - } - public void EndRealTimeTicker() - { - flag = false; - if (timer != null) - { - this.timer.Dispose(); - this.timer = null; - - } - } + /// /// 실시간 데이터 가져오는 함수(Buyer에서 시작과 동시에 호출되는 함수) @@ -139,22 +105,14 @@ namespace Million.Manager /// /// /// - public Dictionary> GetRealTimeCandleData(List types,DateTime startDate, DateTime endDate, int count = 200) + public Dictionary> GetRealTimeCandleData(List types,DateTime startDate, DateTime endDate, int count = 200) { + //여기는 한번만 동작하므로 RealtimeConclusion 처리 해야함 + var thread = new Thread(new ThreadStart(ThreadEventAsync)); + thread.Start(); - var data = new Dictionary>(); - - if (this.buyerMode != BuyerMode.BuyerTicker) - { - StartGetRealTimeTicker(null); - } - else - { - startDateTime = startDate; - endDateTime = endDate; - GetAllTickerDataList(); - } - + var data = new Dictionary>(); + foreach (var type in types) { data[type] = GetBasicDataSetting(type, startDate, count); @@ -163,23 +121,6 @@ namespace Million.Manager return ProcessRecentlyCandleDatas(data, types); } - /// - /// 전체 Ticker Data List가져오는 함수 - /// - private void GetAllTickerDataList() - { - var tickerDickList = DBConnection.QueryGetExecuter_VerifyTickerData(startDateTime, endDateTime); - tickerDickList = tickerDickList.OrderBy(t => t["DateTime"]?.ToString()).ToList(); - foreach (var item in tickerDickList) - { - var tick = new Ticker(); - tick.DateTime = Convert.ToDateTime(item["DateTime"]?.ToString()); - double.TryParse(item["EndValue"]?.ToString(), out double val); - tick.TradePrice = val; - tick.CoinFullName = item["CoinFullName"]?.ToString(); - totalTickerList.Add(tick); - } - } /// @@ -188,18 +129,24 @@ namespace Million.Manager /// /// /// - public Dictionary> ProcessRecentlyCandleDatas(Dictionary> candleDatas, List types) + public Dictionary> ProcessRecentlyCandleDatas(Dictionary> candleDatas, List types) { - if(buyerMode == BuyerMode.BuyerTicker) + var cloneRealtimeConclusion = new List(); + + lock (obj) { - tickerList.Clear(); - if (totalTickerList.Count < coinFullNameList.Count) return null; - foreach (var item in coinFullNameList) + try { - var tick = totalTickerList.FirstOrDefault(t => t.CoinFullName == item); - tickerList.Add(tick); - totalTickerList.Remove(tick); - } + foreach (var item in realtimeConclusions) + { + cloneRealtimeConclusion.Add(item.Clone()); + } + realtimeConclusions.Clear(); + } + catch (Exception e) + { + LogManager.WriteLog(e.Message); + } } foreach (var type in types) @@ -207,32 +154,18 @@ namespace Million.Manager var candleList = candleDatas[type]; //Parallel.ForEach(candleList, item => //{ - var tickList = new List(); - var cloneTickList = new List(); - lock (obj) - { - try - { - foreach (var item in tickerList) - { - cloneTickList.Add(item.Clone()); - } - } - catch (Exception e) - { - LogManager.WriteLog(e.Message); - } - } + + var list = new List(); foreach (var item in candleList) { - if (item.CandleDataLists_Im.Count > 0) - basicDateTime = item.CandleDataLists_Im.Select(t => t.DateTime).Max(); + //if (item.CandleDataLists_Im.Count > 0) + // basicDateTime = item.CandleDataLists_Im.Select(t => t.DateTime).Max(); var coinFullName = item.ConGoodsData.CoinFullName; - tickList = cloneTickList.Where(t => t.CoinFullName == coinFullName).OrderBy(t=>t.DateTime).ToList(); + list = cloneRealtimeConclusion.Where(t => t.code == coinFullName).OrderBy(t=>t.TradeDateTime).ToList(); #region 여러 Type 다 호환 되도록 새로 구성 /* @@ -242,7 +175,7 @@ namespace Million.Manager * 4. 이후 300개 이상일 경우 삭제 처리 */ - var returnList = DataManager.GetOneMinuteCandleDataFromTickList(tickList); + var returnList = DataManager.GetOneMinuteCandleDataFromConclusionList(list); if(item.CandleDataLists_Im.Count > 0) { var lastData = item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1]; @@ -263,228 +196,75 @@ namespace Million.Manager } #endregion - #region 옛날 소스 - //// 호출 당시 시, 분, 초 - //var callH = basicDateTime.Hour; - //var callM = basicDateTime.Minute; - //var callS = basicDateTime.Second; - //try - //{ - // if (type == MCandleTimeType.M1) - // { - // var equalMinuteList = tickList.Where(t => t.DateTime.Minute == callM).ToList(); - - // //해당 분 고가 - // if (equalMinuteList.Count != 0) - // { - // var equalListM = equalMinuteList.Select(t => t.TradePrice).ToList(); - // double equalListMax = 0; - // if (equalListM.Count != 0) - // { - // equalListMax = equalListM.Max(); - // } - - // //해당 분 저가 - // var equalListL = equalMinuteList.Select(t => t.TradePrice).ToList(); - - // double equalListMin = 0; - // if (equalListL.Count != 0) - // { - // equalListMin = equalListL.Min(); - // } - // if (item.CandleDataLists_Im.Count != 0) - // { - // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0) - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax; - // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0) - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin; - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true; - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice; - // } - // else - // { - // var candle = new CandleData(); - // candle.CandleTimeType = (int)MCandleTimeType.M1; - // candle.StartValue = equalMinuteList[0].TradePrice; - // candle.HighValue = equalListMax; - // candle.LowValue = equalListMin; - // candle.RecentlyDataFlag = true; - // candle.EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice; - // var date = basicDateTime.AddMinutes(1); - // date = date.AddSeconds(-1 * callS); - // candle.DateTime = date; - // if (item.CandleDataLists_Im.Count > 300) - // item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300); - // item.CandleDataLists_Im.Add(candle); - // } - // } - - // var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Minute != basicDateTime.Minute).ToList(); - - // if (list.Count > 0) - // { - // // 데이터 가져올떄 1분 이상 걸릴 시 처리할 데이터 - // var minList = list.Select(t => t.DateTime.Minute).Distinct().ToList(); - // minList.Sort(); - - // foreach (var min in minList) - // { - // var equalList = list.Where(t => t.DateTime.Minute == min).OrderBy(t => t.DateTime).ToList(); - - // //해당 분 고가 - // var max = equalList.Select(t => t.TradePrice).ToList().Max(); - // //해당 분 저가 - // var low = equalList.Select(t => t.TradePrice).ToList().Min(); - - // var candle = new CandleData(); - // candle.CandleTimeType = (int)MCandleTimeType.M1; - // candle.StartValue = equalList[0].TradePrice; - // candle.HighValue = max; - // candle.LowValue = low; - // candle.RecentlyDataFlag = true; - // candle.EndValue = equalList[equalList.Count - 1].TradePrice; - - // var intervalMin = min - callM; - - // var date = basicDateTime.AddMinutes(intervalMin); - // if(intervalMin < 0) date = date.AddHours(1); - - // date = date.AddSeconds(-1 * callS); - // candle.DateTime = date; - // if (item.CandleDataLists_Im.Count > 300) - // item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300); - // item.CandleDataLists_Im.Add(candle); - - // } - // } - // } - // else if (type == MCandleTimeType.H1) - // { - // var equalHourList = tickList.Where(t => t.DateTime.Hour == callH).ToList(); - // if (equalHourList.Count != 0) - // { - // var equalListM = equalHourList.Select(t => t.TradePrice).ToList(); - // double equalListMax = 0; - // if (equalListM.Count != 0) - // { - // equalListMax = equalListM.Max(); - // } - - // //해당 분 저가 - // var equalListL = equalHourList.Select(t => t.TradePrice).ToList(); - // double equalListMin = 0; - // if (equalListL.Count != 0) - // { - // equalListMin = equalListL.Min(); - // } - // if (item.CandleDataLists_Im.Count > 0) - // { - // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0) - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax; - // if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0) - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin; - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true; - // item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalHourList[equalHourList.Count - 1].TradePrice; - // } - // else - // { - // var candle = new CandleData(); - // candle.CandleTimeType = (int)MCandleTimeType.H1; - // candle.StartValue = equalHourList[0].TradePrice; - // candle.HighValue = equalListMax; - // candle.LowValue = equalListMin; - // candle.RecentlyDataFlag = true; - // candle.EndValue = equalHourList[equalHourList.Count - 1].TradePrice; - - // var date = basicDateTime.AddHours(1); - // date = date.AddMinutes(-1 * callM); - // date = date.AddSeconds(-1 * callS); - // candle.DateTime = date; - // if (item.CandleDataLists_Im.Count > 300) - // item.CandleDataLists_Im.RemoveRange(0, 100); - // item.CandleDataLists_Im.Add(candle); - // } - // } - - // var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Hour != basicDateTime.Hour).ToList(); - // if (list.Count > 0) - // { - // //해당 분 고가 - // var max = list.Select(t => t.TradePrice).ToList().Max(); - // //해당 분 저가 - // var low = list.Select(t => t.TradePrice).ToList().Min(); - - // var candle = new CandleData(); - // candle.CandleTimeType = (int)MCandleTimeType.H1; - // candle.StartValue = list[0].TradePrice; - // candle.HighValue = max; - // candle.LowValue = low; - // candle.RecentlyDataFlag = true; - // candle.EndValue = list[list.Count - 1].TradePrice; - - // var date = basicDateTime.AddHours(1); - // date = date.AddMinutes(-1 * callM); - // date = date.AddSeconds(-1 * callS); - - // candle.DateTime = date; - // if (item.CandleDataLists_Im.Count > 300) - // item.CandleDataLists_Im.RemoveRange(0, 100); - // item.CandleDataLists_Im.Add(candle); - // } - // } - //} - //catch (Exception e) - //{ - // throw; - //} - #endregion + } //}); } return candleDatas; } - public void ClearTicker() - { - lock (obj) - { - try { - if (tickerList.Count > 2000) - tickerList.RemoveRange(0, tickerList.Count - 1000); - - } - catch (Exception e) - { - LogManager.WriteLog(e.Message); - } - } - } - - /// /// Timer Event /// /// - private void TimerEvent(object state) + private async void ThreadEventAsync() { - lock (obj) + string WebSocketUrl = "wss://api.upbit.com/websocket/v1"; + + ClientWebSocket webSocket = new ClientWebSocket(); + + try { - try - { - var temp = GetRecentlyCandleData(); + await webSocket.ConnectAsync(new Uri(WebSocketUrl), CancellationToken.None); + var dic = new List>(); + dic.Add(new Dictionary() { { "ticket", "test" } }); + dic.Add(new Dictionary() { { "type", "trade" }, { "codes", CommonProperty.recentlyMarketOfPlaceList.Where(t=>t.CoinFullName.Contains("KRW-")).Select(t=>t.CoinFullName).ToList() } }); - if (temp != null) + await SendMessage(webSocket, JsonConvert.SerializeObject(dic)); + + + // 데이터 수신을 위한 반복문 시작 + while (webSocket.State == WebSocketState.Open && Flag) + { + byte[] buffer = new byte[1024 * 10]; + WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + + // 수신한 데이터 처리 + var message = System.Text.Encoding.UTF8.GetString(buffer, 0, result.Count); + + if (!DataManager.ValidateJSON(message)) continue; + + var data = JsonConvert.DeserializeObject(message); + + lock (obj) { - tickerList.AddRange(temp); - ClearTicker(); + realtimeConclusions.Add(data); } - - } - catch (Exception e) - { - LogManager.WriteLog(e.Message); } } + catch (Exception ex) + { + throw ex; + } + finally + { + if (webSocket.State == WebSocketState.Open) + await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "WebSocket 연결 종료", CancellationToken.None); + + webSocket.Dispose(); + } + } + + /// + /// Websocket 관련 SendMessage function + /// + /// + /// + /// + private async Task SendMessage(ClientWebSocket webSocket, string message) + { + byte[] buffer = Encoding.UTF8.GetBytes(message); + await webSocket.SendAsync(new ArraySegment(buffer), WebSocketMessageType.Text, true, CancellationToken.None); } } } diff --git a/Million/Million Core.csproj b/Million/Million Core.csproj index 2a88309..d82a603 100644 --- a/Million/Million Core.csproj +++ b/Million/Million Core.csproj @@ -173,6 +173,7 @@ + diff --git a/Million/WebMangement/Upbit/UpbitAPI.cs b/Million/WebMangement/Upbit/UpbitAPI.cs index 12bf44d..90928ae 100644 --- a/Million/WebMangement/Upbit/UpbitAPI.cs +++ b/Million/WebMangement/Upbit/UpbitAPI.cs @@ -338,7 +338,7 @@ namespace Million.WebMangement.Upbit } return returnData; - } + } /// /// Coin Full name List를 기준으로 현재가 가져오는 함수 From 1cefd842989acb6c5547319c55418c8272c2285a Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Thu, 8 Jun 2023 13:57:02 +0900 Subject: [PATCH 24/25] =?UTF-8?q?=EC=8B=9C=EA=B0=84=EB=B4=89=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/Manager/DataManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Million/Manager/DataManager.cs b/Million/Manager/DataManager.cs index 8a549d7..00b73c6 100644 --- a/Million/Manager/DataManager.cs +++ b/Million/Manager/DataManager.cs @@ -385,7 +385,7 @@ namespace Million.Manager } else if (timeFlag == "hour") { - if (candleData.DateTime.Hour % timeFlagValue == 0) + if (candleData.DateTime.Hour % timeFlagValue == 1) { if (recentlyData.DateTime.Hour != candleData.DateTime.Hour) flag = true; From 10c95ba0a0acf2f9091107a437d7a02085157db5 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Mon, 3 Jul 2023 14:32:59 +0900 Subject: [PATCH 25/25] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=EA=B0=80=20?= =?UTF-8?q?=EC=9D=98=EB=8F=84=EC=B9=98=20=EC=95=8A=EA=B2=8C=20websocket=20?= =?UTF-8?q?=EC=A2=85=EB=A3=8C=20=EB=90=A0=EA=B2=BD=EC=9A=B0=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=8B=A4=ED=96=89=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/Manager/RealtimeDataSettingManager.cs | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/Million/Manager/RealtimeDataSettingManager.cs b/Million/Manager/RealtimeDataSettingManager.cs index 42176ba..5035b5f 100644 --- a/Million/Manager/RealtimeDataSettingManager.cs +++ b/Million/Manager/RealtimeDataSettingManager.cs @@ -210,48 +210,51 @@ namespace Million.Manager private async void ThreadEventAsync() { string WebSocketUrl = "wss://api.upbit.com/websocket/v1"; - - ClientWebSocket webSocket = new ClientWebSocket(); - - try + realtimeConclusions.Clear(); + while (Flag) { - await webSocket.ConnectAsync(new Uri(WebSocketUrl), CancellationToken.None); - var dic = new List>(); - dic.Add(new Dictionary() { { "ticket", "test" } }); - dic.Add(new Dictionary() { { "type", "trade" }, { "codes", CommonProperty.recentlyMarketOfPlaceList.Where(t=>t.CoinFullName.Contains("KRW-")).Select(t=>t.CoinFullName).ToList() } }); + ClientWebSocket webSocket = new ClientWebSocket(); - await SendMessage(webSocket, JsonConvert.SerializeObject(dic)); - - - // 데이터 수신을 위한 반복문 시작 - while (webSocket.State == WebSocketState.Open && Flag) + try { - byte[] buffer = new byte[1024 * 10]; - WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); - - // 수신한 데이터 처리 - var message = System.Text.Encoding.UTF8.GetString(buffer, 0, result.Count); + await webSocket.ConnectAsync(new Uri(WebSocketUrl), CancellationToken.None); + var dic = new List>(); + dic.Add(new Dictionary() { { "ticket", "test" } }); + dic.Add(new Dictionary() { { "type", "trade" }, { "codes", CommonProperty.recentlyMarketOfPlaceList.Where(t => t.CoinFullName.Contains("KRW-")).Select(t => t.CoinFullName).ToList() } }); - if (!DataManager.ValidateJSON(message)) continue; - - var data = JsonConvert.DeserializeObject(message); + await SendMessage(webSocket, JsonConvert.SerializeObject(dic)); - lock (obj) + + // 데이터 수신을 위한 반복문 시작 + while (webSocket.State == WebSocketState.Open && Flag) { - realtimeConclusions.Add(data); + byte[] buffer = new byte[1024 * 10]; + WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + + // 수신한 데이터 처리 + var message = System.Text.Encoding.UTF8.GetString(buffer, 0, result.Count); + + if (!DataManager.ValidateJSON(message)) continue; + + var data = JsonConvert.DeserializeObject(message); + + lock (obj) + { + realtimeConclusions.Add(data); + } } } - } - catch (Exception ex) - { - throw ex; - } - finally - { - if (webSocket.State == WebSocketState.Open) - await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "WebSocket 연결 종료", CancellationToken.None); + catch (Exception ex) + { + LogManager.WriteLog(ex.Message); + } + finally + { + if (webSocket.State == WebSocketState.Open) + await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "WebSocket 연결 종료", CancellationToken.None); - webSocket.Dispose(); + webSocket.Dispose(); + } } }