diff --git a/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs b/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs index bb71730..d55fc39 100644 --- a/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs +++ b/Million Hunter/HunterSubForm/ResultViewerForm.Designer.cs @@ -750,7 +750,6 @@ namespace Million.HunterSubForm #endregion private DevExpress.XtraEditors.PanelControl panelControl_IndicatorCondition; - private DevExpress.XtraTreeList.TreeList treeList_ResultData; private System.Windows.Forms.GroupBox groupBox_; private System.Windows.Forms.SplitContainer splitContainer_SetupPanel; private System.Windows.Forms.GroupBox groupBox3; @@ -796,5 +795,6 @@ namespace Million.HunterSubForm private DevExpress.XtraEditors.LabelControl labelControl_WinRateProfitRate; private DevExpress.XtraEditors.SimpleButton simpleButton_WinRateProfitRate; public DevExpress.XtraEditors.SimpleButton simpleButton_TestBoard; + public DevExpress.XtraTreeList.TreeList treeList_ResultData; } } \ No newline at end of file diff --git a/Million Hunter/HunterSubForm/ResultViewerForm.cs b/Million Hunter/HunterSubForm/ResultViewerForm.cs index 536d970..cfb4c76 100644 --- a/Million Hunter/HunterSubForm/ResultViewerForm.cs +++ b/Million Hunter/HunterSubForm/ResultViewerForm.cs @@ -219,7 +219,7 @@ namespace Million.HunterSubForm /// /// 승률 및 수익률 계산 함수 /// - private void CalcurateProfitAndWinRate() + public void CalcurateProfitAndWinRate() { // 승률 수익률 계산하기 // 결과 반영 체크 && Filter 된 노드만 리스트로 모음 diff --git a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs index 255ce97..fe3b486 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.Designer.cs @@ -32,10 +32,17 @@ 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.simpleButton_Calc = new DevExpress.XtraEditors.SimpleButton(); - this.checkedListBox_Indicator = new System.Windows.Forms.CheckedListBox(); + 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.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(); this.SuspendLayout(); // // simpleButton_FullInsertCandle @@ -54,55 +61,90 @@ 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(419, 63); + this.groupBox1.Size = new System.Drawing.Size(154, 63); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "데이터 채우기"; // // groupBox2 // - this.groupBox2.Controls.Add(this.checkedListBox_Indicator); + 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.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(829, 129); + this.groupBox2.Size = new System.Drawing.Size(829, 123); this.groupBox2.TabIndex = 3; this.groupBox2.TabStop = false; this.groupBox2.Text = "지표"; // - // simpleButton_Calc + // checkEdit_구매이전봉볼린저40_1이하 // - this.simpleButton_Calc.Appearance.ForeColor = System.Drawing.Color.Teal; - this.simpleButton_Calc.Appearance.Options.UseForeColor = true; - this.simpleButton_Calc.Location = new System.Drawing.Point(720, 225); - this.simpleButton_Calc.Name = "simpleButton_Calc"; - this.simpleButton_Calc.Size = new System.Drawing.Size(121, 32); - this.simpleButton_Calc.TabIndex = 1; - this.simpleButton_Calc.Text = "계산하기"; - this.simpleButton_Calc.Click += new System.EventHandler(this.simpleButton_Calc_Click); + this.checkEdit_구매이전봉볼린저40_1이하.Location = new System.Drawing.Point(204, 22); + 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(179, 19); + this.checkEdit_구매이전봉볼린저40_1이하.TabIndex = 1; + this.checkEdit_구매이전봉볼린저40_1이하.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); // - // checkedListBox_Indicator + // checkEdit_이전봉40_2볼린저이하 // - this.checkedListBox_Indicator.Dock = System.Windows.Forms.DockStyle.Fill; - this.checkedListBox_Indicator.FormattingEnabled = true; - this.checkedListBox_Indicator.Items.AddRange(new object[] { - "구매 시점 이전 봉 40 1 볼린저 값 이하"}); - this.checkedListBox_Indicator.Location = new System.Drawing.Point(3, 18); - this.checkedListBox_Indicator.Name = "checkedListBox_Indicator"; - this.checkedListBox_Indicator.Size = new System.Drawing.Size(823, 108); - this.checkedListBox_Indicator.TabIndex = 0; + this.checkEdit_이전봉40_2볼린저이하.Location = new System.Drawing.Point(19, 22); + this.checkEdit_이전봉40_2볼린저이하.Name = "checkEdit_이전봉40_2볼린저이하"; + this.checkEdit_이전봉40_2볼린저이하.Properties.Caption = "구매 이전 봉 40_2 볼린저 이하"; + this.checkEdit_이전봉40_2볼린저이하.Size = new System.Drawing.Size(179, 19); + this.checkEdit_이전봉40_2볼린저이하.TabIndex = 0; + this.checkEdit_이전봉40_2볼린저이하.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.simpleButton_Reset); + this.groupBox3.Location = new System.Drawing.Point(187, 12); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(154, 63); + this.groupBox3.TabIndex = 4; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "데이터 채우기"; + // + // simpleButton_Reset + // + this.simpleButton_Reset.Location = new System.Drawing.Point(0, 0); + this.simpleButton_Reset.Name = "simpleButton_Reset"; + this.simpleButton_Reset.Size = new System.Drawing.Size(75, 23); + this.simpleButton_Reset.TabIndex = 0; + // + // 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.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(852, 23); + this.progressBar1.TabIndex = 5; + // + // simpleButton_찬 + // + this.simpleButton_찬.Location = new System.Drawing.Point(737, 33); + 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); // // 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.Controls.Add(this.simpleButton_Calc); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.simpleButton_찬); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "TestBoardForm"; this.Text = "TestBoard"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit(); + this.groupBox3.ResumeLayout(false); this.ResumeLayout(false); } @@ -113,6 +155,11 @@ namespace Million_Hunter.HunterSubForm private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.CheckedListBox checkedListBox_Indicator; - private DevExpress.XtraEditors.SimpleButton simpleButton_Calc; + private DevExpress.XtraEditors.SimpleButton simpleButton_찬; + private System.Windows.Forms.ProgressBar progressBar1; + private DevExpress.XtraEditors.CheckEdit checkEdit_이전봉40_2볼린저이하; + private System.Windows.Forms.GroupBox groupBox3; + private DevExpress.XtraEditors.SimpleButton simpleButton_Reset; + 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 e4ce9b8..33a1547 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -1,6 +1,7 @@ using DevExpress.XtraEditors; using Million; using Million.Data; +using Million.DbManagement; using Million.HunterSubForm; using Million.IndicatorConditionSetup; using Million.Manager; @@ -11,6 +12,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -24,11 +26,15 @@ namespace Million_Hunter.HunterSubForm CommonProperty.MCandleTimeType MCandleTimeType; + bool ignoreChangedfilter = false; + public TestBoardForm(ResultViewerForm resultViewerForm) { InitializeComponent(); parentForm = resultViewerForm; analysisDatas = parentForm._analysisDatas; + + } /// @@ -137,36 +143,284 @@ namespace Million_Hunter.HunterSubForm } /// - /// 추가 조건 계산하기 + /// 데이터 초기화 /// /// /// - private void simpleButton_Calc_Click(object sender, EventArgs e) + private void simpleButton_Reset_Click(object sender, EventArgs e) + { + resetFilter(); + + ignoreChangedfilter = true; + + checkEdit_구매이전봉볼린저40_1이하.Checked = false; + checkEdit_이전봉40_2볼린저이하.Checked = false; + + ignoreChangedfilter = false; + + parentForm.treeList_ResultData.RefreshDataSource(); + parentForm.CalcurateProfitAndWinRate(); + } + + public void resetFilter() { // 구매 시점 이전 봉 40 1 볼린저 값 이하 foreach (var analysisData in parentForm._analysisDatas) { - var startDate = analysisData.StartDate; - var endDate = analysisData.EndDate; + analysisData.Inclusion = true; + analysisData.Description = ""; + } - var 구매이전봉 = startDate; - //차트 Date Time 설정하기 - var StartDateInterval = -1; + } - var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉); - var highValue = candleData.HighValue; - var bol402 = candleData.IndicatorDic["Bol402"]?.value ; + public void calcurateFilter() + { - if(bol402 != null) + // 필터 초기화 + resetFilter(); + + // 이전봉40_2볼린저이하 + if (checkEdit_이전봉40_2볼린저이하.Checked) + { + // 구매 시점 이전 봉 40 1 볼린저 값 이하 + foreach (var analysisData in parentForm._analysisDatas) { - if (highValue < bol402) analysisData.Inclusion = true; - else analysisData.Inclusion = false; - } + var startDate = analysisData.StartDate; + var endDate = analysisData.EndDate; + if (checkEdit_이전봉40_2볼린저이하.Checked) + { + var 구매이전봉 = startDate; + + //차트 Date Time 설정하기 + 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; + } + + var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉); + // 시간대 캔들이 없으면 결과에서 제외 + if (candleData == null) + { + analysisData.Description = "[오류:캔들없음]" + analysisData.Description; + analysisData.Inclusion = false; + continue; + } + + var highValue = candleData.HighValue; + + var bol402 = candleData.IndicatorDic["Bol402"]?.value; + + if (bol402 != null) + { + // 제외된 조건인 아닌 경우 + if (analysisData.Inclusion) + { + if (highValue < bol402) + { + analysisData.Inclusion = true; + analysisData.Description = '[' + checkEdit_이전봉40_2볼린저이하.Text + ']' + analysisData.Description; + } + else + analysisData.Inclusion = false; + } + + } + } + } + } + + // 이전봉40_1볼린저이하 + if (checkEdit_구매이전봉볼린저40_1이하.Checked) + { + // 구매 시점 이전 봉 40 1 볼린저 값 이하 + foreach (var analysisData in parentForm._analysisDatas) + { + var startDate = analysisData.StartDate; + var endDate = analysisData.EndDate; + + if (checkEdit_구매이전봉볼린저40_1이하.Checked) + { + var 구매이전봉 = startDate; + + //차트 Date Time 설정하기 + 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; + } + + var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉); + // 시간대 캔들이 없으면 결과에서 제외 + if (candleData == null) + { + analysisData.Description = "[오류:캔들없음]" + analysisData.Description; + analysisData.Inclusion = false; + continue; + } + + var highValue = candleData.HighValue; + + var bol401 = candleData.IndicatorDic["Bol401"]?.value; + + if (bol401 != null) + { + // 제외된 조건인 아닌 경우 + if (analysisData.Inclusion) + { + if (highValue < bol401) + { + analysisData.Inclusion = true; + analysisData.Description = '[' + checkEdit_이전봉40_2볼린저이하.Text + ']' + analysisData.Description; + } + else + analysisData.Inclusion = false; + } + + } + } + } + } + + parentForm.treeList_ResultData.RefreshDataSource(); + parentForm.CalcurateProfitAndWinRate(); + + } + + /// + /// 이전봉40_2볼린저이하 + /// + /// + /// + private void checkEdit_common_CheckedChanged(object sender, EventArgs e) + { + if(!ignoreChangedfilter) + { + calcurateFilter(); } } + private void simpleButton_찬_Click(object sender, EventArgs e) + { + progressBar1.Minimum = 0; + progressBar1.Step = 1; + progressBar1.Value = 0; + progressBar1.Maximum = parentForm._analysisDatas.Count; + + new Thread(() => test11()).Start(); + } + + private void test11() + { + + var _chartIndicatorCoditionSetups = new List(); + + _chartIndicatorCoditionSetups.Add(new BolingerConditionSetup() + { + IndicatorType = CommonProperty.IndicatorType.볼린저밴드, + Period = 40, + Squared = 1, + Description = "bol40_1", + MCandleTimeType = CommonProperty.MCandleTimeType.M1 + }); ; + + var lowAverArr = new List(); + var lowAverPlusArr = new List(); + foreach (var analysis in parentForm._analysisDatas) + { + if(analysis.BuyValue >= analysis.SellValue) + { + lowAverPlusArr.Add((analysis.SellValue - analysis.BuyValue) / analysis.BuyValue); + } + else + { + lowAverArr.Add((analysis.SellValue - analysis.BuyValue) / analysis.BuyValue); + } + UIController.next(this, progressBar1); + } + + + /* + foreach (var analysis in parentForm._analysisDatas) + { + var chartStartDate = analysis.StartDate; + var chartEndDate = analysis.EndDate; + + var data = DbServiceFunctions.GetCandleData(analysis.OriginalSearchResult.MarketData, chartStartDate, chartEndDate, CommonProperty.MCandleTimeType.M1); + + var selData = data.CandleDataLists_Im.Where(x => x.DateTime > chartStartDate && x.DateTime < chartEndDate).ToList(); + + if (selData.Count != 0) + { + + + var lowValue = selData.Min(x => x.LowValue); + if (analysis.BuyValue < analysis.SellValue) + { + lowAverPlusArr.Add((analysis.BuyValue - lowValue) / analysis.BuyValue); + } + else + { + lowAverArr.Add((analysis.BuyValue - lowValue) / analysis.BuyValue); + } + } + + UIController.next(this, progressBar1); + } + */ + double aver = 0.0; + foreach(var low in lowAverArr) + { + aver += low; + } + aver = aver / lowAverArr.Count; + + double aver2 = 0.0; + foreach (var low in lowAverPlusArr) + { + aver2 += low; + } + aver2 = aver2 / lowAverPlusArr.Count; + + aver.ToString(); + + } } } \ No newline at end of file diff --git a/Million/Manager/ExcelExport.cs b/Million/Manager/ExcelExport.cs new file mode 100644 index 0000000..c17647e --- /dev/null +++ b/Million/Manager/ExcelExport.cs @@ -0,0 +1,54 @@ + +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Spreadsheet; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Million.Manager +{ + public static class ExcelExport + { + + public static void export(String path ,List> data) + { + using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(path, SpreadsheetDocumentType.Workbook)) + { + // WorkbookPart 객체를 만듭니다. + WorkbookPart workbookPart = spreadsheetDocument.AddWorkbookPart(); + workbookPart.Workbook = new Workbook(); + + // WorksheetPart 객체를 만듭니다. + WorksheetPart worksheetPart = workbookPart.AddNewPart(); + worksheetPart.Worksheet = new Worksheet(new SheetData()); + + // Sheet 객체를 만듭니다. + Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); + Sheet sheet = new Sheet() { Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "Sheet1" }; + sheets.Append(sheet); + + // 데이터를 출력합니다. + SheetData sheetData = worksheetPart.Worksheet.GetFirstChild(); + Row headerRow = new Row(); + foreach (string key in data.First().Keys) + { + headerRow.AppendChild(new Cell() { CellValue = new CellValue(key), DataType = CellValues.String }); + } + sheetData.AppendChild(headerRow); + + foreach (var row in data) + { + Row dataRow = new Row(); + foreach (var key in row.Keys) + { + dataRow.AppendChild(new Cell() { CellValue = new CellValue(row[key].ToString()), DataType = CellValues.String }); + } + sheetData.AppendChild(dataRow); + } + } + } + } +} diff --git a/Million/Manager/UIController.cs b/Million/Manager/UIController.cs new file mode 100644 index 0000000..be0cbf6 --- /dev/null +++ b/Million/Manager/UIController.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Million.Manager +{ + public static class UIController + { + public static void next(Form subForm, ProgressBar progressBar) + { + subForm.Invoke(new MethodInvoker(delegate () + { + progressBar.PerformStep(); + })); + } + } +} diff --git a/Million/Million Core.csproj b/Million/Million Core.csproj index 0003439..2a88309 100644 --- a/Million/Million Core.csproj +++ b/Million/Million Core.csproj @@ -194,6 +194,7 @@ + @@ -203,6 +204,7 @@ +