- 리스트에 종목명 추가

- 공시 요청 여부 추가
- 공시 특허권취득 추가
This commit is contained in:
2017-01-30 02:57:27 +09:00
parent babcdb918c
commit 8c6d265ef9
10 changed files with 456 additions and 193 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ obj/
log/
publish/
.vs/
configure/code-duplicated.txt

168
Config.cs
View File

@@ -4,13 +4,14 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace NewsCrawler
{
static class Config
{
static Dictionary<string, string> m_Data = new Dictionary<string, string>();
static Dictionary<string, object> m_Data = new Dictionary<string, object>();
static Random m_Random = new Random();
static int m_iDartAPIKeyCnt = 0;
@@ -18,11 +19,20 @@ namespace NewsCrawler
public static void Init()
{
m_Data.Add("manual-price", "100000");
m_Data.Add("buy-price", "1000000");
m_Data.Add("supply-contract-rate", "50.0");
m_Data.Add("revenue-rate", "50.0");
m_Data.Add("manual-price", 100000);
m_Data.Add("buy-price", 1000000);
m_Data.Add("ann-dart-api", true);
m_Data.Add("ann-supply-contract", true);
m_Data.Add("ann-supply-contract-rate", 50.0f);
m_Data.Add("ann-revenue", true);
m_Data.Add("ann-revenue-rate", 50.0f);
m_Data.Add("ann-rights-issue", true);
m_Data.Add("ann-patent", true);
m_Data.Add("ann-patent-search-string", new Regex("(미국|중국)"));
Load();
Migration();
Save();
int iIdx = 1;
while(true)
@@ -40,7 +50,7 @@ namespace NewsCrawler
static void Load()
{
string strPath = Util.GetConfigPath()+"/config.ini";
string strPath = Util.GetConfigPath() + "/config.ini";
if(File.Exists(strPath) == false)
return;
@@ -54,18 +64,44 @@ namespace NewsCrawler
if(aTokens.Length < 2)
continue;
if(m_Data.ContainsKey(aTokens[0]) == true)
m_Data[aTokens[0]] = aTokens[1];
if(aTokens[0] == "ann-patent-search-string")
{
m_Data[aTokens[0]] = new Regex(aTokens[1]);
}
else
m_Data.Add(aTokens[0], aTokens[1]);
{
if(m_Data.ContainsKey(aTokens[0]) == true)
m_Data[aTokens[0]] = Convert.ChangeType(aTokens[1], m_Data[aTokens[0]].GetType());
else
m_Data.Add(aTokens[0], aTokens[1]);
}
}
}
static void Migration()
{
if(m_Data.ContainsKey("supply-contract-rate"))
{
float fValue;
float.TryParse((string)m_Data["supply-contract-rate"], out fValue);
m_Data["ann-supply-contract-rate"] = fValue;
m_Data.Remove("supply-contract-rate");
}
if(m_Data.ContainsKey("revenue-rate"))
{
float fValue;
float.TryParse((string)m_Data["revenue-rate"], out fValue);
m_Data["ann-revenue-rate"] = fValue;
m_Data.Remove("revenue-rate");
}
}
static void Save()
{
string strContents = "";
foreach(KeyValuePair<string, string> pair in m_Data)
strContents += pair.Key + "=" + pair.Value + Environment.NewLine;
foreach(KeyValuePair<string, object> pair in m_Data)
strContents += pair.Key + "=" + pair.Value.ToString() + Environment.NewLine;
string strPath = Util.GetConfigPath()+"/config.ini";
File.WriteAllText(strPath, strContents, new UTF8Encoding(true));
@@ -73,27 +109,23 @@ namespace NewsCrawler
public static int GetManualPrice()
{
int iPrice;
int.TryParse(m_Data["manual-price"], out iPrice);
return iPrice;
return (int)m_Data["manual-price"];
}
public static void SetManualPrice(int iPrice)
{
m_Data["manual-price"] = iPrice.ToString();
m_Data["manual-price"] = iPrice;
Save();
}
public static int GetBuyPrice()
{
int iPrice;
int.TryParse(m_Data["buy-price"], out iPrice);
return iPrice;
return (int)m_Data["buy-price"];
}
public static void SetBuyPrice(int iPrice)
{
m_Data["buy-price"] = iPrice.ToString();
m_Data["buy-price"] = iPrice;
Save();
}
@@ -106,38 +138,12 @@ namespace NewsCrawler
public static string GetAccount()
{
return m_Data["account"];
return (string)m_Data["account"];
}
public static string GetSubAccount()
{
return m_Data["sub-account"];
}
public static void SetSupplyContractRate(float fRate)
{
m_Data["supply-contract-rate"] = fRate.ToString();
Save();
}
public static float GetSupplyContractRate()
{
float fRate;
float.TryParse(m_Data["supply-contract-rate"], out fRate);
return fRate;
}
public static void SetRevenueRate(float fRate)
{
m_Data["revenue-rate"] = fRate.ToString();
Save();
}
public static float GetRevenueRate()
{
float fRate;
float.TryParse(m_Data["revenue-rate"], out fRate);
return fRate;
return (string)m_Data["sub-account"];
}
public static string GetDartAPIKey()
@@ -152,19 +158,81 @@ namespace NewsCrawler
while(iNum < 0 || m_abDartAPIKeyLimit[iNum-1] == true)
iNum = m_Random.Next(0, 10000)%m_iDartAPIKeyCnt + 1;
return m_Data["dart-api-key"+iNum];
return (string)m_Data["dart-api-key"+iNum];
}
public static void SetDartAPIKeyLimit(string strKey)
{
for(int i=0; i<m_iDartAPIKeyCnt; i++)
for(int i = 0; i<m_iDartAPIKeyCnt; i++)
{
if(m_Data["dart-api-key"+(i+1).ToString()] == strKey)
if((string)m_Data["dart-api-key"+(i+1).ToString()] == strKey)
{
m_abDartAPIKeyLimit[i] = true;
break;
}
}
}
public static void SetAnnouncement(bool bDartAPI,
bool bSupply, bool bRevenue, bool bRightsIssue, bool bPatent,
float fSupplyContractRate, float fRevenueRate, string strPatent)
{
m_Data["ann-dart-api"] = bDartAPI;
m_Data["ann-supply-contract"] = bSupply;
m_Data["ann-supply-contract-rate"] = fSupplyContractRate;
m_Data["ann-revenue"] = bRevenue;
m_Data["ann-revenue-rate"] = fRevenueRate;
m_Data["ann-rights-issue"] = bRightsIssue;
m_Data["ann-patent"] = bPatent;
m_Data["ann-patent-search-string"] = strPatent;
Save();
}
#region Announcement
public static bool CheckDartAPI()
{
return (bool)m_Data["ann-dart-api"];
}
public static bool CheckSupplyContract()
{
return (bool)m_Data["ann-supply-contract"];
}
public static float GetSupplyContractRate()
{
return (float)m_Data["ann-supply-contract-rate"];
}
public static bool CheckRevenue()
{
return (bool)m_Data["ann-revenue"];
}
public static float GetRevenueRate()
{
return (float)m_Data["ann-revenue-rate"];
}
public static bool CheckRightsIssue()
{
return (bool)m_Data["ann-ann-rights-issue"];
}
public static bool CheckPatent()
{
return (bool)m_Data["ann-patent"];
}
public static Regex GetPatentSearchString()
{
return (Regex)m_Data["ann-patent-search-string"];
}
#endregion
}
}

