From ed97e19e96ec1af1aadd8be959d683a5fac952f1 Mon Sep 17 00:00:00 2001 From: mjjo Date: Fri, 17 Feb 2017 04:00:59 +0900 Subject: [PATCH] =?UTF-8?q?-=20=EB=A7=A4=EB=8F=84=20=EA=B0=80=EA=B2=A9?= =?UTF-8?q?=EC=9D=84=20=EB=A7=A4=EB=8F=84=ED=98=B8=EA=B0=80=EC=9D=98=20?= =?UTF-8?q?=ED=95=9C=ED=98=B8=EA=B0=80=20=EC=95=84=EB=9E=98=EB=A1=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20-=20=EB=AF=B8=EC=B2=B4=EA=B2=B0=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoSeller.Designer.cs | 115 +++++++++++++++++++++++++++++++++++------ AutoSeller.cs | 42 +++++++++++++++ CybosHelper.cs | 79 ++++++++++++++++++++++++++-- 3 files changed, 216 insertions(+), 20 deletions(-) diff --git a/AutoSeller.Designer.cs b/AutoSeller.Designer.cs index 5e87a9d..d483090 100644 --- a/AutoSeller.Designer.cs +++ b/AutoSeller.Designer.cs @@ -56,6 +56,7 @@ this.tbSimulationLog = new System.Windows.Forms.RichTextBox(); this.btSimulate = new MaterialSkin.Controls.MaterialFlatButton(); this.btLoad = new MaterialSkin.Controls.MaterialFlatButton(); + this.splitContainer3 = new System.Windows.Forms.SplitContainer(); this.lvItems = new AutoSellerNS.ListViewNF(); this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -68,6 +69,12 @@ this.chYield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chMaxPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chCheckCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.lvNCItem = new AutoSellerNS.ListViewNF(); + this.chNCCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chNCCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chNCType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chNCPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chNCCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.lvCurPrice = new AutoSellerNS.ListViewNF(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chAskCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -85,6 +92,10 @@ this.splitContainer1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); + this.splitContainer3.Panel1.SuspendLayout(); + this.splitContainer3.Panel2.SuspendLayout(); + this.splitContainer3.SuspendLayout(); this.SuspendLayout(); // // materialTabSelector1 @@ -113,7 +124,7 @@ this.materialTabControl1.MouseState = MaterialSkin.MouseState.HOVER; this.materialTabControl1.Name = "materialTabControl1"; this.materialTabControl1.SelectedIndex = 0; - this.materialTabControl1.Size = new System.Drawing.Size(1068, 572); + this.materialTabControl1.Size = new System.Drawing.Size(1068, 719); this.materialTabControl1.TabIndex = 2; // // tabPage1 @@ -125,7 +136,7 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(1060, 546); + this.tabPage1.Size = new System.Drawing.Size(1060, 693); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Items"; this.tabPage1.UseVisualStyleBackColor = true; @@ -160,7 +171,7 @@ // splitContainer2.Panel2 // this.splitContainer2.Panel2.Controls.Add(this.lvCurPrice); - this.splitContainer2.Size = new System.Drawing.Size(1054, 508); + this.splitContainer2.Size = new System.Drawing.Size(1054, 655); this.splitContainer2.SplitterDistance = 804; this.splitContainer2.TabIndex = 2; this.splitContainer2.SizeChanged += new System.EventHandler(this.splitContainer2_SizeChanged); @@ -174,13 +185,13 @@ // // splitContainer1.Panel1 // - this.splitContainer1.Panel1.Controls.Add(this.lvItems); + this.splitContainer1.Panel1.Controls.Add(this.splitContainer3); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.tbLog); - this.splitContainer1.Size = new System.Drawing.Size(804, 508); - this.splitContainer1.SplitterDistance = 353; + this.splitContainer1.Size = new System.Drawing.Size(804, 655); + this.splitContainer1.SplitterDistance = 455; this.splitContainer1.TabIndex = 1; // // tbLog @@ -188,7 +199,7 @@ this.tbLog.Dock = System.Windows.Forms.DockStyle.Fill; this.tbLog.Location = new System.Drawing.Point(0, 0); this.tbLog.Name = "tbLog"; - this.tbLog.Size = new System.Drawing.Size(804, 151); + this.tbLog.Size = new System.Drawing.Size(804, 196); this.tbLog.TabIndex = 0; this.tbLog.Text = ""; // @@ -239,7 +250,7 @@ this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(1060, 546); + this.tabPage2.Size = new System.Drawing.Size(1060, 693); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Preference"; // @@ -334,12 +345,12 @@ this.materialLabel3.Depth = 0; this.materialLabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel3.Location = new System.Drawing.Point(6, 524); + this.materialLabel3.Location = new System.Drawing.Point(6, 671); this.materialLabel3.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel3.Name = "materialLabel3"; this.materialLabel3.Size = new System.Drawing.Size(162, 18); this.materialLabel3.TabIndex = 6; - this.materialLabel3.Text = "Version : 2017.02.07.09"; + this.materialLabel3.Text = "Version : 2017.02.17.04"; // // materialLabel2 // @@ -433,7 +444,7 @@ this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(1060, 546); + this.tabPage3.Size = new System.Drawing.Size(1060, 693); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Simulation"; this.tabPage3.UseVisualStyleBackColor = true; @@ -445,7 +456,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.tbSimulationLog.Location = new System.Drawing.Point(0, 204); this.tbSimulationLog.Name = "tbSimulationLog"; - this.tbSimulationLog.Size = new System.Drawing.Size(1060, 342); + this.tbSimulationLog.Size = new System.Drawing.Size(1060, 489); this.tbSimulationLog.TabIndex = 2; this.tbSimulationLog.Text = ""; // @@ -481,6 +492,24 @@ this.btLoad.UseVisualStyleBackColor = true; this.btLoad.Click += new System.EventHandler(this.btLoad_Click); // + // splitContainer3 + // + this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer3.Location = new System.Drawing.Point(0, 0); + this.splitContainer3.Name = "splitContainer3"; + this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer3.Panel1 + // + this.splitContainer3.Panel1.Controls.Add(this.lvItems); + // + // splitContainer3.Panel2 + // + this.splitContainer3.Panel2.Controls.Add(this.lvNCItem); + this.splitContainer3.Size = new System.Drawing.Size(804, 455); + this.splitContainer3.SplitterDistance = 300; + this.splitContainer3.TabIndex = 1; + // // lvItems // this.lvItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -500,7 +529,7 @@ this.lvItems.GridLines = true; this.lvItems.Location = new System.Drawing.Point(0, 0); this.lvItems.Name = "lvItems"; - this.lvItems.Size = new System.Drawing.Size(804, 353); + this.lvItems.Size = new System.Drawing.Size(804, 300); this.lvItems.TabIndex = 0; this.lvItems.UseCompatibleStateImageBehavior = false; this.lvItems.View = System.Windows.Forms.View.Details; @@ -567,6 +596,51 @@ this.chCheckCount.Text = "조건횟수"; this.chCheckCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // + // lvNCItem + // + this.lvNCItem.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chNCCode, + this.chNCCodeName, + this.chNCType, + this.chNCPrice, + this.chNCCount}); + this.lvNCItem.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvNCItem.FullRowSelect = true; + this.lvNCItem.GridLines = true; + this.lvNCItem.Location = new System.Drawing.Point(0, 0); + this.lvNCItem.Name = "lvNCItem"; + this.lvNCItem.Size = new System.Drawing.Size(804, 151); + this.lvNCItem.TabIndex = 1; + this.lvNCItem.UseCompatibleStateImageBehavior = false; + this.lvNCItem.View = System.Windows.Forms.View.Details; + // + // chNCCode + // + this.chNCCode.Text = "코드"; + this.chNCCode.Width = 77; + // + // chNCCodeName + // + this.chNCCodeName.Text = "종목명"; + this.chNCCodeName.Width = 86; + // + // chNCType + // + this.chNCType.Text = "매매구분"; + this.chNCType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chNCType.Width = 71; + // + // chNCPrice + // + this.chNCPrice.Text = "주문단가"; + this.chNCPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chNCPrice.Width = 72; + // + // chNCCount + // + this.chNCCount.Text = "미체결량"; + this.chNCCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // // lvCurPrice // this.lvCurPrice.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -579,7 +653,7 @@ this.lvCurPrice.GridLines = true; this.lvCurPrice.Location = new System.Drawing.Point(0, 0); this.lvCurPrice.Name = "lvCurPrice"; - this.lvCurPrice.Size = new System.Drawing.Size(246, 508); + this.lvCurPrice.Size = new System.Drawing.Size(246, 655); this.lvCurPrice.TabIndex = 0; this.lvCurPrice.UseCompatibleStateImageBehavior = false; this.lvCurPrice.View = System.Windows.Forms.View.Details; @@ -609,7 +683,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1074, 690); + this.ClientSize = new System.Drawing.Size(1074, 837); this.Controls.Add(this.materialTabSelector1); this.Controls.Add(this.materialTabControl1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -630,6 +704,10 @@ this.tabPage2.PerformLayout(); this.tabPage3.ResumeLayout(false); this.tabPage3.PerformLayout(); + this.splitContainer3.Panel1.ResumeLayout(false); + this.splitContainer3.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); + this.splitContainer3.ResumeLayout(false); this.ResumeLayout(false); } @@ -679,5 +757,12 @@ private MaterialSkin.Controls.MaterialFlatButton btLoad; private MaterialSkin.Controls.MaterialFlatButton btSimulate; private System.Windows.Forms.RichTextBox tbSimulationLog; + private System.Windows.Forms.SplitContainer splitContainer3; + private ListViewNF lvNCItem; + private System.Windows.Forms.ColumnHeader chNCCode; + private System.Windows.Forms.ColumnHeader chNCCodeName; + private System.Windows.Forms.ColumnHeader chNCType; + private System.Windows.Forms.ColumnHeader chNCCount; + private System.Windows.Forms.ColumnHeader chNCPrice; } } \ No newline at end of file diff --git a/AutoSeller.cs b/AutoSeller.cs index eff477d..9f39c7d 100644 --- a/AutoSeller.cs +++ b/AutoSeller.cs @@ -30,6 +30,15 @@ namespace AutoSellerNS public int m_iCurPrice; } + public class NCITEM + { + public string m_strCodeName; + public string m_strCode; + public int m_iRemainCnt; + public int m_iOrderPrice; + public string m_strDesc; + } + int m_iCurPricePanelWith; CybosHelper m_CybosHelper = null; @@ -179,12 +188,45 @@ namespace AutoSellerNS private void btUpdate_Click(object sender, EventArgs e) { + // 잔고 var Items = m_CybosHelper.UpdateItems(); m_Items.Clear(); lvItems.Items.Clear(); foreach (var Item in Items) AddItem(Item); + + // 미체결 + var NCItems = m_CybosHelper.UpdateNC(); + lvNCItem.Clear(); + if(lvNCItem.InvokeRequired) + { + lvNCItem.Invoke(new Action(() => { + foreach(var NCItem in NCItems) + { + lvNCItem.Items.Add(new ListViewItem(new string[] { + NCItem.m_strCode, + NCItem.m_strCodeName, + NCItem.m_strDesc, + string.Format("{0:0n}", NCItem.m_iOrderPrice), + string.Format("{0:0n}", NCItem.m_iRemainCnt), + })); + } + })); + } + else + { + foreach(var NCItem in NCItems) + { + lvNCItem.Items.Add(new ListViewItem(new string[] { + NCItem.m_strCode, + NCItem.m_strCodeName, + NCItem.m_strDesc, + string.Format("{0:0n}", NCItem.m_iOrderPrice), + string.Format("{0:0n}", NCItem.m_iRemainCnt), + })); + } + } } public void UpdateItem(string strCode, string strCodeName, bool bBid, int iConclusionCnt, int iRemainCnt, int iBookValue) diff --git a/CybosHelper.cs b/CybosHelper.cs index 37dbaee..0a553bf 100644 --- a/CybosHelper.cs +++ b/CybosHelper.cs @@ -48,7 +48,7 @@ namespace AutoSellerNS if(m_iCheckCount >= Config.GetBidCount() && m_Listener.IsSelling() == true) { - m_CybosHelper.SellItem(m_strCode, m_iCurPrice, m_Listener.GetSellableCount(m_strCode)); + m_CybosHelper.SellItem(m_strCode, m_Listener.GetSellableCount(m_strCode), m_aiAskPrice[0]); Util.Log(Util.LOG_TYPE.SELL, string.Format("[조건 완료 매도] {0} ({1}회) (현재가 {2:n0}원, 최고가 {3:n0}원)", m_strCodeName, Config.GetBidCount(), m_iCurPrice, m_iMaxPrice)); } @@ -56,7 +56,7 @@ namespace AutoSellerNS m_iTrailingCount++; if(m_iTrailingCount >= Config.GetTrailingCnt() && m_Listener.IsSelling() == true) { - m_CybosHelper.SellItem(m_strCode, m_iCurPrice, m_Listener.GetSellableCount(m_strCode)); + m_CybosHelper.SellItem(m_strCode, m_Listener.GetSellableCount(m_strCode), m_aiAskPrice[0]); Util.Log(Util.LOG_TYPE.SELL, string.Format("[트레일링 매도] {0} ({1}% {2}회) (현재가 {2:n0}원, 최고가 {3:n0}원)", m_strCodeName, Config.GetTrailingRate(), Config.GetTrailingCnt(), m_iCurPrice, m_iMaxPrice)); } @@ -211,6 +211,40 @@ namespace AutoSellerNS return aItems; } + public List UpdateNC() + { + List NCItems = new List(); + + CPTRADELib.CpTd5339 CP5339 = new CPTRADELib.CpTd5339(); + CP5339.SetInputValue(0, Config.GetAccount()); + CP5339.SetInputValue(1, Config.GetSubAccount()); + CP5339.BlockRequest2(0); + + bool bContinue = true; + while(bContinue) + { + int iCnt = CP5339.GetHeaderValue(5); + for(int i = 0; i