Merge branch 'master' of http://222.96.13.116/Million
This commit is contained in:
@@ -267,11 +267,7 @@ namespace Million_Hunter
|
||||
|
||||
var totalIndicator = new List<IndicatorCoditionSetup>();
|
||||
totalIndicator.AddRange(buyIndicatorList);
|
||||
totalIndicator.AddRange(sellIndicatorList);
|
||||
|
||||
var candleTypeList = totalIndicator.Select(t => t.MCandleTimeType).ToList();
|
||||
candleTypeList.Add(CommonProperty.MCandleTimeType.M1);
|
||||
candleTypeList = candleTypeList.Distinct().ToList();
|
||||
totalIndicator.AddRange(sellIndicatorList);
|
||||
|
||||
var tableList = CommonProperty.selectedMarketOfPlaceList;
|
||||
var totalResultList = new List<SearchResult>();
|
||||
@@ -285,106 +281,45 @@ namespace Million_Hunter
|
||||
//data setting
|
||||
var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicator);
|
||||
|
||||
var dic = new Dictionary<CommonProperty.MCandleTimeType, List<List<CandleData>>>();
|
||||
|
||||
foreach (var item in candleTypeList)
|
||||
{
|
||||
var candleDataListClass = DbServiceFunctions.GetCandleData(selectTable,
|
||||
_saveResultData.StartDateTime, _saveResultData.EndDateTime, item);
|
||||
|
||||
var indicatorSetUpList = distinctIndicator.Where(t => t.MCandleTimeType == item).ToList();
|
||||
foreach (var setup in indicatorSetUpList)
|
||||
{
|
||||
setup.excute(candleDataListClass.CandleDataLists_Im);
|
||||
}
|
||||
|
||||
dic[item] = ValidationCheckManager.SplitValidationCandleDataList(candleDataListClass.CandleDataLists_Im, item);
|
||||
}
|
||||
|
||||
var resultCandleDataList = new List<CandleData>();
|
||||
// 총 데이터
|
||||
var dic = DataManager.GetStandardData(totalIndicator, _saveResultData.StartDateTime, _saveResultData.EndDateTime, selectTable, distinctIndicator, true);
|
||||
|
||||
// buy, sell 계산
|
||||
var lossIndicator = new List<IndicatorCoditionSetup>();
|
||||
//var totalCalculateCandleList = new List<CandleData>();
|
||||
|
||||
foreach (var item in dic[CommonProperty.MCandleTimeType.M1])
|
||||
resultCandleDataList.AddRange(item);
|
||||
|
||||
// 1분봉 데이터 Setting
|
||||
var resultCandleDataList = dic[CommonProperty.MCandleTimeType.M1];
|
||||
resultCandleDataList = resultCandleDataList.Where(t => _saveResultData.StartDateTime <= t.DateTime && t.DateTime < _saveResultData.EndDateTime).ToList();
|
||||
|
||||
// 최초와 cross의 조건먼저 계산이 필요함(선처리)
|
||||
var parentIndicator = totalIndicator.Where(t => t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.최초돌파 ||
|
||||
t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.크로스).ToList();
|
||||
var indiList = new List<string>();
|
||||
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();
|
||||
// Sub Indicator string list 반환
|
||||
var subIndStringiList = DataManager.GetSubIndicatorStringList(totalIndicator);
|
||||
|
||||
var subIndicator = totalIndicator.Where(t => indiList.Any(u => u == t.IndexString)).ToList();
|
||||
// Sub Indicator Class
|
||||
var subIndicator = totalIndicator.Where(t => subIndStringiList.Any(u => u == t.IndexString)).ToList();
|
||||
|
||||
// 선처리
|
||||
CalculateManager.GetCalculateIndicator(totalIndicator, subIndStringiList, lossIndicator, _saveResultData.StartDateTime,
|
||||
_saveResultData.EndDateTime, resultCandleDataList, subIndicator, dic);
|
||||
|
||||
foreach (var item in indiList)
|
||||
{
|
||||
var indicator = totalIndicator.FirstOrDefault(t => t.IndexString == item);
|
||||
if(indicator != null)
|
||||
{
|
||||
if (indicator.IndicatorType == CommonProperty.IndicatorType.가격비율)
|
||||
{
|
||||
//추후 가격도 처리 해야함 EX: 호가 단위 등등
|
||||
var temp = (PriceRateCondtionSetup)indicator;
|
||||
if(temp.PriceRateSetupConditionType == CommonProperty.PriceRateSetupConditionType.비율) {
|
||||
lossIndicator.Add(indicator);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var list = new List<CandleData>();
|
||||
|
||||
var totalIndi = totalIndicator.Select(t => t.IndexString).ToList();
|
||||
|
||||
foreach (var parent in dic[indicator.MCandleTimeType]) list.AddRange(parent);
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
// 중복계산 방지
|
||||
foreach (var item in subIndStringiList)
|
||||
totalIndi.Remove(item);
|
||||
|
||||
// 후처리
|
||||
foreach (var indicator in totalIndicator)
|
||||
{
|
||||
if (indiList.Any(t => t == indicator.IndexString)) continue;
|
||||
|
||||
if (indicator.IndicatorType == CommonProperty.IndicatorType.가격비율)
|
||||
{
|
||||
var temp = (PriceRateCondtionSetup)indicator;
|
||||
|
||||
//추후 가격도 처리 해야함 EX: 호가 단위 등등
|
||||
if (temp.PriceRateSetupConditionType == CommonProperty.PriceRateSetupConditionType.비율)
|
||||
{
|
||||
lossIndicator.Add(indicator);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var list = new List<CandleData>();
|
||||
foreach (var parent in dic[indicator.MCandleTimeType]) list.AddRange(parent);
|
||||
list = list.Where(t => _saveResultData.StartDateTime <= t.DateTime && t.DateTime < _saveResultData.EndDateTime).ToList();
|
||||
|
||||
CalculateManager.SwitchFun(indicator, list, resultCandleDataList, subIndicator);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CalculateManager.GetCalculateIndicator(totalIndicator, totalIndi, lossIndicator, _saveResultData.StartDateTime,
|
||||
_saveResultData.EndDateTime, resultCandleDataList, subIndicator, dic);
|
||||
|
||||
// 계산 로직
|
||||
var resultLsit = ResultLogicManager.GetSearchResultList(resultCandleDataList, lossIndicator,
|
||||
_saveResultData.BuyRegularExpression, _saveResultData.SellRegularExpression, selectTable, totalIndicator);
|
||||
totalResultList.AddRange(resultLsit);
|
||||
//}
|
||||
});
|
||||
|
||||
//수익 률 계산 로직 -> 이거는 추후 빼도 될듯
|
||||
double totalVal = 0;
|
||||
double win = 0;
|
||||
double lose = 0;
|
||||
|
||||
@@ -179,7 +179,6 @@
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\licenses.licx" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
@@ -114,15 +114,15 @@ namespace Million_Prototype
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<CandleDataList> list = null;
|
||||
DataSettingManager realTimeMsg = null;
|
||||
RealtimeDataSettingManager realTimeMsg = null;
|
||||
int firstFlag = 0;
|
||||
for (; ; )
|
||||
{
|
||||
if (firstFlag == 0)
|
||||
{
|
||||
realTimeMsg = new DataSettingManager(null, PaymentType.KRW);
|
||||
realTimeMsg = new RealtimeDataSettingManager(null, PaymentType.KRW);
|
||||
realTimeMsg.StartGetRealTimeTicker(null);
|
||||
var dsm = new DataSettingManager(null, PaymentType.KRW);
|
||||
var dsm = new RealtimeDataSettingManager(null, PaymentType.KRW);
|
||||
list = dsm.GetRealTimeCandleData(MCandleTimeType.M1, 200);
|
||||
firstFlag = 1;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Million.Data;
|
||||
using Million.DbManagement;
|
||||
using Million.IndicatorConditionSetup;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -501,27 +502,40 @@ namespace Million.Manager
|
||||
break;
|
||||
}
|
||||
}
|
||||
parent.CalculateFlag[setUp.IndexString] = true;
|
||||
|
||||
if (!parent.IndicatorDic.ContainsKey(key))
|
||||
{
|
||||
parent.IndicatorDic[key] = new IndicatorData();
|
||||
parent.IndicatorDic[key].overlapValue = overlapVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.IndicatorDic[key].overlapValue = overlapVal;
|
||||
}
|
||||
|
||||
childs = GetChildrenDatas(parent, setUp.MCandleTimeType, childrenCandleDataList);
|
||||
|
||||
foreach(var item in childs)
|
||||
|
||||
foreach (var item in childs)
|
||||
{
|
||||
if (item.CalculateFlag[setUp.IndexString]) continue;
|
||||
|
||||
item.CalculateFlag[setUp.IndexString] = true;
|
||||
parent.CalculateFlag[setUp.IndexString] = true;
|
||||
|
||||
|
||||
if (!(item.HighValue <= overlapVal && item.LowValue >= overlapVal))
|
||||
{
|
||||
overlapVal = item.StartValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!parent.IndicatorDic.ContainsKey(key))
|
||||
if (!item.IndicatorDic.ContainsKey(key))
|
||||
{
|
||||
parent.IndicatorDic[key] = new IndicatorData();
|
||||
parent.IndicatorDic[key] = parent.IndicatorDic[key];
|
||||
parent.IndicatorDic[key].overlapValue = overlapVal;
|
||||
}
|
||||
item.IndicatorDic[key] = new IndicatorData();
|
||||
item.IndicatorDic[key].overlapValue = overlapVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.IndicatorDic[key].overlapValue = overlapVal;
|
||||
}
|
||||
}
|
||||
|
||||
// 해당하는 봉만 True
|
||||
@@ -823,6 +837,10 @@ namespace Million.Manager
|
||||
child.IndicatorDic[key] = new IndicatorData();
|
||||
child.IndicatorDic[key] = item.IndicatorDic[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
child.IndicatorDic[key] = item.IndicatorDic[key];
|
||||
}
|
||||
|
||||
if (!trueVal)
|
||||
{
|
||||
@@ -837,7 +855,13 @@ namespace Million.Manager
|
||||
if (trueVal)
|
||||
{
|
||||
child.CalculateFlag[setUp.IndexString] = true;
|
||||
child.IndicatorDic[key].overlapValue = val;
|
||||
if(child.IndicatorDic.ContainsKey(key))
|
||||
child.IndicatorDic[key].overlapValue = val;
|
||||
else
|
||||
{
|
||||
child.IndicatorDic[key] = new IndicatorData();
|
||||
child.IndicatorDic[key].overlapValue = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1095,5 +1119,42 @@ namespace Million.Manager
|
||||
if (list.Count == count) return list;
|
||||
return new List<CandleData>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicator 계산 로직
|
||||
/// </summary>
|
||||
/// <param name="totalIndicator"></param>
|
||||
/// <param name="indiList"></param>
|
||||
/// <param name="lossIndicator"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <param name="resultCandleDataList"></param>
|
||||
/// <param name="subIndicator"></param>
|
||||
public static void GetCalculateIndicator(List<IndicatorCoditionSetup> totalIndicator, List<string> indiList, List<IndicatorCoditionSetup> lossIndicator,
|
||||
DateTime startDate, DateTime endDate, List<CandleData> resultCandleDataList, List<IndicatorCoditionSetup> subIndicator, Dictionary<MCandleTimeType, List<CandleData>> parentList)
|
||||
{
|
||||
foreach (var item in indiList)
|
||||
{
|
||||
var indicator = totalIndicator.FirstOrDefault(t => t.IndexString == item);
|
||||
if (indicator != null)
|
||||
{
|
||||
if (indicator.IndicatorType == CommonProperty.IndicatorType.가격비율)
|
||||
{
|
||||
//추후 가격도 처리 해야함 EX: 호가 단위 등등
|
||||
var temp = (PriceRateCondtionSetup)indicator;
|
||||
if (temp.PriceRateSetupConditionType == CommonProperty.PriceRateSetupConditionType.비율)
|
||||
{
|
||||
lossIndicator.Add(indicator);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var list = parentList[indicator.MCandleTimeType];
|
||||
|
||||
list = list.Where(t => startDate <= t.DateTime && t.DateTime < endDate).ToList();
|
||||
|
||||
SwitchFun(indicator, list, resultCandleDataList, subIndicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
84
Million/Manager/DataManager.cs
Normal file
84
Million/Manager/DataManager.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using Million.Data;
|
||||
using Million.DbManagement;
|
||||
using Million.IndicatorConditionSetup;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Million.CommonProperty;
|
||||
|
||||
namespace Million.Manager
|
||||
{
|
||||
/// <summary>
|
||||
/// 데이터 구성 Manager Class
|
||||
/// </summary>
|
||||
public static class DataManager
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// DB에서 데이터 가져오며 Setting 처리 함
|
||||
/// </summary>
|
||||
/// <param name="candleTypeList"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <param name="market"></param>
|
||||
/// <param name="distinctIndicator"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<MCandleTimeType, List<CandleData>> GetStandardData(List<IndicatorCoditionSetup> totalIndicator, DateTime startDate,
|
||||
DateTime endDate, MarketData market, List<IndicatorCoditionSetup> distinctIndicator, bool flag = false)
|
||||
{
|
||||
var candleTypeList = totalIndicator.Select(t => t.MCandleTimeType).ToList();
|
||||
candleTypeList.Add(CommonProperty.MCandleTimeType.M1);
|
||||
candleTypeList = candleTypeList.Distinct().ToList();
|
||||
|
||||
|
||||
var dic = new Dictionary<CommonProperty.MCandleTimeType, List<CandleData>>();
|
||||
//계산로직에 필요한 Data setting
|
||||
foreach (var item in candleTypeList)
|
||||
{
|
||||
var candleDataListClass = DbServiceFunctions.GetCandleData(market,
|
||||
startDate, endDate, item);
|
||||
|
||||
var indicatorSetUpList = distinctIndicator.Where(t => t.MCandleTimeType == item).ToList();
|
||||
foreach (var setup in indicatorSetUpList)
|
||||
{
|
||||
setup.excute(candleDataListClass.CandleDataLists_Im);
|
||||
}
|
||||
var list = new List<CandleData>();
|
||||
if (flag)
|
||||
{
|
||||
var parentData = ValidationCheckManager.SplitValidationCandleDataList(candleDataListClass.CandleDataLists_Im, item);
|
||||
foreach (var parent in parentData) list.AddRange(parent);
|
||||
dic.Add(item, list);
|
||||
}
|
||||
else
|
||||
dic.Add(item, candleDataListClass.CandleDataLists_Im);
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sub Indicator List String 반환 Function
|
||||
/// </summary>
|
||||
/// <param name="totalIndicator"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetSubIndicatorStringList(List<IndicatorCoditionSetup> totalIndicator)
|
||||
{
|
||||
// 최초와 cross의 조건먼저 계산이 필요함(선처리)
|
||||
var parentIndicator = totalIndicator.Where(t => t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.최초돌파 ||
|
||||
t.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.크로스).ToList();
|
||||
|
||||
var subIndStringiList = new List<string>();
|
||||
foreach (var item in parentIndicator)
|
||||
{
|
||||
var subRegExpression = item.FirstOverSubRegExpression;
|
||||
if (item.SubIndicatorSetupType == CommonProperty.SubIndicatorSetupType.크로스)
|
||||
subRegExpression = item.CrossSubRegExpression;
|
||||
subIndStringiList.AddRange(subRegExpression.Split(',').ToList());
|
||||
}
|
||||
subIndStringiList = subIndStringiList.Distinct().ToList();
|
||||
return subIndStringiList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Million.Manager
|
||||
/// <summary>
|
||||
/// Data Setting하는 Manager Class
|
||||
/// </summary>
|
||||
public class DataSettingManager
|
||||
public class RealtimeDataSettingManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Ticker에 들어갈 데이터
|
||||
@@ -33,7 +33,7 @@ namespace Million.Manager
|
||||
/// <summary>
|
||||
/// 생성자
|
||||
/// </summary>
|
||||
public DataSettingManager(List<string> codeFullNameList, PaymentType buyType, string tableName = "Upbit")
|
||||
public RealtimeDataSettingManager(List<string> codeFullNameList, PaymentType buyType, string tableName = "Upbit")
|
||||
{
|
||||
this.buyType = buyType;
|
||||
marketList = DbServiceFunctions.GetMarketDatas(tableName, Enum.GetName(typeof(PaymentType), buyType));
|
||||
@@ -86,7 +86,7 @@ namespace Million.Manager
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartGetRealTimeTicker(object state, int duTime = 0, int period = 50)
|
||||
{
|
||||
@@ -191,7 +191,8 @@
|
||||
</Compile>
|
||||
<Compile Include="Manager\BuyLogicManager.cs" />
|
||||
<Compile Include="Manager\CalculateManager.cs" />
|
||||
<Compile Include="Manager\DataSettingManager.cs" />
|
||||
<Compile Include="Manager\DataManager.cs" />
|
||||
<Compile Include="Manager\RealtimeDataSettingManager.cs" />
|
||||
<Compile Include="Manager\IndicatorSetupManager.cs" />
|
||||
<Compile Include="Manager\InteratorScripter.cs" />
|
||||
<Compile Include="Manager\OrderbookManager.cs" />
|
||||
|
||||
Reference in New Issue
Block a user