186
ConfigForm.Designer.cs generated
View File

@@ -63,13 +63,18 @@
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.btnAccountApply = new System.Windows.Forms.Button();
this.groupBox12 = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
this.tbSupplyContractRate = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.btAnApply = new System.Windows.Forms.Button();
this.tbAnPatent = new System.Windows.Forms.TextBox();
this.chAnPatent = new System.Windows.Forms.CheckBox();
this.chAnRightsIssue = new System.Windows.Forms.CheckBox();
this.chAnRevenue = new System.Windows.Forms.CheckBox();
this.chAnSupply = new System.Windows.Forms.CheckBox();
this.label7 = new System.Windows.Forms.Label();
this.tbRevenueRate = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.tbAnRevenueRate = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.tbAnSupplyContractRate = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.chAnDartAPI = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox6.SuspendLayout();
@@ -437,91 +442,155 @@
//
// groupBox12
//
this.groupBox12.Controls.Add(this.btAnApply);
this.groupBox12.Controls.Add(this.tbAnPatent);
this.groupBox12.Controls.Add(this.chAnPatent);
this.groupBox12.Controls.Add(this.chAnRightsIssue);
this.groupBox12.Controls.Add(this.chAnRevenue);
this.groupBox12.Controls.Add(this.chAnDartAPI);
this.groupBox12.Controls.Add(this.chAnSupply);
this.groupBox12.Controls.Add(this.label7);
this.groupBox12.Controls.Add(this.tbRevenueRate);
this.groupBox12.Controls.Add(this.label8);
this.groupBox12.Controls.Add(this.tbAnRevenueRate);
this.groupBox12.Controls.Add(this.label6);
this.groupBox12.Controls.Add(this.tbSupplyContractRate);
this.groupBox12.Controls.Add(this.label5);
this.groupBox12.Controls.Add(this.tbAnSupplyContractRate);
this.groupBox12.Location = new System.Drawing.Point(280, 316);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(262, 82);
this.groupBox12.Size = new System.Drawing.Size(262, 209);
this.groupBox12.TabIndex = 19;
this.groupBox12.TabStop = false;
this.groupBox12.Text = "공시";
//
// label6
// btAnApply
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(217, 23);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(15, 12);
this.label6.TabIndex = 2;
this.label6.Text = "%";
this.btAnApply.Location = new System.Drawing.Point(93, 163);
this.btAnApply.Name = "btAnApply";
this.btAnApply.Size = new System.Drawing.Size(72, 39);
this.btAnApply.TabIndex = 5;
this.btAnApply.Text = "적용";
this.btAnApply.UseVisualStyleBackColor = true;
this.btAnApply.Click += new System.EventHandler(this.btAnApply_Click);
//
// tbSupplyContractRate
// tbAnPatent
//
this.tbSupplyContractRate.Location = new System.Drawing.Point(136, 20);
this.tbSupplyContractRate.Name = "tbSupplyContractRate";
this.tbSupplyContractRate.Size = new System.Drawing.Size(73, 21);
this.tbSupplyContractRate.TabIndex = 1;
this.tbSupplyContractRate.Text = "5.0";
this.tbSupplyContractRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tbSupplyContractRate.TextChanged += new System.EventHandler(this.tbSupplyContractRate_TextChanged);
this.tbSupplyContractRate.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbSupplyContractRate_KeyPress);
this.tbAnPatent.Location = new System.Drawing.Point(136, 136);
this.tbAnPatent.Name = "tbAnPatent";
this.tbAnPatent.Size = new System.Drawing.Size(73, 21);
this.tbAnPatent.TabIndex = 8;
this.tbAnPatent.Text = "(미국|중국)";
//
// label5
// chAnPatent
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(28, 23);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(77, 12);
this.label5.TabIndex = 0;
this.label5.Text = "공급계약체결";
this.chAnPatent.AutoSize = true;
this.chAnPatent.Checked = true;
this.chAnPatent.CheckState = System.Windows.Forms.CheckState.Checked;
this.chAnPatent.Location = new System.Drawing.Point(16, 138);
this.chAnPatent.Name = "chAnPatent";
this.chAnPatent.Size = new System.Drawing.Size(88, 16);
this.chAnPatent.TabIndex = 7;
this.chAnPatent.Text = "특허권 취득";
this.chAnPatent.UseVisualStyleBackColor = true;
//
// chAnRightsIssue
//
this.chAnRightsIssue.AutoSize = true;
this.chAnRightsIssue.Checked = true;
this.chAnRightsIssue.CheckState = System.Windows.Forms.CheckState.Checked;
this.chAnRightsIssue.Location = new System.Drawing.Point(16, 109);
this.chAnRightsIssue.Name = "chAnRightsIssue";
this.chAnRightsIssue.Size = new System.Drawing.Size(102, 16);
this.chAnRightsIssue.TabIndex = 7;
this.chAnRightsIssue.Text = "제3자배정증자";
this.chAnRightsIssue.UseVisualStyleBackColor = true;
//
// chAnRevenue
//
this.chAnRevenue.AutoSize = true;
this.chAnRevenue.Checked = true;
this.chAnRevenue.CheckState = System.Windows.Forms.CheckState.Checked;
this.chAnRevenue.Location = new System.Drawing.Point(16, 80);
this.chAnRevenue.Name = "chAnRevenue";
this.chAnRevenue.Size = new System.Drawing.Size(106, 16);
this.chAnRevenue.TabIndex = 7;
this.chAnRevenue.Text = "영업(잠정)실적";
this.chAnRevenue.UseVisualStyleBackColor = true;
//
// chAnSupply
//
this.chAnSupply.AutoSize = true;
this.chAnSupply.Checked = true;
this.chAnSupply.CheckState = System.Windows.Forms.CheckState.Checked;
this.chAnSupply.Location = new System.Drawing.Point(16, 51);
this.chAnSupply.Name = "chAnSupply";
this.chAnSupply.Size = new System.Drawing.Size(96, 16);
this.chAnSupply.TabIndex = 6;
this.chAnSupply.Text = "공급계약체결";
this.chAnSupply.UseVisualStyleBackColor = true;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(217, 50);
this.label7.Location = new System.Drawing.Point(215, 81);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(15, 12);
this.label7.TabIndex = 5;
this.label7.Text = "%";
//
// tbRevenueRate
// tbAnRevenueRate
//
this.tbRevenueRate.Location = new System.Drawing.Point(136, 47);
this.tbRevenueRate.Name = "tbRevenueRate";
this.tbRevenueRate.Size = new System.Drawing.Size(73, 21);
this.tbRevenueRate.TabIndex = 4;
this.tbRevenueRate.Text = "5.0";
this.tbRevenueRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tbRevenueRate.TextChanged += new System.EventHandler(this.tbRevenueRate_TextChanged);
this.tbRevenueRate.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbRevenueRate_KeyPress);
this.tbAnRevenueRate.Location = new System.Drawing.Point(136, 78);
this.tbAnRevenueRate.Name = "tbAnRevenueRate";
this.tbAnRevenueRate.Size = new System.Drawing.Size(73, 21);
this.tbAnRevenueRate.TabIndex = 4;
this.tbAnRevenueRate.Text = "5.0";
this.tbAnRevenueRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tbAnRevenueRate.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbRevenueRate_KeyPress);
//
// label8
// label6
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(28, 50);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(87, 12);
this.label8.TabIndex = 3;
this.label8.Text = "영업(잠정)실적";
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(215, 52);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(15, 12);
this.label6.TabIndex = 2;
this.label6.Text = "%";
//
// tbAnSupplyContractRate
//
this.tbAnSupplyContractRate.Location = new System.Drawing.Point(136, 48);
this.tbAnSupplyContractRate.Name = "tbAnSupplyContractRate";
this.tbAnSupplyContractRate.Size = new System.Drawing.Size(73, 21);
this.tbAnSupplyContractRate.TabIndex = 1;
this.tbAnSupplyContractRate.Text = "5.0";
this.tbAnSupplyContractRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tbAnSupplyContractRate.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbSupplyContractRate_KeyPress);
//
// label9
//
this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(8, 420);
this.label9.Location = new System.Drawing.Point(12, 516);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(132, 12);
this.label9.TabIndex = 20;
this.label9.Text = "Version : 2017.01.27.01";
//
// chAnDartAPI
//
this.chAnDartAPI.AutoSize = true;
this.chAnDartAPI.Checked = true;
this.chAnDartAPI.CheckState = System.Windows.Forms.CheckState.Checked;
this.chAnDartAPI.Location = new System.Drawing.Point(16, 21);
this.chAnDartAPI.Name = "chAnDartAPI";
this.chAnDartAPI.Size = new System.Drawing.Size(97, 16);
this.chAnDartAPI.TabIndex = 6;
this.chAnDartAPI.Text = "Dart API 요청";
this.chAnDartAPI.UseVisualStyleBackColor = true;
//
// ConfigForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(548, 441);
this.ClientSize = new System.Drawing.Size(548, 537);
this.Controls.Add(this.label9);
this.Controls.Add(this.groupBox12);
this.Controls.Add(this.groupBox11);
@@ -593,11 +662,16 @@
private System.Windows.Forms.Button btnAccountApply;
private System.Windows.Forms.GroupBox groupBox12;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox tbSupplyContractRate;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox tbAnSupplyContractRate;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox tbRevenueRate;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox tbAnRevenueRate;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.CheckBox chAnRightsIssue;
private System.Windows.Forms.CheckBox chAnRevenue;
private System.Windows.Forms.CheckBox chAnSupply;
private System.Windows.Forms.TextBox tbAnPatent;
private System.Windows.Forms.CheckBox chAnPatent;
private System.Windows.Forms.Button btAnApply;
private System.Windows.Forms.CheckBox chAnDartAPI;
}
}

