hunter realtime 모드 수정 완

1. Log manager 이용하여 데이터 처리할 수 있도록 수정
2. Json 메모리참조관련 Serialize할때 에러 안나도록 JsonIgnore 추가
This commit is contained in:
kyh
2022-11-30 11:28:12 +09:00
parent 33a840069a
commit d69e6310a3
6 changed files with 61 additions and 14 deletions

View File

@@ -289,6 +289,8 @@ namespace Million
CommonProperty.DownBeforeValueFlag = cb_DownBeforeValueFlag.Checked;
var hunterMode = rd_Hunter.Checked;
var buyScript = new InteratorScripter("Buy Script");
buyScript.regularExpressionString = _saveResultData.BuyRegularExpression;
@@ -297,10 +299,13 @@ namespace Million
var sellExceptionScript = new InteratorScripter("Sell Exception Script");
sellExceptionScript.regularExpressionString = _saveResultData.SellExceptionRegularExpression;
CommonProperty.InsertLogFlag = false;
Parallel.For(0, tableList.Count, i =>
{
var market = tableList[i];
var item = market.CoinFullName;
// for (var i = 0; i < tableList.Count; i++)
//{
var market = tableList[i];
var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicator);
if (hunterMode)
@@ -313,6 +318,7 @@ namespace Million
totalResultList.AddRange(CalculateHunterRealtime(totalIndicator, startDate, endDate,
market, distinctIndicator, overlapBuyManagementList, buyScript, sellScript, sellExceptionScript));
}
//}
});
//수익 률 계산 로직 -> 이거는 추후 빼도 될듯
@@ -425,19 +431,18 @@ namespace Million
var mTotalDataList = DbServiceFunctions.GetCandleData(market, startDate, endDate);
foreach (var minData in mTotalDataList.CandleDataLists_Im)
{
var compareMin = standardData[CommonProperty.MCandleTimeType.M1].LastOrDefault();
if (compareMin.DateTime == minData.DateTime) continue;
if (compareMin == null || compareMin.DateTime == minData.DateTime || compareMin.DateTime > minData.DateTime) continue;
//remove
standardData[CommonProperty.MCandleTimeType.M1].RemoveAt(0);
if (standardData[CommonProperty.MCandleTimeType.H1].Count > 300)
standardData[CommonProperty.MCandleTimeType.H1].RemoveAt(0);
//1분씩 증가하면서 1h 처리
minData.RecentlyDataFlag = true;
standardData[CommonProperty.MCandleTimeType.M1].Add(minData);
var compareHour = standardData[CommonProperty.MCandleTimeType.H1].LastOrDefault();
if (compareHour.DateTime.Hour != minData.DateTime.Hour)
@@ -460,13 +465,14 @@ namespace Million
}
else
{
compareHour.HighValue = compareHour.HighValue < compareMin.HighValue ? compareMin.HighValue : compareHour.HighValue;
compareHour.LowValue = compareHour.LowValue < compareMin.LowValue ? compareMin.LowValue : compareHour.LowValue;
compareHour.EndValue = compareMin.EndValue;
compareHour.HighValue = compareHour.HighValue < minData.HighValue ? minData.HighValue : compareHour.HighValue;
compareHour.LowValue = compareHour.LowValue < minData.LowValue ? compareHour.LowValue : minData.LowValue;
compareHour.EndValue = minData.EndValue;
compareHour.RecentlyDataFlag = true;
}
//1분씩 증가하면서 1h 처리
standardData = DataManager.GetExecuteData(standardData, totalIndicator);
var minDateTime = standardData[CommonProperty.MCandleTimeType.M1].Select(t => t.DateTime).Min();
var maxDateTime = standardData[CommonProperty.MCandleTimeType.M1].Select(t => t.DateTime).Max().AddHours(1);
@@ -488,7 +494,6 @@ namespace Million
if (!buyList.Any(t => t.ConGoodsData.CoinFullName == item))
{
var flag = buyScript.DicExcuteScript(recentlyData.CalculateFlag);
if (flag)
{
@@ -559,6 +564,19 @@ namespace Million
}
}
}
if(buyList.Count > 0)
{
foreach(var buy in buyList)
{
var lastData = mTotalDataList.CandleDataLists_Im.LastOrDefault();
lastData.SellValue = lastData.EndValue;
lastData.SellTime = new DateTime(2000, 1, 1);
var result = DataManager.GetBuyerSearchResult(buy.CandleDataLists_Im[0], mTotalDataList.CandleDataLists_Im.LastOrDefault(), buy.ConGoodsData);
resultData.Add(result);
}
}
return resultData;
}

View File

@@ -338,6 +338,8 @@ namespace Million
public static string DataExtend = ".data";
// Save 결과 분석 데이터
public static string AnalysisExtendFolder = "_analysis";
public static bool InsertLogFlag = true;
#endregion
#region Buyer Flag

View File

@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using static Million.CommonProperty;
@@ -37,6 +38,7 @@ namespace Million.Data
public Dictionary<string, bool> SellLogicFlag { get; set; } = new Dictionary<string, bool>();
public Dictionary<string, bool> CalculateFlag { get; set; } = new Dictionary<string, bool>();
[JsonIgnore]
public Dictionary<MCandleTimeType, CandleData> ParentCandleData = new Dictionary<MCandleTimeType, CandleData>();

View File

@@ -679,7 +679,7 @@ namespace Million.Manager
if (recentlyDataFlag)
{
if (!subManagement[coinFullName])
if (!subManagement[coinFullName] && CommonProperty.InsertLogFlag)
{
str = "Buyer(Realtime) Mode\r\n";
str += coinFullName + " 최초 돌파 Sub조건 초기화 됨\r\n";

View File

@@ -69,7 +69,7 @@ namespace Million.Manager
}
/// <summary>
/// Recently Data관련 Data Setting 및 데이터 들고오기
/// Data Indicator Execute
/// </summary>
/// <param name="dataList"></param>
/// <param name="totalIndicatorList"></param>
@@ -94,6 +94,29 @@ namespace Million.Manager
return dic;
}
/// <summary>
/// Data Indicator Execute
/// </summary>
/// <param name="dataList"></param>
/// <param name="totalIndicatorList"></param>
/// <returns></returns>
public static Dictionary<MCandleTimeType, List<CandleData>> GetExecuteData(Dictionary<MCandleTimeType, List<CandleData>> dataList, List<IndicatorCoditionSetup> totalIndicatorList)
{
var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicatorList);
foreach (var key in dataList.Keys)
{
var indicatorSetUpList = distinctIndicator.Where(t => t.MCandleTimeType == key).ToList();
foreach (var setup in indicatorSetUpList)
{
setup.excute(dataList[key], true);
}
}
return dataList;
}
/// <summary>
/// Sub Indicator List String 반환 Function
/// </summary>

View File

@@ -25,6 +25,8 @@ namespace Million.Manager
/// <returns></returns>
public static bool WriteLog(string message, string coinFullName = "")
{
if (!CommonProperty.InsertLogFlag) return false;
if (coinFullName == "") coinFullName = "common";
var returnData = true;
var defaultMesage = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "=>" + message +"\r\n";