버그 수정
This commit is contained in:
12
CodeList.cs
12
CodeList.cs
@@ -82,6 +82,8 @@ namespace NewsCrawler
|
||||
|
||||
void MakeList()
|
||||
{
|
||||
CPUTILLib.CpCodeMgr CodeMgr = new CPUTILLib.CpCodeMgr();
|
||||
|
||||
int iCnt = m_StockCode.GetCount();
|
||||
for(short i = 0; i<iCnt; i++)
|
||||
{
|
||||
@@ -90,9 +92,17 @@ namespace NewsCrawler
|
||||
Code.m_strCode = m_StockCode.GetData(0, i);
|
||||
Code.m_strName = m_StockCode.GetData(1, i);
|
||||
|
||||
if(Code.m_strCode[0] == 'A')
|
||||
var CodeMarketKind = CodeMgr.GetStockMarketKind(Code.m_strCode);
|
||||
var CodeSectionKind = CodeMgr.GetStockSectionKind(Code.m_strCode);
|
||||
|
||||
if(Code.m_strCode[0] == 'A' &&
|
||||
(CodeMarketKind != CPUTILLib.CPE_MARKET_KIND.CPC_MARKET_FREEBOARD) &&
|
||||
(CodeSectionKind == CPUTILLib.CPE_KSE_SECTION_KIND.CPC_KSE_SECTION_KIND_NULL ||
|
||||
CodeSectionKind == CPUTILLib.CPE_KSE_SECTION_KIND.CPC_KSE_SECTION_KIND_ST))
|
||||
{
|
||||
m_CodeList.Add(Code);
|
||||
}
|
||||
}
|
||||
|
||||
m_CodeList.Sort((a, b) => b.m_strName.Length-a.m_strName.Length);
|
||||
}
|
||||
|
||||
17
Crawler.cs
17
Crawler.cs
@@ -20,6 +20,8 @@ namespace NewsCrawler
|
||||
public Crawler(NewsForm Listener)
|
||||
{
|
||||
m_Listener = Listener;
|
||||
|
||||
Test();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +35,14 @@ namespace NewsCrawler
|
||||
public string m_strAuthKey = "";
|
||||
};
|
||||
|
||||
void Test()
|
||||
{
|
||||
if(Util.IsDebugging() == false)
|
||||
return;
|
||||
|
||||
ReadSupplyContract(false, "강스템바이오텍", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170111900149");
|
||||
}
|
||||
|
||||
void ResponseAsiaE(IAsyncResult result)
|
||||
{
|
||||
REQUEST_STATUS State = (REQUEST_STATUS)result.AsyncState;
|
||||
@@ -850,6 +860,8 @@ namespace NewsCrawler
|
||||
string strXPath = "//div[@class='categoryList']//li";
|
||||
|
||||
var lists = doc.DocumentNode.SelectNodes(strXPath);
|
||||
try
|
||||
{
|
||||
foreach(var item in lists)
|
||||
{
|
||||
string strTitle = item.SelectNodes(".//a")[1].InnerText;
|
||||
@@ -864,6 +876,11 @@ namespace NewsCrawler
|
||||
m_Listener.InsertItem(strTitle, "", "", Time, DateTime.Now, strURL, "파이낸셜뉴스", State.m_Timer.Elapsed.TotalMilliseconds, bInitial);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,11 +105,14 @@ namespace NewsCrawler
|
||||
while(GetLimitRemainCountRQ() < 1)
|
||||
Thread.Sleep(100);
|
||||
|
||||
lock(m_CPStockMst)
|
||||
{
|
||||
m_CPStockMst.SetInputValue(0, Code.m_strCode);
|
||||
m_CPStockMst.BlockRequest2(0);
|
||||
int iCurPrice = m_CPStockMst.GetHeaderValue(11);
|
||||
return iCurPrice;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetLowHighPrice(CodeList.CODE_VALUE Code, DateTime StartTime, int iAfterMin, out int iPriceLow, out int iPriceHigh)
|
||||
{
|
||||
@@ -119,6 +122,8 @@ namespace NewsCrawler
|
||||
if(GetLimitRemainCountRQ() < 5)
|
||||
return;
|
||||
|
||||
lock(m_StockChart)
|
||||
{
|
||||
string strTime = StartTime.ToString("yyyyMMdd");
|
||||
|
||||
m_StockChart.SetInputValue(0, Code.m_strCode);
|
||||
@@ -155,6 +160,7 @@ namespace NewsCrawler
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Buy(CodeList.CODE_VALUE Code, int iMaxPrice)
|
||||
{
|
||||
@@ -164,6 +170,8 @@ namespace NewsCrawler
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int iCurPrice = GetCurPrice(Code);
|
||||
int iCount = iMaxPrice/iCurPrice;
|
||||
|
||||
@@ -179,5 +187,10 @@ namespace NewsCrawler
|
||||
|
||||
Util.Log(Util.LOG_TYPE.BUY, string.Format("code:{0} {1}주 현재가 {2}원, 시장가 매수", Code.ToString(), iCount, iCurPrice));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, ex.Message+Environment.NewLine+ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,29 +11,15 @@ namespace NewsCrawler
|
||||
{
|
||||
public class ExcelHandler
|
||||
{
|
||||
bool m_bAvailable = false;
|
||||
bool m_bAvailable = true;
|
||||
string m_strFileName = "";
|
||||
string m_strToday = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
Excel.Application m_App = null;
|
||||
|
||||
public ExcelHandler(string strFileName)
|
||||
{
|
||||
m_App = new Excel.Application();
|
||||
if(m_App == null)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
m_bAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_strFileName = strFileName;
|
||||
}
|
||||
|
||||
~ExcelHandler()
|
||||
{
|
||||
Marshal.ReleaseComObject(m_App);
|
||||
}
|
||||
|
||||
public bool IsAvailable()
|
||||
{
|
||||
return m_bAvailable;
|
||||
@@ -41,7 +27,17 @@ namespace NewsCrawler
|
||||
|
||||
private void Create()
|
||||
{
|
||||
Excel._Workbook Workbook = m_App.Workbooks.Add(Missing.Value);
|
||||
try
|
||||
{
|
||||
Excel.Application App = new Excel.Application();
|
||||
if(App == null)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
m_bAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Excel._Workbook Workbook = App.Workbooks.Add(Missing.Value);
|
||||
Excel._Worksheet Worksheet = Workbook.ActiveSheet;
|
||||
|
||||
Worksheet.Cells[1, 1] = "날짜";
|
||||
@@ -63,17 +59,34 @@ namespace NewsCrawler
|
||||
Missing.Value, Missing.Value, Missing.Value);
|
||||
Workbook.Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRow(string strNewsTime, string strResTime, string strRef, string strTitle, float fReqTime, int iPriceS, int iPriceLow, float fPriceLowP, int iPriceHigh, float fPriceHighP, string strLink)
|
||||
public bool AddRow(string strNewsTime, string strResTime, string strRef, string strTitle, float fReqTime, int iPriceS, int iPriceLow, float fPriceLowP, int iPriceHigh, float fPriceHighP, string strLink)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
if(m_bAvailable == false)
|
||||
return;
|
||||
return false;
|
||||
|
||||
if(File.Exists(m_strFileName) == false)
|
||||
Create();
|
||||
|
||||
try
|
||||
{
|
||||
Excel.Application App = new Excel.Application();
|
||||
if(App == null)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
m_bAvailable = false;
|
||||
return false;
|
||||
}
|
||||
App.DisplayAlerts = false;
|
||||
|
||||
Excel._Workbook Workbook = m_App.Workbooks.Open(m_strFileName);
|
||||
Excel._Workbook Workbook = App.Workbooks.Open(m_strFileName);
|
||||
Excel._Worksheet Worksheet = Workbook.ActiveSheet;
|
||||
|
||||
int iRow = Worksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row+1;
|
||||
@@ -93,5 +106,14 @@ namespace NewsCrawler
|
||||
Workbook.Save();
|
||||
Workbook.Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
NewsForm.Designer.cs
generated
2
NewsForm.Designer.cs
generated
@@ -290,6 +290,8 @@
|
||||
// cbPriceCheck
|
||||
//
|
||||
this.cbPriceCheck.AutoSize = true;
|
||||
this.cbPriceCheck.Checked = true;
|
||||
this.cbPriceCheck.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cbPriceCheck.Location = new System.Drawing.Point(274, 4);
|
||||
this.cbPriceCheck.Name = "cbPriceCheck";
|
||||
this.cbPriceCheck.Size = new System.Drawing.Size(76, 16);
|
||||
|
||||
54
NewsForm.cs
54
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,6 +252,8 @@ 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()));
|
||||
|
||||
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]"),
|
||||
@@ -248,10 +261,11 @@ namespace NewsCrawler
|
||||
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,6 +387,7 @@ namespace NewsCrawler
|
||||
"",
|
||||
strURL }));
|
||||
|
||||
lock(m_URLs)
|
||||
m_URLs.Add(strURL);
|
||||
|
||||
if(bInitial == false)
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,10 +13,17 @@ namespace NewsCrawler
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new NewsForm());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -64,3 +64,15 @@ TPC
|
||||
인콘
|
||||
한국전력
|
||||
우리은행
|
||||
SK텔레콤
|
||||
TIGER 일본(합성 H)
|
||||
아이엠
|
||||
아모레퍼시픽
|
||||
KODEX 단기채권
|
||||
에스엠코어
|
||||
포스코대우
|
||||
미래에셋대우
|
||||
신한제2호SPAC
|
||||
강스템바이오텍
|
||||
금호타이어
|
||||
아이진
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,6 @@
|
||||
위젠솔라 = 뉴프라이드
|
||||
한토신 = 한국토지신탁
|
||||
테바 = 한독
|
||||
신성FA = 신성에프에이
|
||||
무림에스피 = 무림SP
|
||||
SK이노 = SK이노베이션
|
||||
디지털옵틱 = 디지탈옵틱
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
manual-price=100000
|
||||
buy-price=100000
|
||||
account=138115810
|
||||
supply-contract-rate=50
|
||||
account=335261568
|
||||
sub-account=10
|
||||
supply-contract-rate=100
|
||||
dart-api-key1=840943e5370eb9037057beab35f4468fa9a6ce5c
|
||||
dart-api-key2=eba07099d81474c17af615f995d94a517db2c426
|
||||
dart-api-key3=6fcea963a04a6c5b4c4c74a6eee126ce371d47ef
|
||||
|
||||
Reference in New Issue
Block a user