Log 처리

This commit is contained in:
kyh
2022-10-07 13:46:40 +09:00
parent a2520734b0
commit 8cab39f944
2 changed files with 64 additions and 28 deletions

View File

@@ -141,7 +141,7 @@ namespace Million_Buyer
ThreadFlag = true;
bt_Start.Enabled = false;
rd_buyer.Enabled = false;
rd_Realtime.Enabled = false;
rd_Realtime.Enabled = false;
}
}
}
@@ -171,6 +171,9 @@ namespace Million_Buyer
/// </summary>
private void ThreadFunction()
{
//시간 체크
var sw = new System.Diagnostics.Stopwatch();
var dataList = new Dictionary<MCandleTimeType, List<CandleDataList>>();
var sellIndicator = _saveResultData.SellSetupList.OfType<IndicatorCoditionSetup>().ToList();
@@ -207,9 +210,10 @@ namespace Million_Buyer
RealtimeDataSettingManager realTimeMsg = null;
var standardTime = DateTime.Now;
var standardTime = DateTime.Now;
this.Invoke(new Action(delegate ()
this.BeginInvoke(new Action(delegate ()
{
lb_StartDate.Text = standardTime.ToString("yyyy-MM-dd HH:mm:ss");
}));
@@ -219,6 +223,9 @@ namespace Million_Buyer
else
InsertLog("Buyer 구동 중..");
var cnt = 0;
sw.Start();
while (ThreadFlag)
{
try
@@ -251,13 +258,18 @@ namespace Million_Buyer
firstFlag = 1;
InsertLog("Deafult Data Setting 완료..");
sw.Stop();
InsertLog("Default 계산 시간 : " + sw.Elapsed.ToString());
}
else
{
if (firstFlag == 1)
{
sw.Restart();
dataList = realTimeMsg.ProcessRecentlyCandleDatas(dataList, candleTypeList);
sw.Stop();
if(sw.Elapsed.TotalSeconds > 1)
InsertLog("Ticker 계산 시간 : " + sw.Elapsed.ToString());
}
}
#endregion
@@ -283,7 +295,7 @@ namespace Million_Buyer
var dic = new Dictionary<MCandleTimeType, List<CandleData>>();
var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicatorList);
sw.Restart();
foreach (var key in dataList.Keys)
{
var candleDataList = dataList[key].FirstOrDefault(t => t.ConGoodsData.CodeFullName == item);
@@ -295,11 +307,18 @@ namespace Million_Buyer
setup.excute(dic[key], true);
}
}
sw.Stop();
if (sw.Elapsed.TotalSeconds > 1)
InsertLog("Execute 계산 시간 : " + sw.Elapsed.ToString());
var minDateTime = dic[MCandleTimeType.M1].Select(t => t.DateTime).Min();
var maxDateTime = dic[MCandleTimeType.M1].Select(t => t.DateTime).Max().AddHours(1);
sw.Restart();
dic = IndicatorSetupManager.CalculateIndicator(dic, totalIndicatorList, minDateTime, maxDateTime, cb_UpperMainIndi.Checked, item, true);
sw.Stop();
if (sw.Elapsed.TotalSeconds > 1)
InsertLog("Indicator Calculate 계산 시간 : " + sw.Elapsed.ToString());
#endregion
#region 사고 파는 로직
@@ -323,6 +342,7 @@ namespace Million_Buyer
{
if (overlapBuyManagementList[item])
{
sw.Restart();
//if (resultDataList.Select(t => t.MarketData).ToList().Any(t => t.CodeFullName == item)) continue;
var time = DateTime.Now;
var buyData = new CandleDataList();
@@ -340,13 +360,16 @@ namespace Million_Buyer
overlapBuyManagementList[item] = false;
InsertLog(buyData.ConGoodsData.CodeFullName + " Market Data 구입 DateTime : " + time.ToString("yyyy-MM-dd HH:mm:ss"));
//grid 처리 구매항목, 구매 가격, 구매 개수, 구매시점
this.Invoke(new Action(delegate ()
this.BeginInvoke(new Action(delegate ()
{
tl_BuyList.AppendNode(new object[]
{buyData.ConGoodsData.CodeFullName, recentlyData.BuyValue, recentlyData.BuyCount, time.ToString("yyyy-MM-dd HH:mm:ss") }, null);
lb_BuyMarketCount.Text = buyList.Count.ToString();
}));
sw.Stop();
if (sw.Elapsed.TotalSeconds > 1)
InsertLog("Buy 계산 로직 : " + sw.Elapsed.ToString());
}
}
else
@@ -359,6 +382,7 @@ namespace Million_Buyer
var flag = sellScript.DicExcuteScript(recentlyData.CalculateFlag);
if (flag)
{
sw.Restart();
var buyItem = buyList.FirstOrDefault(x => x.ConGoodsData.CodeFullName == item);
var time = DateTime.Now;
@@ -397,10 +421,10 @@ namespace Million_Buyer
//처리한 buyList는 삭제
buyList.Remove(buyItem);
InsertLog(buyItem.ConGoodsData.CodeFullName + " Market Data 판매 DateTime : " + time.ToString("yyyy-MM-dd HH:mm:ss"));
this.Invoke(new Action(delegate ()
this.BeginInvoke(new Action(delegate ()
{
//Grid 처리
TreeListNode buyNode = null;
//Grid 처리
TreeListNode buyNode = null;
foreach (TreeListNode node in tl_BuyList.Nodes)
{
@@ -435,8 +459,8 @@ namespace Million_Buyer
totalRate += resultData.FirstEarningRate;
if (!RealTimeFlag)
{
// 총 돈량 측정
totalMoneyValue += (resultData.SellValue * (1 - 0.0005) - resultData.BuyValueList[0] * (1 - 0.0005)) * resultData.BuyCount;
// 총 돈량 측정
totalMoneyValue += (resultData.SellValue * (1 - 0.0005) - resultData.BuyValueList[0] * (1 - 0.0005)) * resultData.BuyCount;
}
}
@@ -445,9 +469,17 @@ namespace Million_Buyer
if (!RealTimeFlag)
lb_TotalMoneyValue.Text = totalMoneyValue + "원";
}));
if (sw.Elapsed.TotalSeconds > 1)
InsertLog("Sell 계산 로직 : " + sw.Elapsed.ToString());
}
}
#endregion
}
cnt++;
if(cnt%60 == 0)
{
InsertLog("Scanning......" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
cnt = 0;
}
}
catch (Exception e)
@@ -566,7 +598,8 @@ namespace Million_Buyer
/// <param name="log"></param>
private void InsertLog(string log)
{
this.Invoke(new Action(delegate ()
this.BeginInvoke(new Action(delegate ()
{
if (lb_log.Items.Count > 500)
{