From e92cf14052dda0416d2ff5cb35bb3cd0a6e612e3 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 4 Oct 2022 11:30:40 +0900 Subject: [PATCH] =?UTF-8?q?Save=20=EC=9D=B4=ED=9B=84=20=EB=82=A8=EC=95=84?= =?UTF-8?q?=20=EC=9E=88=EB=8A=94=20Buy=20list=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=EB=8F=84=20SearchResultList=EC=97=90=20=EB=84=A3?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Buyer/MainForm.cs | 53 +++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/Million Buyer/MainForm.cs b/Million Buyer/MainForm.cs index d438352..099edcf 100644 --- a/Million Buyer/MainForm.cs +++ b/Million Buyer/MainForm.cs @@ -24,14 +24,19 @@ namespace Million_Buyer public partial class MainForm : Form { bool RealTimeMode = true; + public SavedResultData _saveResultData; + //결과 데이터 + public List resultDataList; + //구매 데이터 + public List buyList; + bool SetIndicator = false; bool ThreadFlag = false; Thread thread = null; - //결과 데이터 - List resultDataList = new List(); + public MainForm() { @@ -60,7 +65,9 @@ namespace Million_Buyer { BuySetupList = new List(), SellSetupList = new List() - }; + }; + resultDataList = new List(); + buyList = new List(); } /// @@ -188,7 +195,7 @@ namespace Million_Buyer _saveResultData.StartDateTime = DateTime.Now; //구매 데이터 - var buyList = new List(); + var saveFlag = true; //구매 후 데이터 여러개 계속 겹치는 경우 제외하기 위한 List @@ -363,8 +370,8 @@ namespace Million_Buyer result.BuyEarningRate.Add(rate); result.BuyValueList.Add(buyCandleData.BuyValue); result.BuyList.ConGoodsData = buyItem.ConGoodsData; - result.BuyList.CandleDataLists_Im.Add(buyItem.CandleDataLists_Im[0]); - result.StartDate = buyItem.CandleDataLists_Im[0].DateTime; + result.BuyList.CandleDataLists_Im.Add(buyCandleData); + result.StartDate = buyCandleData.DateTime; result.SellData = sellItem; result.SellValue = sellVal; result.TotalEarningRate = rate; @@ -437,7 +444,7 @@ namespace Million_Buyer //Stop 시 저장 -> Real Time의 경우 Search Result List만 저장 if (RealTimeFlag) { - SaveData(resultDataList); + SaveData(); } else { @@ -448,14 +455,10 @@ namespace Million_Buyer /// 데이터 저장 기능 /// /// - public void SaveData(List resultDataList) + public void SaveData() { if (resultDataList.Count > 0) { - _saveResultData.EndDateTime = DateTime.Now; - _saveResultData.SavedDateTime = DateTime.Now; - _saveResultData.SearchResultList = resultDataList; - //수익 률 계산 로직 -> 이거는 추후 빼도 될듯 double totalVal = 0; double win = 0; @@ -497,6 +500,30 @@ namespace Million_Buyer _saveResultData.SaveResultType = "Realtime"; _saveResultData.ExchangePlace = "Upbit"; _saveResultData.ParentId = null; + _saveResultData.EndDateTime = DateTime.Now; + _saveResultData.SavedDateTime = DateTime.Now; + + //buy list가 남아 있을 시 + if (buyList.Count > 0) + { + foreach (var item in buyList) + { + var result = new SearchResult(); + + var buyCandleData = item.CandleDataLists_Im[0]; + + result.CodeFullName = item.ConGoodsData.CodeFullName; + result.MarketData = item.ConGoodsData; + result.BuyValueList.Add(buyCandleData.BuyValue); + result.BuyList.ConGoodsData = item.ConGoodsData; + result.BuyList.CandleDataLists_Im.Add(buyCandleData); + result.StartDate = buyCandleData.DateTime; + result.BuyCount = buyCandleData.BuyCount; + resultDataList.Add(result); + } + } + + _saveResultData.SearchResultList = resultDataList; DBConnection.QueryInsertExcuter_SavedResultData(_saveResultData); @@ -513,7 +540,7 @@ namespace Million_Buyer /// private void button1_Click(object sender, EventArgs e) { - SaveData(resultDataList); + SaveData(); } ///