View File

@@ -27,8 +27,8 @@ namespace NewsCrawler
if(Config.GetAccount() != "" && Accounts.Contains(Config.GetAccount()))
cbAccount.SelectedItem = Config.GetAccount();
tbSupplyContractRate.Text = Config.GetSupplyContractRate().ToString();
tbRevenueRate.Text = Config.GetRevenueRate().ToString();
tbAnSupplyContractRate.Text = Config.GetSupplyContractRate().ToString();
tbAnRevenueRate.Text = Config.GetRevenueRate().ToString();
}
private void OpenFile(string strName)
@@ -145,30 +145,29 @@ namespace NewsCrawler
m_Listener.OnConfigFormClosing();
}
private void tbSupplyContractRate_TextChanged(object sender, EventArgs e)
{
float fSupplyContractRate;
float.TryParse(tbSupplyContractRate.Text, out fSupplyContractRate);
m_Listener.OnSupplyContractRateChanged(fSupplyContractRate);
}
private void tbSupplyContractRate_KeyPress(object sender, KeyPressEventArgs e)
{
if(char.IsDigit(e.KeyChar) == false && e.KeyChar != '.')
e.Handled = true;
}
private void tbRevenueRate_TextChanged(object sender, EventArgs e)
{
float fRevenueRate;
float.TryParse(tbRevenueRate.Text, out fRevenueRate);
m_Listener.OnRevenueRateChanged(fRevenueRate);
}
private void tbRevenueRate_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == false && e.KeyChar != '.')
e.Handled = true;
}
private void btAnApply_Click(object sender, EventArgs e)
{
float fSupplyContractRate;
float.TryParse(tbAnSupplyContractRate.Text, out fSupplyContractRate);
float fRevenueRate;
float.TryParse(tbAnRevenueRate.Text, out fRevenueRate);
Config.SetAnnouncement(chAnDartAPI.Checked,
chAnSupply.Checked, chAnRevenue.Checked, chAnRightsIssue.Checked, chAnPatent.Checked,
fSupplyContractRate, fRevenueRate, tbAnPatent.Text);
}
}
}

