버그 수정
This commit is contained in:
68
NewsForm.cs
68
NewsForm.cs
@@ -57,6 +57,7 @@ namespace NewsCrawler
|
||||
public int m_iPriceHigh = 0;
|
||||
public DateTime m_StartTime;
|
||||
public int m_iTryCnt = 0;
|
||||
public bool m_bLog = false;
|
||||
|
||||
public NEWS_ITEM m_NewsItem;
|
||||
}
|
||||
@@ -66,6 +67,9 @@ namespace NewsCrawler
|
||||
TextCondition m_Condition = null;
|
||||
ConfigForm m_ConfigForm = null;
|
||||
|
||||
DateTime m_StartTime;
|
||||
DateTime m_EndTime;
|
||||
|
||||
System.Timers.Timer m_CrawlTimer = new System.Timers.Timer();
|
||||
int m_iCrawlInterval = 500;
|
||||
bool m_bBuy = false;
|
||||
@@ -95,6 +99,9 @@ namespace NewsCrawler
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
m_StartTime = DateTime.ParseExact("09:00", "HH:mm", CultureInfo.CurrentCulture);
|
||||
m_EndTime = DateTime.ParseExact("15:30", "HH:mm", CultureInfo.CurrentCulture);
|
||||
|
||||
Config.Init();
|
||||
Util.SetLogView(tbLog);
|
||||
m_CodeList = new CodeList();
|
||||
@@ -103,6 +110,8 @@ namespace NewsCrawler
|
||||
m_Crawler = new Crawler(this);
|
||||
m_fSupplyContractRate = Config.GetSupplyContractRate();
|
||||
|
||||
Util.Log(Util.LOG_TYPE.VERVOSE, "========== NewsCrawler 실행 ==========");
|
||||
|
||||
//MessageBox.Show("Keywords : \n\n" + m_Condition.GetKeywordsCnt());
|
||||
|
||||
m_InsertListViewDelegate = new InsertListView(this.InsertItem);
|
||||
@@ -159,6 +168,8 @@ namespace NewsCrawler
|
||||
m_PriceCheckTimer.Elapsed += PriceCheckTimer_Elapsed;
|
||||
m_PriceCheckTimer.Start();
|
||||
|
||||
m_bBuy = true;
|
||||
|
||||
Test();
|
||||
}
|
||||
|
||||
@@ -201,7 +212,7 @@ namespace NewsCrawler
|
||||
|
||||
void CheckPrice(NEWS_ITEM NewsItem)
|
||||
{
|
||||
if(DateTime.Now.Hour < 9 || DateTime.Now.Hour >= 15)
|
||||
if(DateTime.Now < m_StartTime || DateTime.Now >= m_EndTime)
|
||||
return;
|
||||
|
||||
PRICE_CHECK_DATA CheckData = new PRICE_CHECK_DATA();
|
||||
@@ -241,17 +252,20 @@ namespace NewsCrawler
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.MANUAL_CODE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
|
||||
|
||||
ModelessPopup ManualPopup = new ModelessPopup(this);
|
||||
ManualPopup.SetMessage(string.Format("{0}\n[{1}] {2}\n(keyword:{3}, code:{4})\n\n매수하시겠습니까?",
|
||||
DateTime.Now.ToString("[hh:mm:ss]"),
|
||||
NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code), Code);
|
||||
ManualPopup.TopMost = true;
|
||||
ManualPopup.Show();
|
||||
if(m_bBuy == true)
|
||||
{
|
||||
ModelessPopup ManualPopup = new ModelessPopup(this);
|
||||
ManualPopup.SetMessage(string.Format("{0}\n[{1}] {2}\n(keyword:{3}, code:{4})\n\n매수하시겠습니까?",
|
||||
DateTime.Now.ToString("[hh:mm:ss]"),
|
||||
NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code), Code);
|
||||
ManualPopup.TopMost = true;
|
||||
ManualPopup.Show();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
|
||||
BuyItem(Code);
|
||||
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
|
||||
}
|
||||
|
||||
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
|
||||
@@ -319,8 +333,8 @@ namespace NewsCrawler
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1}", strRef, strTitle));
|
||||
BuyItem(Code);
|
||||
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1}", strRef, strTitle));
|
||||
}
|
||||
|
||||
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
|
||||
@@ -332,10 +346,13 @@ namespace NewsCrawler
|
||||
Config.SetSupplyContractRate(fRate);
|
||||
}
|
||||
|
||||
delegate bool IsDuplicatedURLDelegate(string strURL);
|
||||
public bool IsDuplicatedURL(string strURL)
|
||||
{
|
||||
return (strURL != "" && m_URLs.Any(s => s == strURL));
|
||||
if(strURL == "")
|
||||
return false;
|
||||
|
||||
lock(m_URLs)
|
||||
return m_URLs.Any(s => s == strURL);
|
||||
}
|
||||
|
||||
public void InsertItem(string strTitle, string strName, string strCode, DateTime time, DateTime ResTime, string strURL, string strRef, double dElapseT, bool bInitial)
|
||||
@@ -370,7 +387,8 @@ namespace NewsCrawler
|
||||
"",
|
||||
strURL }));
|
||||
|
||||
m_URLs.Add(strURL);
|
||||
lock(m_URLs)
|
||||
m_URLs.Add(strURL);
|
||||
|
||||
if(bInitial == false)
|
||||
lvList.Sort();
|
||||
@@ -493,12 +511,6 @@ namespace NewsCrawler
|
||||
lvList.Columns[chPriceHighP.Index].Width = -1;
|
||||
lvList.Columns[chPriceLowP.Index].Width = -1;
|
||||
}
|
||||
|
||||
m_Excel.AddRow(Data.m_NewsItem.m_NewsTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_ResTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_strRef, Data.m_NewsItem.m_strTitle, Data.m_NewsItem.m_fElapseT,
|
||||
Data.m_iPriceStart,
|
||||
Data.m_iPriceLow, (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
Data.m_iPriceHigh, (Data.m_iPriceHigh-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
Data.m_NewsItem.m_strURL);
|
||||
}
|
||||
|
||||
private void PriceCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
@@ -527,14 +539,26 @@ namespace NewsCrawler
|
||||
|
||||
while(m_PriceCheckList.Count > 0)
|
||||
{
|
||||
PRICE_CHECK_DATA data;
|
||||
if(m_PriceCheckList.TryPeek(out data) == false)
|
||||
PRICE_CHECK_DATA Data;
|
||||
if(m_PriceCheckList.TryPeek(out Data) == false)
|
||||
break;
|
||||
|
||||
if(data.m_iTryCnt < 3 && data.m_iPriceHigh == 0)
|
||||
if(Data.m_iTryCnt < 3 && Data.m_iPriceHigh == 0)
|
||||
break;
|
||||
|
||||
m_PriceCheckList.TryDequeue(out data);
|
||||
if(Data.m_bLog == false)
|
||||
{
|
||||
Data.m_bLog = m_Excel.AddRow(Data.m_NewsItem.m_NewsTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_ResTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_strRef, Data.m_NewsItem.m_strTitle, Data.m_NewsItem.m_fElapseT,
|
||||
Data.m_iPriceStart,
|
||||
Data.m_iPriceLow, (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
Data.m_iPriceHigh, (Data.m_iPriceHigh-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
Data.m_NewsItem.m_strURL);
|
||||
}
|
||||
|
||||
if(Data.m_bLog == false)
|
||||
break;
|
||||
|
||||
m_PriceCheckList.TryDequeue(out Data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user