From eb99c5a8ad33f43e1e9fad7fd059dfa631a97532 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1A3P75F\\lee" Date: Wed, 10 May 2023 12:14:42 +0900 Subject: [PATCH 1/2] =?UTF-8?q?openxml=20=EC=97=91=EC=85=80=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80,=20?= =?UTF-8?q?=EC=8A=B9=ED=8C=A8=EC=8B=9C=20=EC=88=98=EC=9D=B5=EB=A5=A0=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Hunter/HunterSubForm/TestBoardForm.cs | 88 +++++++++++-------- Million/Manager/ExcelExport.cs | 54 ++++++++++++ Million/Million Core.csproj | 1 + 3 files changed, 106 insertions(+), 37 deletions(-) create mode 100644 Million/Manager/ExcelExport.cs diff --git a/Million Hunter/HunterSubForm/TestBoardForm.cs b/Million Hunter/HunterSubForm/TestBoardForm.cs index 329e132..33a1547 100644 --- a/Million Hunter/HunterSubForm/TestBoardForm.cs +++ b/Million Hunter/HunterSubForm/TestBoardForm.cs @@ -363,50 +363,64 @@ namespace Million_Hunter.HunterSubForm var lowAverArr = new List(); var lowAverPlusArr = new List(); - 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) + if(analysis.BuyValue >= analysis.SellValue) { - - - 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); - } + lowAverPlusArr.Add((analysis.SellValue - analysis.BuyValue) / analysis.BuyValue); + } + else + { + lowAverArr.Add((analysis.SellValue - analysis.BuyValue) / analysis.BuyValue); } - UIController.next(this, progressBar1); } - double aver = 0.0; - foreach(var low in lowAverArr) - { - aver += low; + + /* + 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(); + } - 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/Million Core.csproj b/Million/Million Core.csproj index 80ae6ef..2a88309 100644 --- a/Million/Million Core.csproj +++ b/Million/Million Core.csproj @@ -194,6 +194,7 @@ + From f6b69c2c6b41aadc09dc0655ff0e736a9c7f95d8 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Wed, 10 May 2023 12:20:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=88=98=20=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million/IndicatorConditionSetup/CompareConditionSetup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Million/IndicatorConditionSetup/CompareConditionSetup.cs b/Million/IndicatorConditionSetup/CompareConditionSetup.cs index a7e5001..d0a20e0 100644 --- a/Million/IndicatorConditionSetup/CompareConditionSetup.cs +++ b/Million/IndicatorConditionSetup/CompareConditionSetup.cs @@ -7,6 +7,7 @@ using static Million.CommonProperty; namespace Million.IndicatorConditionSetup { + [Serializable] /// /// Compare 조건식 ///