From bc6a5791d3f454a83d9e137d53b92fba8f55e478 Mon Sep 17 00:00:00 2001 From: mjjo53 Date: Tue, 7 Nov 2017 20:33:52 +0900 Subject: [PATCH] =?UTF-8?q?-=20=ED=98=84=EC=9E=AC=EA=B0=80=20log=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20-=20=EC=A0=95=EC=A0=95=20=EC=A3=BC?= =?UTF-8?q?=EB=AC=B8=EC=8B=9C=20=EC=A3=BC=EB=AC=B8=EB=B2=88=ED=98=B8=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoSeller.cs | 2 +- CybosHelper.cs | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/AutoSeller.cs b/AutoSeller.cs index 6fb48a4..e387322 100644 --- a/AutoSeller.cs +++ b/AutoSeller.cs @@ -129,7 +129,7 @@ namespace AutoSellerNS int iAskPrice = CurItem.m_aiAskPrice[0]; m_CybosHelper.CorrectionItem(NCItem.m_strCode, NCItem.m_iOrgOrderNo, NCItem.m_iRemainCnt, iAskPrice); NCItem.m_Time = DateTime.Now; - Util.Log(Util.LOG_TYPE.SELL, string.Format("[{0}] 정정 주문", NCItem.m_strCodeName)); + Util.Log(Util.LOG_TYPE.SELL, string.Format("[{0}] 정정 주문 (주문번호: {1})", NCItem.m_strCodeName, NCItem.m_iOrgOrderNo)); } } } diff --git a/CybosHelper.cs b/CybosHelper.cs index 2853941..7622b63 100644 --- a/CybosHelper.cs +++ b/CybosHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading; @@ -28,7 +29,8 @@ namespace AutoSellerNS public int m_iTrailingCount = 0; - public List m_PriceList = new List(); + // real time, price time, price + public List> m_PriceList = new List>(); public double m_dCheckCountLimit = 5; int m_iPrevTime = 0; @@ -46,9 +48,11 @@ namespace AutoSellerNS if(bReal == true) { - m_PriceList.Add(m_iCurPrice); - double dAverage = (float)m_PriceList.Average(); - double sumOfSquaresOfDifferences = m_PriceList.Select(val => Math.Pow((val-dAverage)/m_CybosHelper.GetUnitValue(val), 2)).Sum(); + DateTime RealTime = DateTime.Now; + int iRealTime = RealTime.Hour * 10000 + RealTime.Minute * 100 + RealTime.Second; + m_PriceList.Add(new Tuple(iRealTime, iTime, m_iCurPrice)); + double dAverage = (float)m_PriceList.Average(s => s.Item3); + double sumOfSquaresOfDifferences = m_PriceList.Select(val => Math.Pow((val.Item3-dAverage)/m_CybosHelper.GetUnitValue(val.Item3), 2)).Sum(); double dStdDev = Math.Sqrt(sumOfSquaresOfDifferences / m_PriceList.Count); if(dStdDev >= Config.GetFastSD()) { @@ -191,6 +195,21 @@ namespace AutoSellerNS m_CpConclusion.Subscribe(); } + public void SavePrice(STOCK_CUR_ITEM item) + { + if (Directory.Exists(Util.GetLogPath()) == false) + Directory.CreateDirectory(Util.GetLogPath()); + + string strToday = DateTime.Now.ToString("yyyy-MM-dd"); + string strFilePath = Util.GetLogPath() + "/price-" + strToday + item.m_strCodeName + ".txt"; + string strMessage = ""; + foreach (var pair in item.m_PriceList) + { + strMessage = string.Format("[{0}] {1} ({2})", pair.Item2, pair.Item3, pair.Item1); + File.AppendAllText(strFilePath, strMessage + Environment.NewLine, new UTF8Encoding(true)); + } + } + public List UpdateItems() { List aItems = new List(); @@ -265,6 +284,7 @@ namespace AutoSellerNS { m_aStockCur[Key].m_StockCur.Unsubscribe(); m_aStockCur[Key].m_Jpbid.Unsubscribe(); + SavePrice(m_aStockCur[Key]); m_aStockCur.Remove(Key); }