- 이투데이 rss 추가

- 요청 시간, 받은 시간 추가
- CYBOS 뉴스 추가
- 중복종목 버그 수정
- 실행시 키워드 수 추가
This commit is contained in:
2016-12-27 10:49:19 +09:00
parent a93faf9eb5
commit a93d3a8f45
5 changed files with 237 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
@@ -15,8 +16,15 @@ namespace NewsCrawler
CPTRADELib.CpTd0311 m_CP0311 = new CPTRADELib.CpTd0311();
bool m_bInitialized = false;
public CybosHelper()
System.Timers.Timer m_timer = new System.Timers.Timer();
ushort m_uiLastReqT = 0;
NewsForm m_Listener = null;
public CybosHelper(NewsForm Listener)
{
m_Listener = Listener;
short iResult = m_CPUtil.TradeInit();
switch(iResult)
{
@@ -41,6 +49,56 @@ namespace NewsCrawler
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 취소되었습니다");
break;
}
m_timer.Interval = 1000;
m_timer.Elapsed += M_timer_Elapsed;
m_timer.Start();
}
private void M_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
m_timer.Enabled = false;
if(GetLimitRemainCountTrace() < 5)
return;
CPSYSDIBLib.CpMarketWatch Watch = new CPSYSDIBLib.CpMarketWatch();
Watch.SetInputValue(0, "*");
Watch.SetInputValue(1, "1,2");
Watch.SetInputValue(2, 0);
Watch.BlockRequest2(0);
ushort uiLatestT = 0;
int iCount = Watch.GetHeaderValue(2);
if(iCount > 0)
uiLatestT = Watch.GetDataValue(0, 0);
for(int i = 0; i<iCount; i++)
{
ushort uiTime = Watch.GetDataValue(0, i);
string strCode = Watch.GetDataValue(1, i);
string strName = Watch.GetDataValue(2, i);
ushort uiType = Watch.GetDataValue(3, i);
string strContents = Watch.GetDataValue(4, i);
if(uiTime <= m_uiLastReqT)
break;
if(m_uiLastReqT > 0)
{
m_Listener.InsertItem(strContents, "", strCode,
DateTime.ParseExact(uiTime.ToString("0000"), "HHmm", CultureInfo.CurrentCulture),
DateTime.Now,
"", "CYBOS", 0, m_uiLastReqT>0);
}
//Console.WriteLine(string.Format("[{0}][{1}] {2} ({3}:{4})", uiTime, uiType, strContents, strName, strCode));
}
m_uiLastReqT = uiLatestT;
m_timer.Enabled = true;
}
public string[] GetAccounts()