개발중
This commit is contained in:
78
ULDataMgr.cs
78
ULDataMgr.cs
@@ -73,6 +73,9 @@ namespace upper_limit_crawler
|
||||
List<BID_LOG> m_BidLogs = new List<BID_LOG>();
|
||||
List<ASK_LOG> m_AskLogs = new List<ASK_LOG>();
|
||||
|
||||
List<BID_LOG> m_BidLogsSimul = new List<BID_LOG>();
|
||||
List<ASK_LOG> m_AskLogsSimul = new List<ASK_LOG>();
|
||||
|
||||
long m_iCacheBalance = 0;
|
||||
long m_iEvalProfit = 0;
|
||||
|
||||
@@ -86,9 +89,11 @@ namespace upper_limit_crawler
|
||||
else
|
||||
m_AvailableList = new List<string>();
|
||||
|
||||
m_BidLogs = GetBidLog(m_strToday);
|
||||
m_AskLogs = GetAskLog(m_strToday);
|
||||
}
|
||||
m_BidLogs = GetBidLog(m_strToday, true);
|
||||
m_AskLogs = GetAskLog(m_strToday, true);
|
||||
m_BidLogsSimul = GetBidLog(m_strToday, false);
|
||||
m_AskLogsSimul = GetAskLog(m_strToday, false);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
@@ -223,9 +228,9 @@ namespace upper_limit_crawler
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBidLog(string strCode, string strCodeName, int iTime, int iBidPrice, float f5MAslope)
|
||||
public void AddBidLog(string strCode, string strCodeName, int iTime, int iBidPrice, float f5MAslope, bool bReal)
|
||||
{
|
||||
string strKey = "bid-"+m_strToday;
|
||||
string strKey = bReal ? "bid-"+m_strToday : "bid-simul-"+m_strToday;
|
||||
|
||||
BID_LOG log = new BID_LOG();
|
||||
log.m_strCode = strCode;
|
||||
@@ -233,23 +238,31 @@ namespace upper_limit_crawler
|
||||
log.m_iTime = iTime;
|
||||
log.m_iBidPrice = iBidPrice;
|
||||
log.m_f5MAslope = f5MAslope;
|
||||
m_BidLogs.Add(log);
|
||||
|
||||
m_DB.Insert(strKey, m_BidLogs);
|
||||
if(bReal == true)
|
||||
{
|
||||
m_BidLogs.Add(log);
|
||||
m_DB.Insert(strKey, m_BidLogs);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BidLogsSimul.Add(log);
|
||||
m_DB.Insert(strKey, m_BidLogsSimul);
|
||||
}
|
||||
}
|
||||
|
||||
List<BID_LOG> GetBidLog(string strDate)
|
||||
List<BID_LOG> GetBidLog(string strDate, bool bReal)
|
||||
{
|
||||
string strKey = "bid-"+strDate;
|
||||
string strKey = bReal ? "bid-"+m_strToday : "bid-simul-"+m_strToday;
|
||||
if(m_DB.IsExist(strKey) == true)
|
||||
return m_DB.Get<List<BID_LOG>>(strKey);
|
||||
else
|
||||
return new List<BID_LOG>();
|
||||
}
|
||||
|
||||
public void AddAskLog(string strCode, string strCodeName, int iTime, int iAskPrice, float f5MAslope, bool bLosscut, int iProfit, float fProfitRate)
|
||||
public void AddAskLog(string strCode, string strCodeName, int iTime, int iAskPrice, float f5MAslope, bool bLosscut, int iProfit, float fProfitRate, bool bReal)
|
||||
{
|
||||
string strKey = "ask-"+m_strToday;
|
||||
string strKey = bReal ? "ask-"+m_strToday : "ask-simul-"+m_strToday;
|
||||
|
||||
ASK_LOG log = new ASK_LOG();
|
||||
log.m_strCode = strCode;
|
||||
@@ -260,33 +273,52 @@ namespace upper_limit_crawler
|
||||
log.m_bLosscut = bLosscut;
|
||||
log.m_iProfit = iProfit;
|
||||
log.m_fProfitRate = fProfitRate;
|
||||
m_AskLogs.Add(log);
|
||||
|
||||
m_DB.Insert(strKey, m_AskLogs);
|
||||
if(bReal == true)
|
||||
{
|
||||
m_AskLogs.Add(log);
|
||||
m_DB.Insert(strKey, m_AskLogs);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AskLogsSimul.Add(log);
|
||||
m_DB.Insert(strKey, m_AskLogsSimul);
|
||||
}
|
||||
}
|
||||
|
||||
List<ASK_LOG> GetAskLog(string strDate)
|
||||
List<ASK_LOG> GetAskLog(string strDate, bool bReal)
|
||||
{
|
||||
string strKey = "ask-"+strDate;
|
||||
string strKey = bReal ? "ask-"+m_strToday : "ask-simul-"+m_strToday;
|
||||
|
||||
if(m_DB.IsExist(strKey) == true)
|
||||
return m_DB.Get<List<ASK_LOG>>(strKey);
|
||||
else
|
||||
return new List<ASK_LOG>();
|
||||
}
|
||||
|
||||
public void DumpLog()
|
||||
public void DumpLog(bool bReal)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach(string strCode in m_AvailableList)
|
||||
sb.AppendLine(strCode+",");
|
||||
sb.AppendLine("\"" +strCode+ "\",");
|
||||
|
||||
foreach(BID_LOG log in m_BidLogs)
|
||||
sb.AppendFormat("매수, {0}, {1}, {2}, {3}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iBidPrice, log.m_f5MAslope.ToString("0.00%"));
|
||||
foreach(ASK_LOG log in m_AskLogs)
|
||||
sb.AppendFormat("매도, {0}, {1}, {2}, {3}, {4}, {5}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iAskPrice, log.m_f5MAslope.ToString("0.00%"), log.m_iProfit, log.m_fProfitRate.ToString("0.00%"));
|
||||
|
||||
System.IO.File.WriteAllText(ULUtil.GetLogDir()+"dblog-"+m_strToday+".csv", sb.ToString(), Encoding.UTF8);
|
||||
if(bReal == true)
|
||||
{
|
||||
foreach(BID_LOG log in m_BidLogs)
|
||||
sb.AppendFormat("매수, {0}, {1}, {2}, {3}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iBidPrice, log.m_f5MAslope.ToString("0.00%"));
|
||||
foreach(ASK_LOG log in m_AskLogs)
|
||||
sb.AppendFormat("매도, {0}, {1}, {2}, {3}, {4}, {5}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iAskPrice, log.m_f5MAslope.ToString("0.00%"), log.m_iProfit, log.m_fProfitRate.ToString("0.00%"));
|
||||
System.IO.File.WriteAllText(ULUtil.GetLogDir()+"dblog-"+m_strToday+".csv", sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(BID_LOG log in m_BidLogsSimul)
|
||||
sb.AppendFormat("매수, {0}, {1}, {2}, {3}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iBidPrice, log.m_f5MAslope.ToString("0.00%"));
|
||||
foreach(ASK_LOG log in m_AskLogsSimul)
|
||||
sb.AppendFormat("매도, {0}, {1}, {2}, {3}, {4}, {5}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iAskPrice, log.m_f5MAslope.ToString("0.00%"), log.m_iProfit, log.m_fProfitRate.ToString("0.00%"));
|
||||
System.IO.File.WriteAllText(ULUtil.GetLogDir()+"dblog-simul-"+m_strToday+".csv", sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user