diff --git a/Million Hunter/MainForm.cs b/Million Hunter/MainForm.cs index 2f8cbd4..9fc29d6 100644 --- a/Million Hunter/MainForm.cs +++ b/Million Hunter/MainForm.cs @@ -273,12 +273,13 @@ namespace Million_Hunter var tableList = CommonProperty.selectedMarketOfPlaceList; var totalResultList = new List(); - //임시로 하나만 + Parallel.For(0, tableList.Count, i => { + //임시로 하나만 //for (var i = 0; i < tableList.Count; i++) //{ - var selectTable = tableList[i]; + var selectTable = tableList[i]; //data setting var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicator); @@ -310,15 +311,22 @@ namespace Million_Hunter resultCandleDataList = resultCandleDataList.Where(t => _saveResultData.StartDateTime <= t.DateTime && t.DateTime < _saveResultData.EndDateTime).ToList(); // 최초와 cross의 조건먼저 계산이 필요함(선처리) - var subIndicator = totalIndicator.Where(t => t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.최초돌파 || + var parentIndicator = totalIndicator.Where(t => t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.최초돌파 || t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.크로스).ToList(); var indiList = new List(); - foreach(var item in subIndicator) - indiList.AddRange(item.FirstOverSubRegExpression.Split(',').ToList()); - + foreach(var item in parentIndicator) + { + var subRegExpression = item.FirstOverSubRegExpression; + if (item.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.크로스) + subRegExpression = item.CrossSubRegExpression; + indiList.AddRange(subRegExpression.Split(',').ToList()); + } indiList = indiList.Distinct().ToList(); - - foreach(var item in indiList) + + var subIndicator = totalIndicator.Where(t => indiList.Any(u => u == t.IndexString)).ToList(); + + + foreach (var item in indiList) { var indicator = totalIndicator.FirstOrDefault(t => t.IndexString == item); if(indicator != null) @@ -364,16 +372,15 @@ namespace Million_Hunter list = list.Where(t => _saveResultData.StartDateTime <= t.DateTime && t.DateTime < _saveResultData.EndDateTime).ToList(); CalculateManager.SwitchFun(indicator, list, resultCandleDataList, subIndicator); - //totalCalculateCandleList.AddRange(CalculateManager.SwitchFun(indicator, list, resultCandleDataList)); + } - //계산되지 않는 범위의 데이터 Filter - //totalCalculateCandleList = totalCalculateCandleList.Where(t => t.DateTime >= _saveResultData.StartDateTime && t.DateTime < _saveResultData.EndDateTime).ToList(); + var resultLsit = ResultLogicManager.GetSearchResultList(resultCandleDataList, lossIndicator, _saveResultData.BuyRegularExpression, _saveResultData.SellRegularExpression, selectTable, totalIndicator); totalResultList.AddRange(resultLsit); - //} + //} }); double totalVal = 0; diff --git a/Million/Manager/CalculateManager.cs b/Million/Manager/CalculateManager.cs index 051b2c1..2d81efb 100644 --- a/Million/Manager/CalculateManager.cs +++ b/Million/Manager/CalculateManager.cs @@ -428,30 +428,32 @@ namespace Million.Manager for (var i = 0; i < parentCandleDataList.Count; i++) { var parent = parentCandleDataList[i]; - if (!parent.IndicatorDic.ContainsKey(subSetup.IndexString)) continue; + var subKey = GetKeyData(subSetup); + if (!parent.IndicatorDic.ContainsKey(subKey)) continue; - var subIndiOverlapVal = parent.IndicatorDic[subSetup.IndexString].overlapValue; - var overlapValue = parent.IndicatorDic[setUp.IndexString].overlapValue; + var subIndiOverlapVal = parent.IndicatorDic[subKey].overlapValue; + + var overlapValue = GetValueData(setUp, parent, key); // 고가 - if(type == 1) + if (type == 1) { - if (parent.IndicatorDic[subSetup.IndexString].highValue != 0 && - parent.IndicatorDic[setUp.IndexString].highValue != 0) + if (parent.IndicatorDic[subKey].highValue != 0 && + parent.IndicatorDic[key].highValue != 0) { - subIndiOverlapVal = parent.IndicatorDic[subSetup.IndexString].highValue; - overlapValue = parent.IndicatorDic[setUp.IndexString].highValue; + subIndiOverlapVal = parent.IndicatorDic[subKey].highValue; + overlapValue = parent.IndicatorDic[key].highValue; } } // 저가 if(type == 2) { - if (parent.IndicatorDic[subSetup.IndexString].lowValue != 0 && - parent.IndicatorDic[setUp.IndexString].lowValue != 0) + if (parent.IndicatorDic[subKey].lowValue != 0 && + parent.IndicatorDic[key].lowValue != 0) { - subIndiOverlapVal = parent.IndicatorDic[subSetup.IndexString].lowValue; - overlapValue = parent.IndicatorDic[setUp.IndexString].lowValue; + subIndiOverlapVal = parent.IndicatorDic[subKey].lowValue; + overlapValue = parent.IndicatorDic[key].lowValue; } } @@ -489,7 +491,7 @@ namespace Million.Manager if (((MovingAverageConditionSetup)subSetup).MovingAverageType == MovingAverageType.거래량) childs = GetChildrenDatas(parent, subSetup.MCandleTimeType, childrenCandleDataList); - var subIndiOver = setUp.GetQuoteValue(subList, childs); + var subIndiOver = subSetup.GetQuoteValue(subList, childs); double overlapVal = 0; foreach(var item in indiOver) { @@ -504,55 +506,22 @@ namespace Million.Manager foreach(var item in childs) { - if(item.EndValue > overlapVal) + if (item.CalculateFlag[setUp.IndexString]) continue; + + item.CalculateFlag[setUp.IndexString] = true; + parent.CalculateFlag[setUp.IndexString] = true; + + if (!(item.HighValue <= overlapVal && item.LowValue >= overlapVal)) { - if (item.CalculateFlag[setUp.IndexString]) continue; + overlapVal = item.StartValue; + } - item.CalculateFlag[setUp.IndexString] = true; - parent.CalculateFlag[setUp.IndexString] = true; - - if (parent.IndicatorDic.ContainsKey(key)) - { - parent.IndicatorDic[key].overlapValue = overlapVal; - } - else - { - parent.IndicatorDic[key] = new IndicatorData(); - parent.IndicatorDic[key] = parent.IndicatorDic[key]; - parent.IndicatorDic[key].overlapValue = overlapVal; - } - - if (item.IndicatorDic.ContainsKey(key)) - { - if (setUp.CrossType == CrossType.CrossOverStatus) - { - item.IndicatorDic[key].overlapValue = overlapVal; - } - else - { - if (item.StartValue > overlapVal) - item.IndicatorDic[key].overlapValue = item.StartValue; - else - item.IndicatorDic[key].overlapValue = overlapVal; - } - } - else - { - item.IndicatorDic[key] = new IndicatorData(); - item.IndicatorDic[key] = parent.IndicatorDic[key]; - if (setUp.CrossType == CrossType.CrossOverStatus) - { - item.IndicatorDic[key].overlapValue = overlapVal; - } - else - { - if (item.StartValue > overlapVal) - item.IndicatorDic[key].overlapValue = item.StartValue; - else - item.IndicatorDic[key].overlapValue = overlapVal; - } - } - } + if (!parent.IndicatorDic.ContainsKey(key)) + { + parent.IndicatorDic[key] = new IndicatorData(); + parent.IndicatorDic[key] = parent.IndicatorDic[key]; + parent.IndicatorDic[key].overlapValue = overlapVal; + } } // 해당하는 봉만 True @@ -780,7 +749,7 @@ namespace Million.Manager { if (!item.IndicatorDic.ContainsKey(key)) continue; double value = GetValue(item, setUp); - var overlapData = GetOverlapValueData(setUp, item, key); + var overlapData = GetValueData(setUp, item, key); if (CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, value)) { @@ -930,6 +899,37 @@ namespace Million.Manager return false; } + /// + /// 계산된 값 가져오는 함수 + /// + /// + /// + /// + /// + private static double GetValueData(IndicatorCoditionSetup setUp, CandleData candleData, string key) + { + var data = candleData.IndicatorDic[key].value; + + #region 비교할 데이터 추출 + if (candleData.IndicatorDic[key].GetType() == typeof(IchimokData)) + { + if (((IchimokuConditionSetup)setUp).IndicatorIchmokuOverLine == CommonProperty.Indicator_IchmokuOverLine.선행스팬1) + { + data = ((IchimokData)candleData.IndicatorDic[key]).value; + } + else if (((IchimokuConditionSetup)setUp).IndicatorIchmokuOverLine == CommonProperty.Indicator_IchmokuOverLine.선행스팬2) + { + data = ((IchimokData)candleData.IndicatorDic[key]).value2; + } + else if (((IchimokuConditionSetup)setUp).IndicatorIchmokuOverLine == CommonProperty.Indicator_IchmokuOverLine.선행스팬1OR2중고가) + { + data = ((IchimokData)candleData.IndicatorDic[key]).GetOverValue(); + } + } + #endregion + return data; + } + /// /// 조건별 Overlap value 데이터 리턴 /// @@ -955,7 +955,7 @@ namespace Million.Manager { overlapData = ((IchimokData)candleData.IndicatorDic[key]).GetOverValue(); } - } + } #endregion return overlapData; }