View File

@@ -44,6 +44,7 @@ namespace NewsCrawler
ReadRevenue(false, "제일기획", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170126800508");
ReadRevenue(false, "LS산전", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170126800581");
ReadRightsIssue(false, "옴니텔", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170126000525");
ReadPatent(false, "인트론바이오", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170125900080");
}
void ResponseAsiaE(IAsyncResult result)
@@ -417,9 +418,6 @@ namespace NewsCrawler
private void ReadSupplyContract(bool bInitial, string strCodeName, string strURL)
{
if(m_iDartAPIRetry <= 0)
return;
try
{
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
@@ -497,9 +495,6 @@ namespace NewsCrawler
private void ReadRevenue(bool bInitial, string strCodeName, string strURL)
{
if (m_iDartAPIRetry <= 0)
return;
try
{
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
@@ -572,9 +567,6 @@ namespace NewsCrawler
private void ReadRightsIssue(bool bInitial, string strCodeName, string strURL)
{
if (m_iDartAPIRetry <= 0)
return;
try
{
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
@@ -595,6 +587,79 @@ namespace NewsCrawler
}
}
void ResponsePatent(IAsyncResult result)
{
REQUEST_STATUS State = (REQUEST_STATUS)result.AsyncState;
HttpWebRequest HttpReq = State.m_HTTPReq;
bool bInitial = State.m_bInitial;
State.m_Timer.Stop();
try
{
using(HttpWebResponse response = (HttpWebResponse)HttpReq.GetResponse())
{
using(Stream dataStream = response.GetResponseStream())
{
using(StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("utf-8")))
{
string responseFromServer = WebUtility.HtmlDecode(reader.ReadToEnd());
dynamic jObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseFromServer);
string strBody = jObj["reportBody"];
strBody = strBody.Replace("\\\"", "\"");
strBody = strBody.Replace("\r\n", "");
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(strBody);
string strXPath = "//tr";
var lists = doc.DocumentNode.SelectNodes(strXPath);
foreach(var item in lists)
{
var cols = item.SelectNodes(".//td");
for(int i = 0; i<cols.Count-1; i++)
{
if(cols[i].InnerText.Contains("기타 투자판단에 참고할 사항") &&
Config.GetPatentSearchString().IsMatch(cols[i+1].InnerText))
{
m_Listener.OnReceivedPatent(State.m_strCodeName);
return;
}
}
}
}
}
}
HttpReq.EndGetResponse(result);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
}
}
private void ReadPatent(bool bInitial, string strCodeName, string strURL)
{
try
{
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
HttpReq.Credentials = CredentialCache.DefaultCredentials;
HttpReq.Timeout = 2000;
REQUEST_STATUS State = new REQUEST_STATUS();
State.m_HTTPReq = HttpReq;
State.m_bInitial = bInitial;
State.m_Timer.Start();
State.m_strCodeName = strCodeName;
HttpReq.BeginGetResponse(new AsyncCallback(ResponsePatent), State);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
}
}
void ResponseDartAPI(IAsyncResult result)
{
REQUEST_STATUS State = (REQUEST_STATUS)result.AsyncState;
@@ -635,12 +700,14 @@ namespace NewsCrawler
string strURL = "http://m.dart.fss.or.kr/html_mdart/MD1007.html?rcpNo=" + data["rcp_no"];
string strViewURL = "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=" + data["rcp_no"];
if (strCodeName != "" && strTitle.Contains("공급계약체결") && m_Listener.IsDuplicatedURL(strURL) == false)
if (Config.CheckSupplyContract() && strCodeName != "" && strTitle.Contains("공급계약체결") && m_Listener.IsDuplicatedURL(strURL) == false)
ReadSupplyContract(bInitial, strCodeName, strViewURL);
else if(strCodeName != "" && strTitle.Contains("영업(잠정)실적(공정공시)") && m_Listener.IsDuplicatedURL(strURL) == false)
else if(Config.CheckRevenue() && strCodeName != "" && strTitle.Contains("영업(잠정)실적(공정공시)") && m_Listener.IsDuplicatedURL(strURL) == false)
ReadRevenue(bInitial, strCodeName, strViewURL);
else if(strCodeName != "" && strTitle.Contains("유상증자결정") && m_Listener.IsDuplicatedURL(strURL) == false)
else if(Config.CheckRightsIssue() && strCodeName != "" && strTitle.Contains("유상증자결정") && m_Listener.IsDuplicatedURL(strURL) == false)
ReadRightsIssue(bInitial, strCodeName, strViewURL);
else if(Config.CheckPatent() && strCodeName != "" && strTitle.Contains("특허권취득") && m_Listener.IsDuplicatedURL(strURL) == false)
ReadPatent(bInitial, strCodeName, strViewURL);
m_Listener.InsertItem(strTitle, strCodeName, "",
DateTime.ParseExact(strTime, "HH:mm", CultureInfo.CurrentCulture),

View File

@@ -71,6 +71,9 @@
<Reference Include="HtmlAgilityPack">
<HintPath>HtmlAgility\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="MaterialSkin">
<HintPath>..\AutoSeller\packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>

21
NewsForm.Designer.cs generated
View File

@@ -55,6 +55,8 @@
this.btnConfig = new System.Windows.Forms.Button();
this.chBuy = new System.Windows.Forms.CheckBox();
this.cbPriceCheck = new System.Windows.Forms.CheckBox();
this.materialContextMenuStrip1 = new MaterialSkin.Controls.MaterialContextMenuStrip();
this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -68,9 +70,10 @@
this.chId,
this.chTime,
this.chResT,
this.chResponseT,
this.chReference,
this.chTitle,
this.chResponseT,
this.chCodeName,
this.chPriceS,
this.chPriceLow,
this.chPriceLowP,
@@ -98,7 +101,7 @@
//
// chTime
//
this.chTime.Text = "시간";
this.chTime.Text = "기사 시간";
//
// chResT
//
@@ -299,6 +302,18 @@
this.cbPriceCheck.Text = "가격 체크";
this.cbPriceCheck.UseVisualStyleBackColor = true;
//
// materialContextMenuStrip1
//
this.materialContextMenuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.materialContextMenuStrip1.Depth = 0;
this.materialContextMenuStrip1.MouseState = MaterialSkin.MouseState.HOVER;
this.materialContextMenuStrip1.Name = "materialContextMenuStrip1";
this.materialContextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// chCodeName
//
this.chCodeName.Text = "종목명";
//
// NewsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -356,6 +371,8 @@
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
private System.Windows.Forms.ColumnHeader chCodeName;
private MaterialSkin.Controls.MaterialContextMenuStrip materialContextMenuStrip1;
}
}

View File

@@ -21,10 +21,12 @@ namespace NewsCrawler
{
class NEWS_ITEM
{
public NEWS_ITEM(int iID, string strTitle, string strName, string strCode, DateTime NewsTime, DateTime ResTime, string strRef, string strURL, float fElapseT)
public NEWS_ITEM(int iID, string strTitle, string strCode, CodeList.CODE_VALUE Code,
DateTime NewsTime, DateTime ResTime, string strRef, string strURL, float fElapseT)
{
m_iID = iID;
m_strCode = strCode;
m_Code = Code;
m_NewsTime = NewsTime;
m_ResTime = ResTime;
m_strRef = strRef;
@@ -88,9 +90,6 @@ namespace NewsCrawler
//ExcelHandler m_Excel = null;
float m_fSupplyContractRate;
float m_fRevenueRate;
object m_lvListLock = new object();
@@ -109,8 +108,6 @@ namespace NewsCrawler
m_Condition = new TextCondition();
m_CybosHelper = new CybosHelper(this);
m_Crawler = new Crawler(this);
m_fSupplyContractRate = Config.GetSupplyContractRate();
m_fRevenueRate = Config.GetRevenueRate();
Util.Log(Util.LOG_TYPE.VERVOSE, "========== NewsCrawler 실행 ==========");
@@ -227,70 +224,59 @@ namespace NewsCrawler
void ProcessSearchAndBuy(NEWS_ITEM NewsItem)
{
CodeList.CODE_VALUE Code = null;
if(NewsItem.m_strCode == "")
Code = m_CodeList.SearchCode(NewsItem.m_strTitle);
else
Code = m_CodeList.GetCode(NewsItem.m_strCode);
if(Code == null)
return;
NewsItem.m_Code = Code;
TextCondition.RESULT MatchResult = m_Condition.Match(NewsItem.m_strTitle);
switch(MatchResult.m_enType)
{
case TextCondition.TYPE.NEGATIVE:
Util.Log(Util.LOG_TYPE.NEGATIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
Util.Log(Util.LOG_TYPE.NEGATIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString()));
break;
case TextCondition.TYPE.POSITIVE:
if((Code.m_enType&CodeList.CODE_TYPE.DENIAL) == CodeList.CODE_TYPE.DENIAL)
Util.Log(Util.LOG_TYPE.DENIAL, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
else if((Code.m_enType&CodeList.CODE_TYPE.DUPLICATED) == CodeList.CODE_TYPE.DUPLICATED)
Util.Log(Util.LOG_TYPE.DUPLICATED, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
else if((Code.m_enType&CodeList.CODE_TYPE.MANUAL) == CodeList.CODE_TYPE.MANUAL)
if((NewsItem.m_Code.m_enType&CodeList.CODE_TYPE.DENIAL) == CodeList.CODE_TYPE.DENIAL)
Util.Log(Util.LOG_TYPE.DENIAL, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString()));
else if((NewsItem.m_Code.m_enType&CodeList.CODE_TYPE.DUPLICATED) == CodeList.CODE_TYPE.DUPLICATED)
Util.Log(Util.LOG_TYPE.DUPLICATED, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString()));
else if((NewsItem.m_Code.m_enType&CodeList.CODE_TYPE.MANUAL) == CodeList.CODE_TYPE.MANUAL)
{
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()));
Util.Log(Util.LOG_TYPE.MANUAL_CODE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_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]"),
NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code), Code);
NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code), NewsItem.m_Code);
ManualPopup.TopMost = true;
ManualPopup.Show();
}
}
else
{
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()));
BuyItem(NewsItem.m_Code);
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString()));
}
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
m_CodeList.AddDuplicatedList(NewsItem.m_Code.m_strCode, NewsItem.m_Code.m_strName);
break;
case TextCondition.TYPE.MANUAL:
Util.Log(Util.LOG_TYPE.MANUAL_KEYWORD, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code.ToString()));
Util.Log(Util.LOG_TYPE.MANUAL_KEYWORD, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_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]"),
NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, Code), Code);
NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code), NewsItem.m_Code);
ManualPopup.TopMost = true;
ManualPopup.Show();
}
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
m_CodeList.AddDuplicatedList(NewsItem.m_Code.m_strCode, NewsItem.m_Code.m_strName);
break;
case TextCondition.TYPE.NOT_MATCHED:
Util.Log(Util.LOG_TYPE.DEBUG, string.Format("[NOT_MATCHED] [{0}] {1}({2})", NewsItem.m_strRef, NewsItem.m_strTitle, Code.ToString()));
Util.Log(Util.LOG_TYPE.DEBUG, string.Format("[NOT_MATCHED] [{0}] {1}({2})", NewsItem.m_strRef, NewsItem.m_strTitle, NewsItem.m_Code.ToString()));
break;
}
@@ -306,9 +292,9 @@ namespace NewsCrawler
return;
}
if(fRate < m_fSupplyContractRate)
if(fRate < Config.GetSupplyContractRate())
{
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("[DartAPI][공급계약체결] 매출액 대비율 낮음({0}, {1}% / {2}%)", strCodeName, fRate, m_fSupplyContractRate));
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("[DartAPI][공급계약체결] 매출액 대비율 낮음({0}, {1}% / {2}%)", strCodeName, fRate, Config.GetSupplyContractRate()));
return;
}
@@ -351,9 +337,9 @@ namespace NewsCrawler
return;
}
if (fRate < m_fRevenueRate)
if (fRate < Config.GetRevenueRate())
{
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("[DartAPI][영업실적] 당기순이익률 낮음({0}, {1}% / {2}%)", strCodeName, fRate, m_fRevenueRate));
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("[DartAPI][영업실적] 당기순이익률 낮음({0}, {1}% / {2}%)", strCodeName, fRate, Config.GetRevenueRate()));
return;
}
@@ -426,16 +412,43 @@ namespace NewsCrawler
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
}
public void OnSupplyContractRateChanged(float fRate)
public void OnReceivedPatent(string strCodeName)
{
m_fSupplyContractRate = fRate;
Config.SetSupplyContractRate(fRate);
}
CodeList.CODE_VALUE Code = m_CodeList.GetCodeByName(strCodeName);
if(Code == null)
{
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("[DartAPI][특허권취득] 종목을 찾을 수 없음({0})", strCodeName));
return;
}
public void OnRevenueRateChanged(float fRate)
{
m_fRevenueRate = fRate;
Config.SetRevenueRate(fRate);
string strRef = "DartAPI";
string strTitle = string.Format("특허권취득 - {0}", strCodeName);
if((Code.m_enType & CodeList.CODE_TYPE.DENIAL) == CodeList.CODE_TYPE.DENIAL)
Util.Log(Util.LOG_TYPE.DENIAL, string.Format("[{0}] {1}", strRef, strTitle));
else if((Code.m_enType & CodeList.CODE_TYPE.DUPLICATED) == CodeList.CODE_TYPE.DUPLICATED)
Util.Log(Util.LOG_TYPE.DUPLICATED, string.Format("[{0}] {1}", strRef, strTitle));
else if((Code.m_enType & CodeList.CODE_TYPE.MANUAL) == CodeList.CODE_TYPE.MANUAL)
{
Util.Log(Util.LOG_TYPE.MANUAL_CODE, string.Format("[{0}] {1}", strRef, strTitle));
if(m_bBuy == true)
{
ModelessPopup ManualPopup = new ModelessPopup(this);
ManualPopup.SetMessage(string.Format("{0}\n[{1}] {2}\n\n매수하시겠습니까?",
DateTime.Now.ToString("[hh:mm:ss]"),
strRef, strTitle), Code);
ManualPopup.TopMost = true;
ManualPopup.Show();
}
}
else
{
BuyItem(Code);
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1}", strRef, strTitle));
}
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
}
public bool IsDuplicatedURL(string strURL)
@@ -462,16 +475,27 @@ namespace NewsCrawler
int iID = lvList.Items.Count+1;
CodeList.CODE_VALUE Code = null;
if(bInitial == false)
ProcessSearchAndBuy(new NEWS_ITEM(iID, strTitle, strName, strCode, time, ResTime, strRef, strURL, (float)dElapseT));
{
if(strCode == "")
Code = m_CodeList.SearchCode(strTitle);
else
Code = m_CodeList.GetCode(strCode);
if(Code != null)
ProcessSearchAndBuy(new NEWS_ITEM(iID, strTitle, strCode, Code, time, ResTime, strRef, strURL, (float)dElapseT));
}
lvList.Items.Add(new ListViewItem(new string[] {
iID.ToString(),
time.ToString("HH:mm:ss"),
ResTime.ToString("HH:mm:ss:fff"),
string.Format("{0:n3} ms", dElapseT),
strRef,
strTitle,
string.Format("{0:n4} ms", dElapseT),
(Code != null) ? Code.m_strName : "",
"",
"",
"",
@@ -530,7 +554,8 @@ namespace NewsCrawler
{
m_Crawler.ReadKIND();
m_Crawler.ReadDart();
m_Crawler.ReadDartAPI();
if(Config.CheckDartAPI())
m_Crawler.ReadDartAPI();
m_Crawler.ReadEtoday();
//m_Crawler.ReadEtoday2();
m_Crawler.ReadAsiaE();
@@ -647,14 +672,14 @@ namespace NewsCrawler
if(Data.m_iTryCnt < 3 && Data.m_iPriceHigh == 0)
break;
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)
//{
// 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;

View File

@@ -120,6 +120,9 @@
<metadata name="statusBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="materialContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>119, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>96</value>
</metadata>

View File

@@ -1,7 +1,13 @@
manual-price=100000
buy-price=100000
supply-contract-rate=15
revenue-rate=35.5
ann-dart-api=True
ann-supply-contract=True
ann-supply-contract-rate=15.4
ann-revenue=True
ann-revenue-rate=35.5
ann-rights-issue=True
ann-patent=True
ann-patent-search-string=(미국|중국)
account=335261568
sub-account=10
dart-api-key1=840943e5370eb9037057beab35f4468fa9a6ce5c