- 매수 기능 추가
This commit is contained in:
12
CodeList.cs
12
CodeList.cs
@@ -24,7 +24,7 @@ namespace NewsCrawler
|
||||
|
||||
override public string ToString()
|
||||
{
|
||||
return string.Format("{0}:{1} ({2})", m_strCode, m_strName, m_enType);
|
||||
return string.Format("{0}:{1}", m_strCode, m_strName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,16 @@ namespace NewsCrawler
|
||||
LoadCodeType(strPath, CODE_TYPE.DUPLICATED);
|
||||
}
|
||||
|
||||
public void AddDuplicatedList(string strCode, string strName)
|
||||
{
|
||||
CODE_VALUE Result = m_CodeList.Find(s => s.m_strCode == strCode);
|
||||
if(Result != null)
|
||||
Result.m_enType |= CODE_TYPE.DUPLICATED;
|
||||
|
||||
string strPath = Util.GetConfigPath()+"/code-duplicated.txt";
|
||||
File.AppendAllText(strPath, strName+Environment.NewLine);
|
||||
}
|
||||
|
||||
public void MakeManualList(int iPrice)
|
||||
{
|
||||
m_CodeList.ForEach(a => a.m_enType &= ~CODE_TYPE.MANUAL);
|
||||
|
||||
21
Config.cs
21
Config.cs
@@ -15,6 +15,7 @@ namespace NewsCrawler
|
||||
public static void Init()
|
||||
{
|
||||
m_Data.Add("manual-price", "100000");
|
||||
m_Data.Add("buy-price", "1000000");
|
||||
Load();
|
||||
}
|
||||
|
||||
@@ -24,8 +25,6 @@ namespace NewsCrawler
|
||||
if(File.Exists(strPath) == false)
|
||||
return;
|
||||
|
||||
m_Data.Clear();
|
||||
|
||||
string[] aLines = File.ReadAllLines(strPath);
|
||||
foreach(string strLine in aLines)
|
||||
{
|
||||
@@ -36,7 +35,10 @@ namespace NewsCrawler
|
||||
if(aTokens.Length < 2)
|
||||
continue;
|
||||
|
||||
m_Data.Add(aTokens[0], aTokens[1]);
|
||||
if(m_Data.ContainsKey(aTokens[0]) == true)
|
||||
m_Data[aTokens[0]] = aTokens[1];
|
||||
else
|
||||
m_Data.Add(aTokens[0], aTokens[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,5 +64,18 @@ namespace NewsCrawler
|
||||
m_Data["manual-price"] = iPrice.ToString();
|
||||
Save();
|
||||
}
|
||||
|
||||
public static int GetBuyPrice()
|
||||
{
|
||||
int iPrice;
|
||||
int.TryParse(m_Data["buy-price"], out iPrice);
|
||||
return iPrice;
|
||||
}
|
||||
|
||||
public static void SetBuyPrice(int iPrice)
|
||||
{
|
||||
m_Data["buy-price"] = iPrice.ToString();
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
57
ConfigForm.Designer.cs
generated
57
ConfigForm.Designer.cs
generated
@@ -54,6 +54,10 @@
|
||||
this.btnDuplicatedCodeApply = new System.Windows.Forms.Button();
|
||||
this.btnDuplicatedCodeEdit = new System.Windows.Forms.Button();
|
||||
this.groupBox9 = new System.Windows.Forms.GroupBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tbBuyPrice = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.groupBox10 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox6.SuspendLayout();
|
||||
@@ -63,6 +67,7 @@
|
||||
this.groupBox7.SuspendLayout();
|
||||
this.groupBox8.SuspendLayout();
|
||||
this.groupBox9.SuspendLayout();
|
||||
this.groupBox10.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tbVolume
|
||||
@@ -144,7 +149,7 @@
|
||||
this.groupBox2.Controls.Add(this.groupBox4);
|
||||
this.groupBox2.Location = new System.Drawing.Point(280, 12);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(262, 287);
|
||||
this.groupBox2.Size = new System.Drawing.Size(262, 298);
|
||||
this.groupBox2.TabIndex = 10;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "키워드";
|
||||
@@ -336,11 +341,53 @@
|
||||
this.groupBox9.TabStop = false;
|
||||
this.groupBox9.Text = "종목편집";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(9, 20);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(29, 12);
|
||||
this.label1.TabIndex = 13;
|
||||
this.label1.Text = "가격";
|
||||
//
|
||||
// tbBuyPrice
|
||||
//
|
||||
this.tbBuyPrice.Location = new System.Drawing.Point(61, 17);
|
||||
this.tbBuyPrice.Name = "tbBuyPrice";
|
||||
this.tbBuyPrice.Size = new System.Drawing.Size(107, 21);
|
||||
this.tbBuyPrice.TabIndex = 12;
|
||||
this.tbBuyPrice.Text = "1000000";
|
||||
this.tbBuyPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.tbBuyPrice.TextChanged += new System.EventHandler(this.tbBuyPrice_TextChanged);
|
||||
this.tbBuyPrice.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbBuyPrice_KeyPress);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(174, 20);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(17, 12);
|
||||
this.label4.TabIndex = 14;
|
||||
this.label4.Text = "원";
|
||||
//
|
||||
// groupBox10
|
||||
//
|
||||
this.groupBox10.Controls.Add(this.tbBuyPrice);
|
||||
this.groupBox10.Controls.Add(this.label4);
|
||||
this.groupBox10.Controls.Add(this.label1);
|
||||
this.groupBox10.Location = new System.Drawing.Point(10, 264);
|
||||
this.groupBox10.Name = "groupBox10";
|
||||
this.groupBox10.Size = new System.Drawing.Size(262, 46);
|
||||
this.groupBox10.TabIndex = 15;
|
||||
this.groupBox10.TabStop = false;
|
||||
this.groupBox10.Text = "매수";
|
||||
//
|
||||
// ConfigForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(548, 307);
|
||||
this.ClientSize = new System.Drawing.Size(548, 320);
|
||||
this.Controls.Add(this.groupBox10);
|
||||
this.Controls.Add(this.groupBox9);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
@@ -359,6 +406,8 @@
|
||||
this.groupBox7.ResumeLayout(false);
|
||||
this.groupBox8.ResumeLayout(false);
|
||||
this.groupBox9.ResumeLayout(false);
|
||||
this.groupBox10.ResumeLayout(false);
|
||||
this.groupBox10.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@@ -390,5 +439,9 @@
|
||||
private System.Windows.Forms.Button btnDuplicatedCodeApply;
|
||||
private System.Windows.Forms.Button btnDuplicatedCodeEdit;
|
||||
private System.Windows.Forms.GroupBox groupBox9;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox tbBuyPrice;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.GroupBox groupBox10;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ namespace NewsCrawler
|
||||
private void ConfigForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
tbVolume.Text = Config.GetManualPrice().ToString();
|
||||
tbBuyPrice.Text = Config.GetBuyPrice().ToString();
|
||||
}
|
||||
|
||||
private void OpenFile(string strName)
|
||||
@@ -109,5 +110,19 @@ namespace NewsCrawler
|
||||
m_Listener.ApplySynonym();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Buy
|
||||
private void tbBuyPrice_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.KeyChar);
|
||||
}
|
||||
|
||||
private void tbBuyPrice_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int iPrice;
|
||||
bool bNumber = int.TryParse(tbBuyPrice.Text, out iPrice);
|
||||
Config.SetBuyPrice(iPrice);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,36 +2,94 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewsCrawler
|
||||
{
|
||||
public class CybosHelper
|
||||
{
|
||||
CPUTILLib.CpCybos m_CPUtil = new CPUTILLib.CpCybos();
|
||||
CPUTILLib.CpCybos m_CPCybos = new CPUTILLib.CpCybos();
|
||||
CPFORETRADELib.CpForeTdUtil m_CPUtil = new CPFORETRADELib.CpForeTdUtil();
|
||||
DSCBO1Lib.StockMst m_CPStockMst = new DSCBO1Lib.StockMst();
|
||||
CPTRADELib.CpTd0311 m_CP0311 = new CPTRADELib.CpTd0311();
|
||||
bool m_bInitialized = false;
|
||||
string m_strAccountNumber;
|
||||
|
||||
public CybosHelper()
|
||||
{
|
||||
short iResult = m_CPUtil.TradeInit();
|
||||
switch(iResult)
|
||||
{
|
||||
case -1:
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 오류");
|
||||
break;
|
||||
|
||||
case 0:
|
||||
m_bInitialized = true;
|
||||
Util.Log(Util.LOG_TYPE.VERVOSE, "[TradeInit] 로그인 되었습니다");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 업무 키 입력 잘못됨");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 계좌 비밀번호가 잘못되었습니다");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 취소되었습니다");
|
||||
break;
|
||||
}
|
||||
|
||||
m_strAccountNumber = m_CPUtil.AccountNumber[0];
|
||||
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("{0}개의 계좌 중 첫번째 계좌 {1}이 선택되었습니다", m_CPUtil.AccountNumber.Length, m_strAccountNumber));
|
||||
}
|
||||
|
||||
public int GetLimitRemainCountTrace()
|
||||
{
|
||||
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
|
||||
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
|
||||
}
|
||||
|
||||
public int GetLimitRemainCountRQ()
|
||||
{
|
||||
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST);
|
||||
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST);
|
||||
}
|
||||
|
||||
public int GetLimitRemainCountSB()
|
||||
{
|
||||
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE);
|
||||
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE);
|
||||
}
|
||||
|
||||
public bool IsConnected()
|
||||
{
|
||||
return (m_CPUtil.IsConnect==1);
|
||||
return (m_CPCybos.IsConnect==1);
|
||||
}
|
||||
|
||||
public void Buy(CodeList.CODE_VALUE Code, int iMaxPrice)
|
||||
{
|
||||
if(m_bInitialized == false)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "[Buy] 매수 준비가 되지 않았습니다");
|
||||
return;
|
||||
}
|
||||
|
||||
m_CPStockMst.SetInputValue(0, Code.m_strCode);
|
||||
m_CPStockMst.BlockRequest2(0);
|
||||
int iCurPrice = m_CPStockMst.GetHeaderValue(13);
|
||||
|
||||
int iCount = iMaxPrice/iCurPrice;
|
||||
|
||||
m_CP0311.SetInputValue(0, 2);
|
||||
m_CP0311.SetInputValue(1, m_strAccountNumber);
|
||||
m_CP0311.SetInputValue(3, Code.m_strCode);
|
||||
m_CP0311.SetInputValue(4, iCount);
|
||||
m_CP0311.SetInputValue(5, 0);
|
||||
m_CP0311.SetInputValue(8, "03");
|
||||
m_CP0311.BlockRequest2(0);
|
||||
|
||||
Util.Log(Util.LOG_TYPE.BUY, string.Format("code:{0} {1}주 현재가 {2}원, 시장가 매수", Code.ToString(), iCount, iCurPrice));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
86
ModelessPopup.Designer.cs
generated
Normal file
86
ModelessPopup.Designer.cs
generated
Normal file
@@ -0,0 +1,86 @@
|
||||
namespace NewsCrawler
|
||||
{
|
||||
partial class ModelessPopup
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnYes = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnYes
|
||||
//
|
||||
this.btnYes.Location = new System.Drawing.Point(123, 67);
|
||||
this.btnYes.Name = "btnYes";
|
||||
this.btnYes.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnYes.TabIndex = 0;
|
||||
this.btnYes.Text = "예";
|
||||
this.btnYes.UseVisualStyleBackColor = true;
|
||||
this.btnYes.Click += new System.EventHandler(this.btnYes_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Location = new System.Drawing.Point(204, 67);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCancel.TabIndex = 1;
|
||||
this.btnCancel.Text = "취소";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(38, 12);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "label1";
|
||||
//
|
||||
// ModelessPopup
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(291, 102);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnYes);
|
||||
this.Name = "ModelessPopup";
|
||||
this.Text = "수동종목";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnYes;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
42
ModelessPopup.cs
Normal file
42
ModelessPopup.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NewsCrawler
|
||||
{
|
||||
public partial class ModelessPopup : Form
|
||||
{
|
||||
NewsForm m_Owner = null;
|
||||
CodeList.CODE_VALUE m_Code;
|
||||
|
||||
public ModelessPopup(NewsForm Owner)
|
||||
{
|
||||
m_Owner = Owner;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetMessage(string strMsg, CodeList.CODE_VALUE Code)
|
||||
{
|
||||
m_Code = Code;
|
||||
label1.Text = strMsg;
|
||||
}
|
||||
|
||||
private void btnYes_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_Owner.OnManualItemBuy(m_Code);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ModelessPopup.resx
Normal file
120
ModelessPopup.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -98,6 +98,12 @@
|
||||
<DependentUpon>ConfigForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CybosHelper.cs" />
|
||||
<Compile Include="ModelessPopup.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ModelessPopup.Designer.cs">
|
||||
<DependentUpon>ModelessPopup.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NewsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -111,6 +117,9 @@
|
||||
<EmbeddedResource Include="ConfigForm.resx">
|
||||
<DependentUpon>ConfigForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ModelessPopup.resx">
|
||||
<DependentUpon>ModelessPopup.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="NewsForm.resx">
|
||||
<DependentUpon>NewsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
15
NewsForm.Designer.cs
generated
15
NewsForm.Designer.cs
generated
@@ -42,6 +42,7 @@
|
||||
this.btnConfig = new System.Windows.Forms.Button();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.tbLog = new System.Windows.Forms.RichTextBox();
|
||||
this.chBuy = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
@@ -205,11 +206,24 @@
|
||||
this.tbLog.TabIndex = 0;
|
||||
this.tbLog.Text = "";
|
||||
//
|
||||
// chBuy
|
||||
//
|
||||
this.chBuy.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
this.chBuy.AutoSize = true;
|
||||
this.chBuy.Location = new System.Drawing.Point(274, 1);
|
||||
this.chBuy.Name = "chBuy";
|
||||
this.chBuy.Size = new System.Drawing.Size(39, 22);
|
||||
this.chBuy.TabIndex = 9;
|
||||
this.chBuy.Text = "매수";
|
||||
this.chBuy.UseVisualStyleBackColor = true;
|
||||
this.chBuy.CheckedChanged += new System.EventHandler(this.chBuy_CheckedChanged);
|
||||
//
|
||||
// NewsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(864, 829);
|
||||
this.Controls.Add(this.chBuy);
|
||||
this.Controls.Add(this.splitContainer2);
|
||||
this.Controls.Add(this.btnConfig);
|
||||
this.Controls.Add(this.label1);
|
||||
@@ -248,6 +262,7 @@
|
||||
private System.Windows.Forms.Button btnConfig;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.RichTextBox tbLog;
|
||||
private System.Windows.Forms.CheckBox chBuy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
NewsForm.cs
45
NewsForm.cs
@@ -17,7 +17,7 @@ namespace NewsCrawler
|
||||
{
|
||||
public partial class NewsForm : Form
|
||||
{
|
||||
CybosHelper m_CybosHelper = new CybosHelper();
|
||||
CybosHelper m_CybosHelper = null;
|
||||
CodeList m_CodeList = null;
|
||||
TextCondition m_Condition = null;
|
||||
ConfigForm m_ConfigForm = null;
|
||||
@@ -27,6 +27,7 @@ namespace NewsCrawler
|
||||
System.Timers.Timer m_CrawlTimer = new System.Timers.Timer();
|
||||
int m_iCrawlInterval = 500;
|
||||
bool m_bBrowserReload = false;
|
||||
bool m_bBuy = false;
|
||||
|
||||
|
||||
|
||||
@@ -68,6 +69,8 @@ namespace NewsCrawler
|
||||
m_CrawlTimer.Interval=m_iCrawlInterval;
|
||||
m_CrawlTimer.Start();
|
||||
|
||||
m_CybosHelper = new CybosHelper();
|
||||
|
||||
Test();
|
||||
}
|
||||
|
||||
@@ -76,12 +79,26 @@ namespace NewsCrawler
|
||||
if(Util.IsDebugging() == false)
|
||||
return;
|
||||
|
||||
InsertItem("[test] 덕산하이메탈, 덕산네오룩스 66만여주 취득14:38", new DateTime(2016, 11, 30, 14, 38, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914371817318", "asiae", false);
|
||||
InsertItem("[test] 자연과환경, 12월15일~22일 주주명부폐쇄14:19", new DateTime(2016, 11, 30, 14, 19, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914193170301", "asiae", false);
|
||||
InsertItem("[test] 이엠코리아, 한국항공우주산업과 3억원 규모 공급계약14:06", new DateTime(2016, 11, 30, 14, 06, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914055964082", "asiae", false);
|
||||
InsertItem("[test] 덕산하이메탈, 덕산네오룩스 66만여주 취득14:38", new DateTime(2016, 11, 30, 00, 00, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914371817318", "asiae", false);
|
||||
InsertItem("[test] 자연과환경, 12월15일~22일 주주명부폐쇄14:19", new DateTime(2016, 11, 30, 00, 00, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914193170301", "asiae", false);
|
||||
InsertItem("[test] 이엠코리아, 한국항공우주산업과 3억원 규모 공급계약14:06", new DateTime(2016, 11, 30, 00, 00, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914055964082", "asiae", false);
|
||||
|
||||
}
|
||||
|
||||
private void BuyItem(CodeList.CODE_VALUE Code)
|
||||
{
|
||||
if(m_bBuy == false)
|
||||
return;
|
||||
|
||||
m_CybosHelper.Buy(Code, Config.GetBuyPrice());
|
||||
m_CodeList.AddDuplicatedList(Code.m_strCode, Code.m_strName);
|
||||
}
|
||||
|
||||
public void OnManualItemBuy(CodeList.CODE_VALUE Code)
|
||||
{
|
||||
BuyItem(Code);
|
||||
}
|
||||
|
||||
void ProcessSearchAndBuy(string strTitle, string strRef)
|
||||
{
|
||||
CodeList.CODE_VALUE Code = m_CodeList.SearchCode(strTitle);
|
||||
@@ -102,11 +119,21 @@ namespace NewsCrawler
|
||||
else if((Code.m_enType&CodeList.CODE_TYPE.DENIAL) == CodeList.CODE_TYPE.MANUAL)
|
||||
Util.Log(Util.LOG_TYPE.MANUAL_CODE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", strRef, strTitle, MatchResult.m_strKeyword, Code.ToString()));
|
||||
else
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.POSITIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", strRef, strTitle, MatchResult.m_strKeyword, Code.ToString()));
|
||||
BuyItem(Code);
|
||||
}
|
||||
break;
|
||||
|
||||
case TextCondition.TYPE.MANUAL:
|
||||
Util.Log(Util.LOG_TYPE.MANUAL_KEYWORD, string.Format("[{0}] {1} (keyword:{2}, code:{3})", strRef, strTitle, MatchResult.m_strKeyword, Code.ToString()));
|
||||
|
||||
if(m_bBuy == true)
|
||||
{
|
||||
ModelessPopup ManualPopup = new ModelessPopup(this);
|
||||
ManualPopup.SetMessage(string.Format("{0} 매수하시겠습니까?", Code.ToString()), Code);
|
||||
ManualPopup.Show();
|
||||
}
|
||||
break;
|
||||
|
||||
case TextCondition.TYPE.NOT_MATCHED:
|
||||
@@ -673,6 +700,16 @@ namespace NewsCrawler
|
||||
{
|
||||
Util.Clear();
|
||||
}
|
||||
|
||||
private void chBuy_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_bBuy = chBuy.Checked;
|
||||
|
||||
if(m_bBuy == true)
|
||||
Util.Log(Util.LOG_TYPE.VERVOSE, "매수 시작");
|
||||
else
|
||||
Util.Log(Util.LOG_TYPE.VERVOSE, "매수 취소");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
Util.cs
12
Util.cs
@@ -45,9 +45,9 @@ namespace NewsCrawler
|
||||
|
||||
bool bInvoke = mainForm != null ? mainForm.InvokeRequired || LogBox.InvokeRequired : LogBox.InvokeRequired;
|
||||
|
||||
if(bInvoke)
|
||||
if(LogBox.InvokeRequired)
|
||||
{
|
||||
mainForm.Invoke(new InsertLogDelegate(InsertLog), LogBox, enType, strLog);
|
||||
LogBox.Invoke(new InsertLogDelegate(InsertLog), LogBox, enType, strLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,11 +104,13 @@ namespace NewsCrawler
|
||||
|
||||
string strLogLevel = "["+enType+"] ";
|
||||
string strTime = DateTime.Now.ToString("[hh:mm:ss] ");
|
||||
string strMessage = strTime+strLogLevel+strLog+Environment.NewLine;
|
||||
string strMessage = strTime+strLogLevel+strLog;
|
||||
|
||||
File.AppendAllText(m_strLogFile, strMessage, new UTF8Encoding(true));
|
||||
File.AppendAllText(m_strLogFile, strMessage+Environment.NewLine, new UTF8Encoding(true));
|
||||
if(m_LogBox != null)
|
||||
InsertLog(m_LogBox, enType, strMessage);
|
||||
InsertLog(m_LogBox, enType, strMessage+Environment.NewLine);
|
||||
|
||||
Console.WriteLine(strMessage);
|
||||
}
|
||||
|
||||
public static bool IsDebugging()
|
||||
|
||||
Reference in New Issue
Block a user