- 현재가 log 저장

- 정정 주문시 주문번호 log
This commit is contained in:
2017-11-07 20:33:52 +09:00
parent d4515954ce
commit bc6a5791d3
2 changed files with 25 additions and 5 deletions

View File

@@ -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<int> m_PriceList = new List<int>();
// real time, price time, price
public List<Tuple<int, int, int>> m_PriceList = new List<Tuple<int, int, int>>();
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<int, int, int>(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<AutoSeller.ITEM> UpdateItems()
{
List<AutoSeller.ITEM> aItems = new List<AutoSeller.ITEM>();
@@ -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);
}