From 0a3bc6b77d25ea58ccadccf18ced577bb8a7546d Mon Sep 17 00:00:00 2001 From: mjjo53 Date: Mon, 15 Oct 2018 15:48:04 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoSeller.Designer.cs | 837 ++++++++++++++++++++++++++--------------- AutoSeller.cs | 228 +++++++++-- AutoSeller.csproj | 2 + CurrentItem.cs | 203 ++++++++++ CybosHelper.cs | 631 ++++++++++++++++--------------- TaskExtensions.cs | 28 ++ Util.cs | 21 +- 7 files changed, 1295 insertions(+), 655 deletions(-) create mode 100644 CurrentItem.cs create mode 100644 TaskExtensions.cs diff --git a/AutoSeller.Designer.cs b/AutoSeller.Designer.cs index 351479b..d4e5d23 100644 --- a/AutoSeller.Designer.cs +++ b/AutoSeller.Designer.cs @@ -32,40 +32,27 @@ this.materialTabSelector1 = new MaterialSkin.Controls.MaterialTabSelector(); this.materialTabControl1 = new MaterialSkin.Controls.MaterialTabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.btClearAll = new MaterialSkin.Controls.MaterialRaisedButton(); + this.lbRQCnt = new MaterialSkin.Controls.MaterialLabel(); + this.lbTRCnt = new MaterialSkin.Controls.MaterialLabel(); + this.lbSBCnt = new MaterialSkin.Controls.MaterialLabel(); this.btSell = new MaterialSkin.Controls.MaterialRaisedButton(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 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())); - this.chCurPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chBookValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chCapitalGains = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chAssessedValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chValuation = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chYield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chMaxPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chCheckCountLimit = ((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.chNCOrderNo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chNCOrgOrderNo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - 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.splitContainer4 = new System.Windows.Forms.SplitContainer(); + this.btUpdateNC = new MaterialSkin.Controls.MaterialRaisedButton(); this.tbLog = new System.Windows.Forms.RichTextBox(); - 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())); - this.chCallPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chBidCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.btUpdate = new MaterialSkin.Controls.MaterialRaisedButton(); this.btCybos = new MaterialSkin.Controls.MaterialRaisedButton(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.btUpdateConclusion = new MaterialSkin.Controls.MaterialRaisedButton(); + this.lvConclusion = new System.Windows.Forms.ListView(); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabPage3 = new System.Windows.Forms.TabPage(); this.cbMockTrading = new System.Windows.Forms.CheckBox(); this.materialLabel18 = new MaterialSkin.Controls.MaterialLabel(); this.tbCFIgnorePrice = new MaterialSkin.Controls.MaterialSingleLineTextField(); @@ -101,7 +88,7 @@ this.btApply = new MaterialSkin.Controls.MaterialFlatButton(); this.tbSubAccount = new MaterialSkin.Controls.MaterialSingleLineTextField(); this.cbAccount = new System.Windows.Forms.ComboBox(); - this.tabPage3 = new System.Windows.Forms.TabPage(); + this.tabPage4 = new System.Windows.Forms.TabPage(); this.chSMHalfTrailing = new MaterialSkin.Controls.MaterialCheckBox(); this.tbSMSlowDownCnt = new System.Windows.Forms.TextBox(); this.tbSMFastDownCnt = new System.Windows.Forms.TextBox(); @@ -117,6 +104,37 @@ this.tbSimulationLog = new System.Windows.Forms.RichTextBox(); this.btSimulate = new MaterialSkin.Controls.MaterialFlatButton(); this.btLoad = new MaterialSkin.Controls.MaterialFlatButton(); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + 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())); + this.chCurPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chBookValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCapitalGains = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chAssessedValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chValuation = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chYield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chMaxPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCheckCountLimit = ((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.chNCOrderNo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chNCOrgOrderNo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + 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())); + this.chCallPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chBidCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.materialTabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); @@ -131,8 +149,13 @@ this.splitContainer3.Panel1.SuspendLayout(); this.splitContainer3.Panel2.SuspendLayout(); this.splitContainer3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).BeginInit(); + this.splitContainer4.Panel1.SuspendLayout(); + this.splitContainer4.Panel2.SuspendLayout(); + this.splitContainer4.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); + this.tabPage4.SuspendLayout(); this.SuspendLayout(); // // materialTabSelector1 @@ -156,6 +179,7 @@ this.materialTabControl1.Controls.Add(this.tabPage1); this.materialTabControl1.Controls.Add(this.tabPage2); this.materialTabControl1.Controls.Add(this.tabPage3); + this.materialTabControl1.Controls.Add(this.tabPage4); this.materialTabControl1.Depth = 0; this.materialTabControl1.Location = new System.Drawing.Point(3, 115); this.materialTabControl1.MouseState = MaterialSkin.MouseState.HOVER; @@ -166,6 +190,10 @@ // // tabPage1 // + this.tabPage1.Controls.Add(this.btClearAll); + this.tabPage1.Controls.Add(this.lbRQCnt); + this.tabPage1.Controls.Add(this.lbTRCnt); + this.tabPage1.Controls.Add(this.lbSBCnt); this.tabPage1.Controls.Add(this.btSell); this.tabPage1.Controls.Add(this.splitContainer2); this.tabPage1.Controls.Add(this.btUpdate); @@ -178,6 +206,59 @@ this.tabPage1.Text = "Items"; this.tabPage1.UseVisualStyleBackColor = true; // + // btClearAll + // + this.btClearAll.AutoSize = true; + this.btClearAll.Depth = 0; + this.btClearAll.Location = new System.Drawing.Point(916, 3); + this.btClearAll.MouseState = MaterialSkin.MouseState.HOVER; + this.btClearAll.Name = "btClearAll"; + this.btClearAll.Primary = true; + this.btClearAll.Size = new System.Drawing.Size(68, 28); + this.btClearAll.TabIndex = 8; + this.btClearAll.Text = "Clear"; + this.btClearAll.UseVisualStyleBackColor = true; + this.btClearAll.Click += new System.EventHandler(this.btClearAll_Click); + // + // lbRQCnt + // + this.lbRQCnt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lbRQCnt.AutoSize = true; + this.lbRQCnt.Depth = 0; + this.lbRQCnt.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); + this.lbRQCnt.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.lbRQCnt.Location = new System.Drawing.Point(1026, 6); + this.lbRQCnt.MouseState = MaterialSkin.MouseState.HOVER; + this.lbRQCnt.Name = "lbRQCnt"; + this.lbRQCnt.Size = new System.Drawing.Size(0, 18); + this.lbRQCnt.TabIndex = 7; + // + // lbTRCnt + // + this.lbTRCnt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lbTRCnt.AutoSize = true; + this.lbTRCnt.Depth = 0; + this.lbTRCnt.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); + this.lbTRCnt.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.lbTRCnt.Location = new System.Drawing.Point(1060, 6); + this.lbTRCnt.MouseState = MaterialSkin.MouseState.HOVER; + this.lbTRCnt.Name = "lbTRCnt"; + this.lbTRCnt.Size = new System.Drawing.Size(0, 18); + this.lbTRCnt.TabIndex = 6; + // + // lbSBCnt + // + this.lbSBCnt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lbSBCnt.AutoSize = true; + this.lbSBCnt.Depth = 0; + this.lbSBCnt.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); + this.lbSBCnt.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.lbSBCnt.Location = new System.Drawing.Point(1094, 6); + this.lbSBCnt.MouseState = MaterialSkin.MouseState.HOVER; + this.lbSBCnt.Name = "lbSBCnt"; + this.lbSBCnt.Size = new System.Drawing.Size(0, 18); + this.lbSBCnt.TabIndex = 5; + // // btSell // this.btSell.AutoSize = true; @@ -244,158 +325,41 @@ // // splitContainer3.Panel2 // - this.splitContainer3.Panel2.Controls.Add(this.lvNCItem); + this.splitContainer3.Panel2.Controls.Add(this.splitContainer4); this.splitContainer3.Size = new System.Drawing.Size(859, 415); this.splitContainer3.SplitterDistance = 273; this.splitContainer3.TabIndex = 1; // - // lvItems + // splitContainer4 // - this.lvItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chCode, - this.chCodeName, - this.chCurPrice, - this.chCount, - this.chBookValue, - this.chCapitalGains, - this.chAssessedValue, - this.chValuation, - this.chYield, - this.chMaxPrice, - this.chCheckCountLimit, - this.chCheckCount}); - this.lvItems.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvItems.FullRowSelect = true; - this.lvItems.GridLines = true; - this.lvItems.Location = new System.Drawing.Point(0, 0); - this.lvItems.Name = "lvItems"; - this.lvItems.Size = new System.Drawing.Size(859, 273); - this.lvItems.TabIndex = 0; - this.lvItems.UseCompatibleStateImageBehavior = false; - this.lvItems.View = System.Windows.Forms.View.Details; - this.lvItems.SelectedIndexChanged += new System.EventHandler(this.lvList_SelectedIndexChanged); + this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer4.Location = new System.Drawing.Point(0, 0); + this.splitContainer4.Name = "splitContainer4"; // - // chCode + // splitContainer4.Panel1 // - this.chCode.Text = "코드"; - this.chCode.Width = 77; + this.splitContainer4.Panel1.Controls.Add(this.lvNCItem); // - // chCodeName + // splitContainer4.Panel2 // - this.chCodeName.Text = "종목명"; - this.chCodeName.Width = 86; + this.splitContainer4.Panel2.Controls.Add(this.btUpdateNC); + this.splitContainer4.Size = new System.Drawing.Size(859, 138); + this.splitContainer4.SplitterDistance = 772; + this.splitContainer4.TabIndex = 2; // - // chCurPrice + // btUpdateNC // - this.chCurPrice.Text = "현재가"; - this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chCurPrice.Width = 71; - // - // chCount - // - this.chCount.Text = "잔고수량"; - this.chCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // chBookValue - // - this.chBookValue.Text = "장부가"; - this.chBookValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chBookValue.Width = 72; - // - // chCapitalGains - // - this.chCapitalGains.Text = "손익단가"; - this.chCapitalGains.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chCapitalGains.Width = 73; - // - // chAssessedValue - // - this.chAssessedValue.Text = "평가금액"; - this.chAssessedValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chAssessedValue.Width = 76; - // - // chValuation - // - this.chValuation.Text = "평가손익"; - this.chValuation.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chValuation.Width = 79; - // - // chYield - // - this.chYield.Text = "수익률"; - this.chYield.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chYield.Width = 79; - // - // chMaxPrice - // - this.chMaxPrice.Text = "최고가"; - this.chMaxPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // chCheckCountLimit - // - this.chCheckCountLimit.Text = "조건제한"; - this.chCheckCountLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // chCheckCount - // - this.chCheckCount.Text = "조건횟수"; - this.chCheckCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // lvNCItem - // - this.lvNCItem.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chNCOrderNo, - this.chNCOrgOrderNo, - 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(859, 138); - this.lvNCItem.TabIndex = 1; - this.lvNCItem.UseCompatibleStateImageBehavior = false; - this.lvNCItem.View = System.Windows.Forms.View.Details; - // - // chNCOrderNo - // - this.chNCOrderNo.Text = "주문번호"; - // - // chNCOrgOrderNo - // - this.chNCOrgOrderNo.Text = "원주문번호"; - this.chNCOrgOrderNo.Width = 91; - // - // chNCCode - // - this.chNCCode.Text = "코드"; - this.chNCCode.Width = 77; - // - // chNCCodeName - // - this.chNCCodeName.Text = "종목명"; - this.chNCCodeName.Width = 101; - // - // chNCType - // - this.chNCType.Text = "매매구분"; - this.chNCType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chNCType.Width = 106; - // - // 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; + this.btUpdateNC.AutoSize = true; + this.btUpdateNC.Depth = 0; + this.btUpdateNC.Location = new System.Drawing.Point(3, 3); + this.btUpdateNC.MouseState = MaterialSkin.MouseState.HOVER; + this.btUpdateNC.Name = "btUpdateNC"; + this.btUpdateNC.Primary = true; + this.btUpdateNC.Size = new System.Drawing.Size(77, 28); + this.btUpdateNC.TabIndex = 4; + this.btUpdateNC.Text = "Update"; + this.btUpdateNC.UseVisualStyleBackColor = true; + this.btUpdateNC.Click += new System.EventHandler(this.btUpdateNC_Click); // // tbLog // @@ -406,44 +370,6 @@ this.tbLog.TabIndex = 0; this.tbLog.Text = ""; // - // lvCurPrice - // - this.lvCurPrice.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.chAskCount, - this.chCallPrice, - this.chBidCount}); - this.lvCurPrice.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvCurPrice.FullRowSelect = true; - this.lvCurPrice.GridLines = true; - this.lvCurPrice.Location = new System.Drawing.Point(0, 0); - this.lvCurPrice.Name = "lvCurPrice"; - this.lvCurPrice.Size = new System.Drawing.Size(264, 598); - this.lvCurPrice.TabIndex = 0; - this.lvCurPrice.UseCompatibleStateImageBehavior = false; - this.lvCurPrice.View = System.Windows.Forms.View.Details; - // - // columnHeader1 - // - this.columnHeader1.Width = 10; - // - // chAskCount - // - this.chAskCount.Text = "매도잔량"; - this.chAskCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chAskCount.Width = 75; - // - // chCallPrice - // - this.chCallPrice.Text = "호가"; - this.chCallPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // chBidCount - // - this.chBidCount.Text = "매수잔량"; - this.chBidCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chBidCount.Width = 75; - // // btUpdate // this.btUpdate.AutoSize = true; @@ -474,48 +400,113 @@ // // tabPage2 // - this.tabPage2.BackColor = System.Drawing.Color.White; - this.tabPage2.Controls.Add(this.cbMockTrading); - this.tabPage2.Controls.Add(this.materialLabel18); - this.tabPage2.Controls.Add(this.tbCFIgnorePrice); - this.tabPage2.Controls.Add(this.materialLabel17); - this.tabPage2.Controls.Add(this.materialLabel14); - this.tabPage2.Controls.Add(this.materialLabel13); - this.tabPage2.Controls.Add(this.tbCFSlowDown); - this.tabPage2.Controls.Add(this.tbCFSlowUp); - this.tabPage2.Controls.Add(this.tbCFSlowSD); - this.tabPage2.Controls.Add(this.materialLabel15); - this.tabPage2.Controls.Add(this.materialLabel11); - this.tabPage2.Controls.Add(this.materialLabel8); - this.tabPage2.Controls.Add(this.tbCFFastDown); - this.tabPage2.Controls.Add(this.tbCFFastUp); - this.tabPage2.Controls.Add(this.tbCFFastSD); - this.tabPage2.Controls.Add(this.materialLabel12); - this.tabPage2.Controls.Add(this.tbCFTimeLimit); - this.tabPage2.Controls.Add(this.tbCFTimeDown); - this.tabPage2.Controls.Add(this.tbCFListSize); - this.tabPage2.Controls.Add(this.materialLabel16); - this.tabPage2.Controls.Add(this.materialLabel9); - this.tabPage2.Controls.Add(this.materialLabel10); - this.tabPage2.Controls.Add(this.materialLabel7); - this.tabPage2.Controls.Add(this.tbTrailingCnt); - this.tabPage2.Controls.Add(this.materialLabel6); - this.tabPage2.Controls.Add(this.tbTrailingP); - this.tabPage2.Controls.Add(this.materialLabel5); - this.tabPage2.Controls.Add(this.materialLabel4); - this.tabPage2.Controls.Add(this.materialLabel3); - this.tabPage2.Controls.Add(this.materialLabel2); - this.tabPage2.Controls.Add(this.tbBidCount); - this.tabPage2.Controls.Add(this.materialLabel1); - this.tabPage2.Controls.Add(this.btApply); - this.tabPage2.Controls.Add(this.tbSubAccount); - this.tabPage2.Controls.Add(this.cbAccount); + this.tabPage2.Controls.Add(this.btUpdateConclusion); + this.tabPage2.Controls.Add(this.lvConclusion); 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(1133, 636); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Preference"; + this.tabPage2.TabIndex = 3; + this.tabPage2.Text = "Conclusion"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // btUpdateConclusion + // + this.btUpdateConclusion.Depth = 0; + this.btUpdateConclusion.Location = new System.Drawing.Point(6, 6); + this.btUpdateConclusion.MouseState = MaterialSkin.MouseState.HOVER; + this.btUpdateConclusion.Name = "btUpdateConclusion"; + this.btUpdateConclusion.Primary = true; + this.btUpdateConclusion.Size = new System.Drawing.Size(75, 23); + this.btUpdateConclusion.TabIndex = 1; + this.btUpdateConclusion.Text = "update"; + this.btUpdateConclusion.UseVisualStyleBackColor = true; + this.btUpdateConclusion.Click += new System.EventHandler(this.btUpdateConclusion_Click); + // + // lvConclusion + // + this.lvConclusion.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lvConclusion.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5, + this.columnHeader6, + this.columnHeader7, + this.columnHeader8, + this.columnHeader9, + this.columnHeader10}); + this.lvConclusion.FullRowSelect = true; + this.lvConclusion.GridLines = true; + this.lvConclusion.Location = new System.Drawing.Point(0, 35); + this.lvConclusion.Name = "lvConclusion"; + this.lvConclusion.Size = new System.Drawing.Size(1133, 601); + this.lvConclusion.TabIndex = 0; + this.lvConclusion.UseCompatibleStateImageBehavior = false; + this.lvConclusion.View = System.Windows.Forms.View.Details; + // + // columnHeader2 + // + this.columnHeader2.Text = "종목코드"; + // + // columnHeader3 + // + this.columnHeader3.Text = "종목명"; + // + // columnHeader4 + // + this.columnHeader4.Text = "구분"; + // + // columnHeader5 + // + this.columnHeader5.Text = "약정금액"; + // + // tabPage3 + // + this.tabPage3.BackColor = System.Drawing.Color.White; + this.tabPage3.Controls.Add(this.cbMockTrading); + this.tabPage3.Controls.Add(this.materialLabel18); + this.tabPage3.Controls.Add(this.tbCFIgnorePrice); + this.tabPage3.Controls.Add(this.materialLabel17); + this.tabPage3.Controls.Add(this.materialLabel14); + this.tabPage3.Controls.Add(this.materialLabel13); + this.tabPage3.Controls.Add(this.tbCFSlowDown); + this.tabPage3.Controls.Add(this.tbCFSlowUp); + this.tabPage3.Controls.Add(this.tbCFSlowSD); + this.tabPage3.Controls.Add(this.materialLabel15); + this.tabPage3.Controls.Add(this.materialLabel11); + this.tabPage3.Controls.Add(this.materialLabel8); + this.tabPage3.Controls.Add(this.tbCFFastDown); + this.tabPage3.Controls.Add(this.tbCFFastUp); + this.tabPage3.Controls.Add(this.tbCFFastSD); + this.tabPage3.Controls.Add(this.materialLabel12); + this.tabPage3.Controls.Add(this.tbCFTimeLimit); + this.tabPage3.Controls.Add(this.tbCFTimeDown); + this.tabPage3.Controls.Add(this.tbCFListSize); + this.tabPage3.Controls.Add(this.materialLabel16); + this.tabPage3.Controls.Add(this.materialLabel9); + this.tabPage3.Controls.Add(this.materialLabel10); + this.tabPage3.Controls.Add(this.materialLabel7); + this.tabPage3.Controls.Add(this.tbTrailingCnt); + this.tabPage3.Controls.Add(this.materialLabel6); + this.tabPage3.Controls.Add(this.tbTrailingP); + this.tabPage3.Controls.Add(this.materialLabel5); + this.tabPage3.Controls.Add(this.materialLabel4); + this.tabPage3.Controls.Add(this.materialLabel3); + this.tabPage3.Controls.Add(this.materialLabel2); + this.tabPage3.Controls.Add(this.tbBidCount); + this.tabPage3.Controls.Add(this.materialLabel1); + this.tabPage3.Controls.Add(this.btApply); + this.tabPage3.Controls.Add(this.tbSubAccount); + this.tabPage3.Controls.Add(this.cbAccount); + 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(1133, 636); + this.tabPage3.TabIndex = 1; + this.tabPage3.Text = "Preference"; // // cbMockTrading // @@ -531,12 +522,12 @@ // this.materialLabel18.AutoSize = true; this.materialLabel18.Depth = 0; - this.materialLabel18.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel18.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel18.Location = new System.Drawing.Point(99, 455); this.materialLabel18.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel18.Name = "materialLabel18"; - this.materialLabel18.Size = new System.Drawing.Size(98, 19); + this.materialLabel18.Size = new System.Drawing.Size(114, 18); this.materialLabel18.TabIndex = 37; this.materialLabel18.Text = "원 이하 체결 무시"; // @@ -560,12 +551,12 @@ // this.materialLabel17.AutoSize = true; this.materialLabel17.Depth = 0; - this.materialLabel17.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel17.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel17.Location = new System.Drawing.Point(187, 424); this.materialLabel17.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel17.Name = "materialLabel17"; - this.materialLabel17.Size = new System.Drawing.Size(94, 19); + this.materialLabel17.Size = new System.Drawing.Size(107, 18); this.materialLabel17.TabIndex = 35; this.materialLabel17.Text = "초 이상이면 매도"; // @@ -573,12 +564,12 @@ // this.materialLabel14.AutoSize = true; this.materialLabel14.Depth = 0; - this.materialLabel14.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel14.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel14.Location = new System.Drawing.Point(209, 389); this.materialLabel14.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel14.Name = "materialLabel14"; - this.materialLabel14.Size = new System.Drawing.Size(13, 19); + this.materialLabel14.Size = new System.Drawing.Size(13, 18); this.materialLabel14.TabIndex = 34; this.materialLabel14.Text = "-"; // @@ -586,12 +577,12 @@ // this.materialLabel13.AutoSize = true; this.materialLabel13.Depth = 0; - this.materialLabel13.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel13.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel13.Location = new System.Drawing.Point(143, 390); this.materialLabel13.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel13.Name = "materialLabel13"; - this.materialLabel13.Size = new System.Drawing.Size(18, 19); + this.materialLabel13.Size = new System.Drawing.Size(17, 18); this.materialLabel13.TabIndex = 34; this.materialLabel13.Text = "+"; // @@ -647,12 +638,12 @@ // this.materialLabel15.AutoSize = true; this.materialLabel15.Depth = 0; - this.materialLabel15.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel15.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel15.Location = new System.Drawing.Point(25, 391); this.materialLabel15.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel15.Name = "materialLabel15"; - this.materialLabel15.Size = new System.Drawing.Size(57, 19); + this.materialLabel15.Size = new System.Drawing.Size(64, 18); this.materialLabel15.TabIndex = 30; this.materialLabel15.Text = "저 변동성"; // @@ -660,12 +651,12 @@ // this.materialLabel11.AutoSize = true; this.materialLabel11.Depth = 0; - this.materialLabel11.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel11.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel11.Location = new System.Drawing.Point(209, 355); this.materialLabel11.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel11.Name = "materialLabel11"; - this.materialLabel11.Size = new System.Drawing.Size(13, 19); + this.materialLabel11.Size = new System.Drawing.Size(13, 18); this.materialLabel11.TabIndex = 29; this.materialLabel11.Text = "-"; // @@ -673,12 +664,12 @@ // this.materialLabel8.AutoSize = true; this.materialLabel8.Depth = 0; - this.materialLabel8.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel8.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel8.Location = new System.Drawing.Point(143, 355); this.materialLabel8.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel8.Name = "materialLabel8"; - this.materialLabel8.Size = new System.Drawing.Size(18, 19); + this.materialLabel8.Size = new System.Drawing.Size(17, 18); this.materialLabel8.TabIndex = 29; this.materialLabel8.Text = "+"; // @@ -734,12 +725,12 @@ // this.materialLabel12.AutoSize = true; this.materialLabel12.Depth = 0; - this.materialLabel12.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel12.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel12.Location = new System.Drawing.Point(25, 356); this.materialLabel12.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel12.Name = "materialLabel12"; - this.materialLabel12.Size = new System.Drawing.Size(57, 19); + this.materialLabel12.Size = new System.Drawing.Size(64, 18); this.materialLabel12.TabIndex = 25; this.materialLabel12.Text = "고 변동성"; // @@ -795,12 +786,12 @@ // this.materialLabel16.AutoSize = true; this.materialLabel16.Depth = 0; - this.materialLabel16.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel16.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel16.Location = new System.Drawing.Point(99, 424); this.materialLabel16.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel16.Name = "materialLabel16"; - this.materialLabel16.Size = new System.Drawing.Size(31, 19); + this.materialLabel16.Size = new System.Drawing.Size(34, 18); this.materialLabel16.TabIndex = 22; this.materialLabel16.Text = "감소"; // @@ -808,12 +799,12 @@ // this.materialLabel9.AutoSize = true; this.materialLabel9.Depth = 0; - this.materialLabel9.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel9.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel9.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel9.Location = new System.Drawing.Point(26, 424); this.materialLabel9.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel9.Name = "materialLabel9"; - this.materialLabel9.Size = new System.Drawing.Size(31, 19); + this.materialLabel9.Size = new System.Drawing.Size(34, 18); this.materialLabel9.TabIndex = 22; this.materialLabel9.Text = "초당"; // @@ -821,12 +812,12 @@ // this.materialLabel10.AutoSize = true; this.materialLabel10.Depth = 0; - this.materialLabel10.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel10.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel10.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel10.Location = new System.Drawing.Point(25, 322); this.materialLabel10.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel10.Name = "materialLabel10"; - this.materialLabel10.Size = new System.Drawing.Size(46, 19); + this.materialLabel10.Size = new System.Drawing.Size(51, 18); this.materialLabel10.TabIndex = 22; this.materialLabel10.Text = "체결 수"; // @@ -834,12 +825,12 @@ // this.materialLabel7.AutoSize = true; this.materialLabel7.Depth = 0; - this.materialLabel7.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel7.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel7.Location = new System.Drawing.Point(224, 229); this.materialLabel7.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel7.Name = "materialLabel7"; - this.materialLabel7.Size = new System.Drawing.Size(20, 19); + this.materialLabel7.Size = new System.Drawing.Size(21, 18); this.materialLabel7.TabIndex = 12; this.materialLabel7.Text = "회"; // @@ -863,12 +854,12 @@ // this.materialLabel6.AutoSize = true; this.materialLabel6.Depth = 0; - this.materialLabel6.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel6.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel6.Location = new System.Drawing.Point(152, 229); this.materialLabel6.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel6.Name = "materialLabel6"; - this.materialLabel6.Size = new System.Drawing.Size(20, 19); + this.materialLabel6.Size = new System.Drawing.Size(21, 18); this.materialLabel6.TabIndex = 10; this.materialLabel6.Text = "%"; // @@ -892,12 +883,12 @@ // this.materialLabel5.AutoSize = true; this.materialLabel5.Depth = 0; - this.materialLabel5.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel5.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel5.Location = new System.Drawing.Point(25, 229); this.materialLabel5.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel5.Name = "materialLabel5"; - this.materialLabel5.Size = new System.Drawing.Size(68, 19); + this.materialLabel5.Size = new System.Drawing.Size(77, 18); this.materialLabel5.TabIndex = 8; this.materialLabel5.Text = "최고가 대비"; // @@ -905,12 +896,12 @@ // this.materialLabel4.AutoSize = true; this.materialLabel4.Depth = 0; - this.materialLabel4.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel4.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel4.Location = new System.Drawing.Point(25, 144); this.materialLabel4.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel4.Name = "materialLabel4"; - this.materialLabel4.Size = new System.Drawing.Size(57, 19); + this.materialLabel4.Size = new System.Drawing.Size(64, 18); this.materialLabel4.TabIndex = 7; this.materialLabel4.Text = "조건 횟수"; // @@ -919,12 +910,12 @@ this.materialLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.materialLabel3.AutoSize = true; this.materialLabel3.Depth = 0; - this.materialLabel3.Font = new System.Drawing.Font("Roboto", 11F); + 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, 614); this.materialLabel3.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel3.Name = "materialLabel3"; - this.materialLabel3.Size = new System.Drawing.Size(165, 19); + this.materialLabel3.Size = new System.Drawing.Size(162, 18); this.materialLabel3.TabIndex = 6; this.materialLabel3.Text = "Version : 2018.01.04.12"; // @@ -932,12 +923,12 @@ // this.materialLabel2.AutoSize = true; this.materialLabel2.Depth = 0; - this.materialLabel2.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel2.Location = new System.Drawing.Point(152, 148); this.materialLabel2.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel2.Name = "materialLabel2"; - this.materialLabel2.Size = new System.Drawing.Size(20, 19); + this.materialLabel2.Size = new System.Drawing.Size(21, 18); this.materialLabel2.TabIndex = 5; this.materialLabel2.Text = "회"; // @@ -961,12 +952,12 @@ // this.materialLabel1.AutoSize = true; this.materialLabel1.Depth = 0; - this.materialLabel1.Font = new System.Drawing.Font("Roboto", 11F); + this.materialLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F); this.materialLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel1.Location = new System.Drawing.Point(25, 29); this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel1.Name = "materialLabel1"; - this.materialLabel1.Size = new System.Drawing.Size(65, 19); + this.materialLabel1.Size = new System.Drawing.Size(62, 18); this.materialLabel1.TabIndex = 3; this.materialLabel1.Text = "Account"; // @@ -1012,36 +1003,36 @@ this.cbAccount.Size = new System.Drawing.Size(121, 20); this.cbAccount.TabIndex = 0; // - // tabPage3 + // tabPage4 // - this.tabPage3.Controls.Add(this.chSMHalfTrailing); - this.tabPage3.Controls.Add(this.tbSMSlowDownCnt); - this.tabPage3.Controls.Add(this.tbSMFastDownCnt); - this.tabPage3.Controls.Add(this.cbSMMethod); - this.tabPage3.Controls.Add(this.tbSMListSize); - this.tabPage3.Controls.Add(this.tbSMSlowUpCnt); - this.tabPage3.Controls.Add(this.tbSMTimeDiffLimit); - this.tabPage3.Controls.Add(this.tbSMIgnorePrice); - this.tabPage3.Controls.Add(this.tbSMTimeSub); - this.tabPage3.Controls.Add(this.tbSMSlowSD); - this.tabPage3.Controls.Add(this.tbSMFastUpCnt); - this.tabPage3.Controls.Add(this.tbSMFastSD); - this.tabPage3.Controls.Add(this.tbSimulationLog); - this.tabPage3.Controls.Add(this.btSimulate); - this.tabPage3.Controls.Add(this.btLoad); - 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(1133, 636); - this.tabPage3.TabIndex = 2; - this.tabPage3.Text = "Simulation"; - this.tabPage3.UseVisualStyleBackColor = true; + this.tabPage4.Controls.Add(this.chSMHalfTrailing); + this.tabPage4.Controls.Add(this.tbSMSlowDownCnt); + this.tabPage4.Controls.Add(this.tbSMFastDownCnt); + this.tabPage4.Controls.Add(this.cbSMMethod); + this.tabPage4.Controls.Add(this.tbSMListSize); + this.tabPage4.Controls.Add(this.tbSMSlowUpCnt); + this.tabPage4.Controls.Add(this.tbSMTimeDiffLimit); + this.tabPage4.Controls.Add(this.tbSMIgnorePrice); + this.tabPage4.Controls.Add(this.tbSMTimeSub); + this.tabPage4.Controls.Add(this.tbSMSlowSD); + this.tabPage4.Controls.Add(this.tbSMFastUpCnt); + this.tabPage4.Controls.Add(this.tbSMFastSD); + this.tabPage4.Controls.Add(this.tbSimulationLog); + this.tabPage4.Controls.Add(this.btSimulate); + this.tabPage4.Controls.Add(this.btLoad); + this.tabPage4.Location = new System.Drawing.Point(4, 22); + this.tabPage4.Name = "tabPage4"; + this.tabPage4.Padding = new System.Windows.Forms.Padding(3); + this.tabPage4.Size = new System.Drawing.Size(1133, 636); + this.tabPage4.TabIndex = 2; + this.tabPage4.Text = "Simulation"; + this.tabPage4.UseVisualStyleBackColor = true; // // chSMHalfTrailing // this.chSMHalfTrailing.AutoSize = true; this.chSMHalfTrailing.Depth = 0; - this.chSMHalfTrailing.Font = new System.Drawing.Font("Roboto", 10F); + this.chSMHalfTrailing.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F); this.chSMHalfTrailing.Location = new System.Drawing.Point(516, 116); this.chSMHalfTrailing.Margin = new System.Windows.Forms.Padding(0); this.chSMHalfTrailing.MouseLocation = new System.Drawing.Point(-1, -1); @@ -1190,6 +1181,214 @@ this.btLoad.UseVisualStyleBackColor = true; this.btLoad.Click += new System.EventHandler(this.btLoad_Click); // + // columnHeader6 + // + this.columnHeader6.Text = "정산금액"; + // + // columnHeader7 + // + this.columnHeader7.Text = "수수료"; + // + // columnHeader8 + // + this.columnHeader8.Text = "거래세"; + // + // columnHeader9 + // + this.columnHeader9.Text = "농특세"; + // + // columnHeader10 + // + this.columnHeader10.Text = "날짜"; + // + // lvItems + // + this.lvItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chCode, + this.chCodeName, + this.chCurPrice, + this.chCount, + this.chBookValue, + this.chCapitalGains, + this.chAssessedValue, + this.chValuation, + this.chYield, + this.chMaxPrice, + this.chCheckCountLimit, + this.chCheckCount}); + this.lvItems.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvItems.FullRowSelect = true; + this.lvItems.GridLines = true; + this.lvItems.Location = new System.Drawing.Point(0, 0); + this.lvItems.Name = "lvItems"; + this.lvItems.Size = new System.Drawing.Size(859, 273); + this.lvItems.TabIndex = 0; + this.lvItems.UseCompatibleStateImageBehavior = false; + this.lvItems.View = System.Windows.Forms.View.Details; + this.lvItems.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvItems_ColumnClick); + this.lvItems.SelectedIndexChanged += new System.EventHandler(this.lvList_SelectedIndexChanged); + // + // chCode + // + this.chCode.Text = "코드"; + this.chCode.Width = 77; + // + // chCodeName + // + this.chCodeName.Text = "종목명"; + this.chCodeName.Width = 86; + // + // chCurPrice + // + this.chCurPrice.Text = "현재가"; + this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chCurPrice.Width = 71; + // + // chCount + // + this.chCount.Text = "잔고수량"; + this.chCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // chBookValue + // + this.chBookValue.Text = "장부가"; + this.chBookValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chBookValue.Width = 72; + // + // chCapitalGains + // + this.chCapitalGains.Text = "손익단가"; + this.chCapitalGains.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chCapitalGains.Width = 73; + // + // chAssessedValue + // + this.chAssessedValue.Text = "평가금액"; + this.chAssessedValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chAssessedValue.Width = 76; + // + // chValuation + // + this.chValuation.Text = "평가손익"; + this.chValuation.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chValuation.Width = 79; + // + // chYield + // + this.chYield.Text = "수익률"; + this.chYield.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chYield.Width = 79; + // + // chMaxPrice + // + this.chMaxPrice.Text = "최고가"; + this.chMaxPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // chCheckCountLimit + // + this.chCheckCountLimit.Text = "조건제한"; + this.chCheckCountLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // chCheckCount + // + this.chCheckCount.Text = "조건횟수"; + this.chCheckCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // lvNCItem + // + this.lvNCItem.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chNCOrderNo, + this.chNCOrgOrderNo, + 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(772, 138); + this.lvNCItem.TabIndex = 1; + this.lvNCItem.UseCompatibleStateImageBehavior = false; + this.lvNCItem.View = System.Windows.Forms.View.Details; + this.lvNCItem.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvNCItem_ColumnClick); + // + // chNCOrderNo + // + this.chNCOrderNo.Text = "주문번호"; + // + // chNCOrgOrderNo + // + this.chNCOrgOrderNo.Text = "원주문번호"; + this.chNCOrgOrderNo.Width = 91; + // + // chNCCode + // + this.chNCCode.Text = "코드"; + this.chNCCode.Width = 77; + // + // chNCCodeName + // + this.chNCCodeName.Text = "종목명"; + this.chNCCodeName.Width = 101; + // + // chNCType + // + this.chNCType.Text = "매매구분"; + this.chNCType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chNCType.Width = 106; + // + // 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[] { + this.columnHeader1, + this.chAskCount, + this.chCallPrice, + this.chBidCount}); + this.lvCurPrice.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvCurPrice.FullRowSelect = true; + this.lvCurPrice.GridLines = true; + this.lvCurPrice.Location = new System.Drawing.Point(0, 0); + this.lvCurPrice.Name = "lvCurPrice"; + this.lvCurPrice.Size = new System.Drawing.Size(264, 598); + this.lvCurPrice.TabIndex = 0; + this.lvCurPrice.UseCompatibleStateImageBehavior = false; + this.lvCurPrice.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Width = 10; + // + // chAskCount + // + this.chAskCount.Text = "매도잔량"; + this.chAskCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chAskCount.Width = 75; + // + // chCallPrice + // + this.chCallPrice.Text = "호가"; + this.chCallPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // chBidCount + // + this.chBidCount.Text = "매수잔량"; + this.chBidCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chBidCount.Width = 75; + // // AutoSeller // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); @@ -1215,10 +1414,16 @@ this.splitContainer3.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); this.splitContainer3.ResumeLayout(false); + this.splitContainer4.Panel1.ResumeLayout(false); + this.splitContainer4.Panel2.ResumeLayout(false); + this.splitContainer4.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).EndInit(); + this.splitContainer4.ResumeLayout(false); this.tabPage2.ResumeLayout(false); - this.tabPage2.PerformLayout(); this.tabPage3.ResumeLayout(false); this.tabPage3.PerformLayout(); + this.tabPage4.ResumeLayout(false); + this.tabPage4.PerformLayout(); this.ResumeLayout(false); } @@ -1227,7 +1432,7 @@ private MaterialSkin.Controls.MaterialTabSelector materialTabSelector1; private MaterialSkin.Controls.MaterialTabControl materialTabControl1; private System.Windows.Forms.TabPage tabPage1; - private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.SplitContainer splitContainer1; private ListViewNF lvItems; private System.Windows.Forms.ColumnHeader chCodeName; @@ -1264,7 +1469,7 @@ private MaterialSkin.Controls.MaterialSingleLineTextField tbTrailingP; private MaterialSkin.Controls.MaterialLabel materialLabel5; private MaterialSkin.Controls.MaterialLabel materialLabel4; - private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.TabPage tabPage4; private MaterialSkin.Controls.MaterialFlatButton btLoad; private MaterialSkin.Controls.MaterialFlatButton btSimulate; private System.Windows.Forms.RichTextBox tbSimulationLog; @@ -1312,5 +1517,23 @@ public MaterialSkin.Controls.MaterialCheckBox chSMHalfTrailing; private System.Windows.Forms.ColumnHeader chNCOrderNo; private System.Windows.Forms.CheckBox cbMockTrading; + private MaterialSkin.Controls.MaterialLabel lbSBCnt; + private MaterialSkin.Controls.MaterialLabel lbRQCnt; + private MaterialSkin.Controls.MaterialLabel lbTRCnt; + private MaterialSkin.Controls.MaterialRaisedButton btClearAll; + private System.Windows.Forms.SplitContainer splitContainer4; + private MaterialSkin.Controls.MaterialRaisedButton btUpdateNC; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.ListView lvConclusion; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private MaterialSkin.Controls.MaterialRaisedButton btUpdateConclusion; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.ColumnHeader columnHeader9; + private System.Windows.Forms.ColumnHeader columnHeader10; } } \ No newline at end of file diff --git a/AutoSeller.cs b/AutoSeller.cs index ae6aca8..7cb2276 100644 --- a/AutoSeller.cs +++ b/AutoSeller.cs @@ -2,6 +2,8 @@ using MaterialSkin.Controls; using Newtonsoft.Json.Linq; using System; +using System.Collections; +using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -33,6 +35,11 @@ namespace AutoSellerNS public long m_iProfitUnitPrice; public int m_iCurPrice; + + public override string ToString() + { + return $"[{m_strCodeName}:{m_strCode}] {m_iCurPrice}"; + } } public class NCITEM @@ -46,6 +53,11 @@ namespace AutoSellerNS public int m_iOrderNo; public int m_iOrgOrderNo; public DateTime m_Time; + + public override string ToString() + { + return $"[{m_strCodeName}:{m_strCode}] {m_iOrderNo}"; + } } @@ -56,8 +68,6 @@ namespace AutoSellerNS string m_strSelectedCode = ""; bool m_bSell = false; - SemaphoreSlim m_UpdateSemaphore = new SemaphoreSlim(1, 1); - SemaphoreSlim m_NCUpdateSemaphore = new SemaphoreSlim(1, 1); System.Timers.Timer m_Timer = new System.Timers.Timer(); public AutoSeller() @@ -71,7 +81,6 @@ namespace AutoSellerNS btUpdate.Enabled = false; btSell.Enabled = false; - for (int i = 0; i < 21; i++) { lvCurPrice.Items.Add(new ListViewItem(new string[] { "", "", "", "" })); @@ -125,16 +134,23 @@ namespace AutoSellerNS public void SetAccountList(string[] aAccountList) { - cbAccount.Items.Clear(); - cbAccount.Items.AddRange(aAccountList); - foreach (var account in aAccountList) - { - if (account == Config.GetAccount()) + Action update = new Action(delegate { + cbAccount.Items.Clear(); + cbAccount.Items.AddRange(aAccountList); + foreach (var account in aAccountList) { - cbAccount.SelectedItem = account; - break; + if (account == Config.GetAccount()) + { + cbAccount.SelectedItem = account; + break; + } } - } + }); + + if (cbAccount.InvokeRequired) + cbAccount.Invoke(update); + else + update(); } private void splitContainer2_SizeChanged(object sender, EventArgs e) @@ -153,8 +169,6 @@ namespace AutoSellerNS btUpdate.Enabled = true; btSell.Enabled = true; - - UpdateItem(); } void SyncItems(List OldItems, List NewItems) @@ -188,7 +202,13 @@ namespace AutoSellerNS void SyncListViewItems(List Items) { - lvItems.Items.Cast().ToList().RemoveAll(s => (Items.Any(t => t.m_strCode == s.SubItems[chCode.Index].Text) == false)); + foreach (ListViewItem item in lvItems.Items) + { + if (Items.Any(t => t.m_strCode == item.SubItems[chCode.Index].Text) == false) + item.Remove(); + } + + //lvItems.Items.Cast().ToList().RemoveAll(s => (Items.Any(t => t.m_strCode == s.SubItems[chCode.Index].Text) == false)); foreach(ITEM item in Items) { @@ -204,10 +224,10 @@ namespace AutoSellerNS } // update - CybosHelper.STOCK_CUR_ITEM ItemCur = m_CybosHelper.GetItem(item.m_strCode); + STOCK_CUR_ITEM ItemCur = m_CybosHelper.GetItem(item.m_strCode); row.SubItems[chCurPrice.Index].Text = string.Format("{0:n0}", item.m_iCurPrice); - row.SubItems[chCount.Index].Text = string.Format("{0:n0}", item.m_iAvailableQuantity); + row.SubItems[chCount.Index].Text = string.Format("{0:n0}", item.m_iItemCnt); row.SubItems[chBookValue.Index].Text = string.Format("{0:n2}", item.m_dBookUnitPrice); row.SubItems[chCapitalGains.Index].Text = string.Format("{0:n0}", item.m_iProfitUnitPrice); row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", item.m_iAssessedValue / 1000); @@ -222,13 +242,15 @@ namespace AutoSellerNS } } - public async void UpdateItem() + public void UpdateItem() + { + m_CybosHelper.UpdateItems(); + } + + public void UpdateItemCallback(List Items) { - await m_UpdateSemaphore.WaitAsync(); - List Items = await m_CybosHelper.UpdateItemsAsync(); SyncItems(m_Items, Items); SyncListViewItems(m_Items); - m_UpdateSemaphore.Release(); } void SyncNCItems(List oldList, List newList) @@ -246,8 +268,13 @@ namespace AutoSellerNS void SyncNCListVIewItems(List NCItems) { - lvNCItem.Items.Cast().ToList().RemoveAll(r => - NCItems.Any(t => (t.m_iOrgOrderNo.ToString() == r.SubItems[chNCOrgOrderNo.Index].Text) == false)); + foreach(ListViewItem item in lvNCItem.Items) + { + if (NCItems.Any(t => t.m_iOrgOrderNo.ToString() == item.SubItems[chNCOrgOrderNo.Index].Text) == false) + item.Remove(); + } + //lvNCItem.Items.Cast().ToList().RemoveAll(r => + // NCItems.Any(t => (t.m_iOrgOrderNo.ToString() == r.SubItems[chNCOrgOrderNo.Index].Text) == false)); foreach (var NCItem in NCItems) { @@ -273,30 +300,38 @@ namespace AutoSellerNS } } - public async void UpdateNCItem() + public void UpdateNCItem() { - await m_NCUpdateSemaphore.WaitAsync(); - List NCItems = await m_CybosHelper.UpdateNCAsync(); - SyncNCItems(m_NCItems, NCItems); - SyncNCListVIewItems(m_NCItems); - m_NCUpdateSemaphore.Release(); + m_CybosHelper.UpdateNC(); } - async void CorrectItems() + public void UpdateNCItemCallback(List NCItems) + { + SyncNCItems(m_NCItems, NCItems); + SyncNCListVIewItems(m_NCItems); + } + + async Task CorrectItems() { if (m_bSell == false) return; - var ClonedList = m_NCItems.ConvertAll(s => s); - foreach (var NCItem in ClonedList) + List cloned; + lock (m_NCItems) + cloned = m_NCItems.ConvertAll(s => s); + + foreach (var NCItem in cloned) { - if (NCItem.m_bAsk == true && DateTime.Now - NCItem.m_Time >= TimeSpan.FromSeconds(3)) + if (NCItem.m_bAsk == true && DateTime.Now - NCItem.m_Time >= TimeSpan.FromSeconds(5)) { var CurItem = m_CybosHelper.GetItem(NCItem.m_strCode); if (CurItem == null) continue; int iPrice = CurItem.m_aiBidPrice[0]; + if (iPrice == NCItem.m_iOrderPrice) + continue; + await m_CybosHelper.CorrectionItem(NCItem.m_strCode, NCItem.m_iOrderNo, NCItem.m_iRemainCnt, iPrice); NCItem.m_Time = DateTime.Now; Util.Log(Util.LOG_TYPE.SELL, string.Format("[{0}] 정정 주문 (주문번호: {1})", NCItem.m_strCodeName, NCItem.m_iOrgOrderNo)); @@ -304,9 +339,19 @@ namespace AutoSellerNS } } - private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + private async void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - CorrectItems(); + await CorrectItems(); + + lbRQCnt.Invoke(new Action(delegate { + lbRQCnt.Text = $"{m_CybosHelper.GetLimitRemainCountRQ(), 3}"; + })); + lbTRCnt.Invoke(new Action(delegate { + lbTRCnt.Text = $"{m_CybosHelper.GetLimitRemainCountTrade(), 3}"; + })); + lbSBCnt.Invoke(new Action(delegate { + lbSBCnt.Text = $"{m_CybosHelper.GetLimitRemainCountSB(), 3}"; + })); } private void btUpdate_Click(object sender, EventArgs e) @@ -495,7 +540,7 @@ namespace AutoSellerNS return; string strCode = lvItems.SelectedItems[0].SubItems[chCode.Index].Text; - CybosHelper.STOCK_CUR_ITEM Item = m_CybosHelper.GetItem(strCode); + STOCK_CUR_ITEM Item = m_CybosHelper.GetItem(strCode); if (Item == null) return; @@ -546,6 +591,42 @@ namespace AutoSellerNS Config.SetMockTrading(cbMockTrading.Checked); } + class ListViewItemComparer : IComparer + { + int m_iColumn = 0; + SortOrder m_Order = SortOrder.Descending; + + public ListViewItemComparer(int column, SortOrder Order) + { + m_iColumn = column; + m_Order = Order; + } + + public int Compare(object x, object y) + { + ListViewItem item1 = (ListViewItem)x; + ListViewItem item2 = (ListViewItem)y; + + double num1; + double num2; + if (double.TryParse(item1.SubItems[m_iColumn].Text, out num1) && + double.TryParse(item2.SubItems[m_iColumn].Text, out num2)) + { + if (m_Order == SortOrder.Ascending) + return (num1 > num2) ? 1 : -1; + else + return (num1 > num2) ? -1 : 1; + } + else + { + if (m_Order == SortOrder.Ascending) + return string.Compare(item1.SubItems[m_iColumn].Text, item2.SubItems[m_iColumn].Text); + else + return string.Compare(item2.SubItems[m_iColumn].Text, item1.SubItems[m_iColumn].Text); + } + } + } + #region Simulation private void btLoad_Click(object sender, EventArgs e) { @@ -558,7 +639,84 @@ namespace AutoSellerNS SimulationHelper helper = new SimulationHelper(this, m_CybosHelper, tbSimulationLog); helper.StartSimuation2(); } + + private void btUpdateNC_Click(object sender, EventArgs e) + { + UpdateNCItem(); + } #endregion + private void lvItems_ColumnClick(object sender, ColumnClickEventArgs e) + { + SortOrder Order = (lvItems.Sorting == SortOrder.Ascending || lvItems.Sorting == SortOrder.None) ? SortOrder.Descending : SortOrder.Ascending; + + lvItems.ListViewItemSorter = new ListViewItemComparer(e.Column, Order); + lvItems.Sorting = Order; + lvItems.Sort(); + } + + private void lvNCItem_ColumnClick(object sender, ColumnClickEventArgs e) + { + SortOrder Order = (lvNCItem.Sorting == SortOrder.Ascending || lvNCItem.Sorting == SortOrder.None) ? SortOrder.Descending : SortOrder.Ascending; + + lvNCItem.ListViewItemSorter = new ListViewItemComparer(e.Column, Order); + lvNCItem.Sorting = Order; + lvNCItem.Sort(); + } + + private async void btClearAll_Click(object sender, EventArgs e) + { + List cloned; + lock (m_Items) + cloned = m_Items.ConvertAll(s => s); + foreach(var item in cloned) + { + await m_CybosHelper.SellItem(item.m_strCode, item.m_iItemCnt); + } + } + + private void btUpdateConclusion_Click(object sender, EventArgs e) + { + m_CybosHelper.GetConclusion(); + } + + public void UpdateConclusionCallback(List data) + { + List items = new List(); + string lastItemCode = ""; + foreach(var conclusion in data) + { + bool bSameItem = (conclusion.strCode == lastItemCode); + + var listItem = new ListViewItem(new string[] { + bSameItem ? "" : conclusion.strCode, + bSameItem ? "" : conclusion.strCodeName, + conclusion.strSellBuy, + conclusion.iCommitedAmount.ToString("n0"), + conclusion.iSettlementAmount.ToString("n0"), + conclusion.iFee.ToString("n0"), + conclusion.iTransactionTax.ToString("n0"), + conclusion.iSpecialTax.ToString("n0"), + conclusion.strDate + }); + + if (conclusion.strSellBuy == "매수") + listItem.SubItems[2].ForeColor = Color.Red; + else + listItem.SubItems[2].ForeColor = Color.Blue; + listItem.UseItemStyleForSubItems = false; + + items.Add(listItem); + } + + lvConclusion.Invoke(new Action(() => { + lvConclusion.BeginUpdate(); + lvConclusion.Items.Clear(); + lvConclusion.Items.AddRange(items.ToArray()); + foreach (ColumnHeader col in lvConclusion.Columns) + col.Width = -2; + lvConclusion.EndUpdate(); + })); + } } } diff --git a/AutoSeller.csproj b/AutoSeller.csproj index a8b1e07..11240db 100644 --- a/AutoSeller.csproj +++ b/AutoSeller.csproj @@ -95,6 +95,7 @@ + Form @@ -137,6 +138,7 @@ + AutoSeller.cs diff --git a/CurrentItem.cs b/CurrentItem.cs new file mode 100644 index 0000000..d41d003 --- /dev/null +++ b/CurrentItem.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AutoSellerNS +{ + public class PriceNode + { + public int m_iTime; + public int m_iPrice; + public int m_iAskPrice; + public int m_iBidPrice; + public int m_iAccDealCnt; + public int m_iDealCnt; + public double m_dAvg; + public double m_dSD; + public double m_dSellLimit; + public int m_iSellCnt; + + public override string ToString() + { + return $"{m_iPrice}({m_dAvg})"; + } + } + + public class STOCK_CUR_ITEM + { + public AutoSeller m_Listener = null; + public CybosHelper m_CybosHelper = null; + public string m_strCode; + public string m_strCodeName; + public DSCBO1Lib.StockCur m_StockCur = null; + public DSCBO1Lib.StockJpbid m_Jpbid = null; + public int[] m_aiBidPrice = new int[10]; + public int[] m_aiBidCount = new int[10]; + public int[] m_aiAskPrice = new int[10]; + public int[] m_aiAskCount = new int[10]; + + public int m_iOpenigPrice = 0; + public int m_iCurPrice = 0; + public int m_iMaxPrice = 0; + public int m_iCheckCount = 0; + + public int m_iTrailingCount = 0; + + // real time, price time, price + public List m_PriceList = new List(); + public double m_dCheckCountLimit = Config.GetBidCount(); + + int m_iPrevTime = 0; + + public async void OnRecievedPrice() + { + bool bOpeningHour = (m_StockCur.GetHeaderValue(19) == '2'); + m_iCurPrice = m_StockCur.GetHeaderValue(13); + if (m_iOpenigPrice == 0) + m_iOpenigPrice = m_iCurPrice; + int iTime = m_StockCur.GetHeaderValue(18); + int iConclusionCnt = m_StockCur.GetHeaderValue(17); + int iAccDealCnt = m_StockCur.GetHeaderValue(9); + int iDealCnt = m_StockCur.GetHeaderValue(17); + + int iTimeDiff = 0; + if (m_iPrevTime > 0) + iTimeDiff = ((iTime / 10000) * 60 * 60 + ((iTime % 10000) / 100) * 60 + (iTime % 100)) - ((m_iPrevTime / 10000) * 60 * 60 + ((m_iPrevTime % 10000) / 100) * 60 + (m_iPrevTime % 100)); + + if (bOpeningHour == true) + { + DateTime RealTime = DateTime.Now; + int iRealTime = RealTime.Hour * 10000 + RealTime.Minute * 100 + RealTime.Second; + + List lastNPrice = null; + lock (m_PriceList) + { + if (Config.GetListSize() == 0) + lastNPrice = m_PriceList.Select(s => s.m_iPrice).ToList(); + else + lastNPrice = m_PriceList.Skip(Math.Max(0, m_PriceList.Count - (Config.GetListSize() - 1))).Select(s => s.m_iPrice).ToList(); + + lastNPrice.Add(m_iCurPrice); + } + + double dAverage = lastNPrice.Average(); + double sumOfSquaresOfDifferences = lastNPrice.Select(val => Math.Pow((val - dAverage) / m_CybosHelper.GetUnitValue(val), 2)).Sum(); + double dStdDev = Math.Sqrt(sumOfSquaresOfDifferences / lastNPrice.Count); + if (dStdDev >= Config.GetFastSD()) + { + if (m_iCurPrice >= dAverage) + m_dCheckCountLimit += Config.GetFastUp(); + else + m_dCheckCountLimit -= Config.GetFastDown(); + } + else if (dStdDev <= Config.GetSlowSD()) + { + if (m_iCurPrice >= dAverage) + m_dCheckCountLimit += Config.GetSlowUp(); + else + m_dCheckCountLimit -= Config.GetSlowDown(); + } + + m_dCheckCountLimit -= iTimeDiff * Config.GetTimeDown(); + + + if (m_iCurPrice > m_iMaxPrice) + m_iTrailingCount = 0; + + m_iMaxPrice = Math.Max(m_iCurPrice, m_iMaxPrice); + + int iAskPrice = m_StockCur.GetHeaderValue(7); + int iBidPrice = m_StockCur.GetHeaderValue(8); + + if (m_iCurPrice * iConclusionCnt > Config.GetIgnorePrice()) + { + if (m_iCurPrice <= iBidPrice) + m_iCheckCount++; + else + m_iCheckCount = 0; + } + + if (m_iCheckCount >= m_dCheckCountLimit && m_Listener.IsSelling() == true) + { + await 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)); + } + + if (m_iCurPrice < (m_iMaxPrice * (100.0f - Config.GetTrailingRate()) / 100.0f)) + m_iTrailingCount++; + if (m_iTrailingCount >= Config.GetTrailingCnt() && m_Listener.IsSelling() == true) + { + await m_CybosHelper.SellItem(m_strCode, m_Listener.GetSellableCount(m_strCode), m_aiAskPrice[0]); + Util.Log(Util.LOG_TYPE.SELL, string.Format("[트레일링 매도] {0} ({1}% {2}회) (현재가 {3:n0}원, 최고가 {4:n0}원)", + m_strCodeName, + Config.GetTrailingRate(), + Config.GetTrailingCnt(), + m_iCurPrice, + m_iMaxPrice)); + } + + if (iTimeDiff >= Config.GetTimeLimit() && m_Listener.IsSelling() == true) + { + await 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, + iTimeDiff, + m_iCurPrice, + m_iMaxPrice)); + } + + lock (m_PriceList) + { + m_PriceList.Add(new PriceNode + { + m_iTime = iTime, + m_iPrice = m_iCurPrice, + m_iAskPrice = iAskPrice, + m_iBidPrice = iBidPrice, + m_iAccDealCnt = iAccDealCnt, + m_iDealCnt = iDealCnt, + m_dAvg = dAverage, + m_dSD = dStdDev, + m_dSellLimit = m_dCheckCountLimit, + m_iSellCnt = m_iCheckCount, + }); + } + } + + m_Listener.OnReceivedCurPrice(m_strCode, m_iCurPrice, m_iMaxPrice, m_dCheckCountLimit, m_iCheckCount, bOpeningHour); + m_iPrevTime = iTime; + } + + public void OnReceivedCall() + { + for (int i = 0; i < 5; i++) + { + m_aiBidPrice[i] = m_Jpbid.GetHeaderValue(4 + 4 * i); + m_aiBidCount[i] = m_Jpbid.GetHeaderValue(6 + 4 * i); + m_aiAskPrice[i] = m_Jpbid.GetHeaderValue(3 + 4 * i); + m_aiAskCount[i] = m_Jpbid.GetHeaderValue(5 + 4 * i); + } + + for (int i = 0; i < 5; i++) + { + m_aiBidPrice[i + 5] = m_Jpbid.GetHeaderValue(28 + 4 * i); + m_aiBidCount[i + 5] = m_Jpbid.GetHeaderValue(30 + 4 * i); + m_aiAskPrice[i + 5] = m_Jpbid.GetHeaderValue(27 + 4 * i); + m_aiAskCount[i + 5] = m_Jpbid.GetHeaderValue(29 + 4 * i); + } + + m_Listener.OnReceivedCall(m_strCode, 0, m_aiBidPrice, m_aiBidCount, m_aiAskPrice, m_aiAskCount); + } + + public override string ToString() + { + return $"[{m_strCodeName}:{m_strCode}] {m_iCurPrice}"; + } + } +} diff --git a/CybosHelper.cs b/CybosHelper.cs index 248380d..18dc2d8 100644 --- a/CybosHelper.cs +++ b/CybosHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -10,199 +11,29 @@ namespace AutoSellerNS { public class CybosHelper { - public class PriceNode - { - public int m_iTime; - public int m_iPrice; - public int m_iAskPrice; - public int m_iBidPrice; - public int m_iAccDealCnt; - public int m_iDealCnt; - public double m_dAvg; - public double m_dSD; - public double m_dSellLimit; - public int m_iSellCnt; - } - - public class STOCK_CUR_ITEM - { - - public AutoSeller m_Listener = null; - public CybosHelper m_CybosHelper = null; - public string m_strCode; - public string m_strCodeName; - public DSCBO1Lib.StockCur m_StockCur = null; - public DSCBO1Lib.StockJpbid m_Jpbid = null; - public int[] m_aiBidPrice = new int[10]; - public int[] m_aiBidCount = new int[10]; - public int[] m_aiAskPrice = new int[10]; - public int[] m_aiAskCount = new int[10]; - - public int m_iOpenigPrice = 0; - public int m_iCurPrice = 0; - public int m_iMaxPrice = 0; - public int m_iCheckCount = 0; - - public int m_iTrailingCount = 0; - - // real time, price time, price - public List m_PriceList = new List(); - public double m_dCheckCountLimit = Config.GetBidCount(); - - int m_iPrevTime = 0; - - public async void OnRecievedPrice() - { - bool bOpeningHour = (m_StockCur.GetHeaderValue(19) == '2'); - m_iCurPrice = m_StockCur.GetHeaderValue(13); - if (m_iOpenigPrice == 0) - m_iOpenigPrice = m_iCurPrice; - int iTime = m_StockCur.GetHeaderValue(18); - int iConclusionCnt = m_StockCur.GetHeaderValue(17); - int iAccDealCnt = m_StockCur.GetHeaderValue(9); - int iDealCnt = m_StockCur.GetHeaderValue(17); - - int iTimeDiff = 0; - if(m_iPrevTime > 0) - iTimeDiff = ((iTime/10000)*60*60 + ((iTime%10000)/100)*60 + (iTime%100)) - ((m_iPrevTime/10000)*60*60 + ((m_iPrevTime%10000)/100)*60 + (m_iPrevTime%100)); - - if(bOpeningHour == true) - { - DateTime RealTime = DateTime.Now; - int iRealTime = RealTime.Hour * 10000 + RealTime.Minute * 100 + RealTime.Second; - - List lastNPrice = null; - if (Config.GetListSize() == 0) - lastNPrice = m_PriceList.Select(s => s.m_iPrice).ToList(); - else - lastNPrice = m_PriceList.Skip(Math.Max(0, m_PriceList.Count - (Config.GetListSize()-1))).Select(s => s.m_iPrice).ToList(); - lastNPrice.Add(m_iCurPrice); - - double dAverage = lastNPrice.Average(); - double sumOfSquaresOfDifferences = lastNPrice.Select(val => Math.Pow((val - dAverage)/m_CybosHelper.GetUnitValue(val), 2)).Sum(); - double dStdDev = Math.Sqrt(sumOfSquaresOfDifferences / lastNPrice.Count); - if(dStdDev >= Config.GetFastSD()) - { - if(m_iCurPrice >= dAverage) - m_dCheckCountLimit += Config.GetFastUp(); - else - m_dCheckCountLimit -= Config.GetFastDown(); - } - else if(dStdDev <= Config.GetSlowSD()) - { - if(m_iCurPrice >= dAverage) - m_dCheckCountLimit += Config.GetSlowUp(); - else - m_dCheckCountLimit -= Config.GetSlowDown(); - } - - m_dCheckCountLimit -= iTimeDiff*Config.GetTimeDown(); - - - if(m_iCurPrice > m_iMaxPrice) - m_iTrailingCount = 0; - - m_iMaxPrice = Math.Max(m_iCurPrice, m_iMaxPrice); - - int iAskPrice = m_StockCur.GetHeaderValue(7); - int iBidPrice = m_StockCur.GetHeaderValue(8); - - if(m_iCurPrice*iConclusionCnt > Config.GetIgnorePrice()) - { - if(m_iCurPrice <= iBidPrice) - m_iCheckCount++; - else - m_iCheckCount = 0; - } - - if(m_iCheckCount >= m_dCheckCountLimit && m_Listener.IsSelling() == true) - { - await 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)); - } - - if(m_iCurPrice < (m_iMaxPrice*(100.0f-Config.GetTrailingRate())/100.0f)) - m_iTrailingCount++; - if(m_iTrailingCount >= Config.GetTrailingCnt() && m_Listener.IsSelling() == true) - { - await m_CybosHelper.SellItem(m_strCode, m_Listener.GetSellableCount(m_strCode), m_aiAskPrice[0]); - Util.Log(Util.LOG_TYPE.SELL, string.Format("[트레일링 매도] {0} ({1}% {2}회) (현재가 {3:n0}원, 최고가 {4:n0}원)", - m_strCodeName, - Config.GetTrailingRate(), - Config.GetTrailingCnt(), - m_iCurPrice, - m_iMaxPrice)); - } - - if(iTimeDiff >= Config.GetTimeLimit() && m_Listener.IsSelling() == true) - { - await 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, - iTimeDiff, - m_iCurPrice, - m_iMaxPrice)); - } - - - m_PriceList.Add(new PriceNode { - m_iTime = iTime, - m_iPrice = m_iCurPrice, - m_iAskPrice = iAskPrice, - m_iBidPrice = iBidPrice, - m_iAccDealCnt = iAccDealCnt, - m_iDealCnt = iDealCnt, - m_dAvg = dAverage, - m_dSD = dStdDev, - m_dSellLimit = m_dCheckCountLimit, - m_iSellCnt = m_iCheckCount, - }); - } - - m_Listener.OnReceivedCurPrice(m_strCode, m_iCurPrice, m_iMaxPrice, m_dCheckCountLimit, m_iCheckCount, bOpeningHour); - m_iPrevTime = iTime; - } - - public void OnReceivedCall() - { - for(int i=0; i<5; i++) - { - m_aiBidPrice[i] = m_Jpbid.GetHeaderValue(4 + 4*i); - m_aiBidCount[i] = m_Jpbid.GetHeaderValue(6 + 4*i); - m_aiAskPrice[i] = m_Jpbid.GetHeaderValue(3 + 4*i); - m_aiAskCount[i] = m_Jpbid.GetHeaderValue(5 + 4*i); - } - - for (int i = 0; i < 5; i++) - { - m_aiBidPrice[i+5] = m_Jpbid.GetHeaderValue(28 + 4*i); - m_aiBidCount[i+5] = m_Jpbid.GetHeaderValue(30 + 4*i); - m_aiAskPrice[i+5] = m_Jpbid.GetHeaderValue(27 + 4*i); - m_aiAskCount[i+5] = m_Jpbid.GetHeaderValue(29 + 4*i); - } - - m_Listener.OnReceivedCall(m_strCode, 0, m_aiBidPrice, m_aiBidCount, m_aiAskPrice, m_aiAskCount); - } - } - AutoSeller m_Listener = null; CPUTILLib.CpCybos m_CPCybos = new CPUTILLib.CpCybos(); CPFORETRADELib.CpForeTdUtil m_CPUtil = new CPFORETRADELib.CpForeTdUtil(); DSCBO1Lib.CpConclusion m_CpConclusion = new DSCBO1Lib.CpConclusion(); - CPTRADELib.CpTd6033 m_6033 = new CPTRADELib.CpTd6033(); Dictionary m_aStockCur = new Dictionary(); - object m_NCItemLock = new object(); + object m_RequestRQLock = new object(); + object m_RequestTRLock = new object(); + + CPTRADELib.CpTd6033 m_CP6033 = new CPTRADELib.CpTd6033(); + CPTRADELib.CpTd5339 m_CP5339 = new CPTRADELib.CpTd5339(); + CPTRADELib.CpTd5342 m_CP5342 = new CPTRADELib.CpTd5342(); + + ConcurrentDictionary m_SellingCode = new ConcurrentDictionary(); + ConcurrentDictionary m_ItemsInCorrection = new ConcurrentDictionary(); public CybosHelper(AutoSeller Listener) { m_Listener = Listener; + m_CP6033.Received += CP6033_Received; + m_CP5339.Received += CP5339_Received; } public void InitCybos() @@ -215,7 +46,7 @@ namespace AutoSellerNS break; case 0: - Util.Log(Util.LOG_TYPE.VERVOSE, "[TradeInit] 로그인 되었습니다"); + Util.Log(Util.LOG_TYPE.VERBOSE, "[TradeInit] 로그인 되었습니다"); break; case 1: @@ -253,48 +84,118 @@ namespace AutoSellerNS string strFilePath = Util.GetLogPath() + "/price-" + strToday + item.m_strCodeName + ".csv"; string strMessage = "시간, 동시호가, 현재가, 매도호가, 매수호가, 거래량, 순간체결량, 평균, 표준편차, 매도 제한, 매도 수, 시가 대비"; File.AppendAllText(strFilePath, strMessage + Environment.NewLine, new UTF8Encoding(true)); - foreach (var node in item.m_PriceList) + lock(item.m_PriceList) { - strMessage = string.Format("{0}:{1}:{2}, , {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12:0.00}", - node.m_iTime/10000, (node.m_iTime/100)%100, node.m_iTime%100, - node.m_iPrice, node.m_iAskPrice, node.m_iBidPrice, - node.m_iAccDealCnt, node.m_iDealCnt, - node.m_dAvg, node.m_dSD, node.m_dSellLimit, node.m_iSellCnt, (node.m_iPrice-item.m_PriceList[0].m_iPrice)*100/(double)item.m_PriceList[0].m_iPrice); - File.AppendAllText(strFilePath, strMessage + Environment.NewLine, new UTF8Encoding(true)); + foreach (var node in item.m_PriceList) + { + strMessage = string.Format("{0}:{1}:{2}, , {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12:0.00}", + node.m_iTime / 10000, (node.m_iTime / 100) % 100, node.m_iTime % 100, + node.m_iPrice, node.m_iAskPrice, node.m_iBidPrice, + node.m_iAccDealCnt, node.m_iDealCnt, + node.m_dAvg, node.m_dSD, node.m_dSellLimit, node.m_iSellCnt, (node.m_iPrice - item.m_PriceList[0].m_iPrice) * 100 / (double)item.m_PriceList[0].m_iPrice); + File.AppendAllText(strFilePath, strMessage + Environment.NewLine, new UTF8Encoding(true)); + } } } - public List UpdateItems() + int iDibWaitCnt = 0; + void BlockRequest(DSCBO1Lib.IDib dib) + { + //lock (m_RequestRQLock) + { + while (GetLimitRemainCountRQ() < 2) + { + iDibWaitCnt++; + Thread.Sleep(500); + iDibWaitCnt--; + } + + var ret = dib.BlockRequest2(0); + if (ret == -1) + Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest RQ 오류"); + else if (ret == 1) + Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest RQ 수신대기"); + } + } + + int iTdDibWaitCnt = 0; + ConcurrentQueue m_TRQueue = new ConcurrentQueue(); + void BlockRequest(CPTRADELib.ICpTdDib dib) + { + m_TRQueue.Enqueue(dib); + + CPTRADELib.ICpTdDib tr; + bool bContinue = true; + while(bContinue == true && m_TRQueue.TryDequeue(out tr) == true) + { + var ret = tr.BlockRequest2(0); + if (ret == -1) + Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 오류"); + else if (ret == 1) + Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 수신대기"); + bContinue = (ret == 0); + } + + ////lock (m_RequestTRLock) + //{ + // while (GetLimitRemainCountTrade() < 2) + // { + // iTdDibWaitCnt++; + // Thread.Sleep(500); + // iTdDibWaitCnt--; + // } + + // var ret = dib.BlockRequest2(0); + // if (ret == -1) + // Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 오류"); + // else if (ret == 1) + // Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 수신대기"); + //} + } + + + public void UpdateItems() + { + if (Config.GetAccount() == "") + return; + + m_CP6033.SetInputValue(0, Config.GetAccount()); + m_CP6033.SetInputValue(1, Config.GetSubAccount()); + m_CP6033.SetInputValue(2, 50); + + string Msg1 = m_CP6033.GetDibMsg1(); + string Msg2 = m_CP6033.GetDibMsg2(); + int iStatus = m_CP6033.GetDibStatus(); + if (iStatus == 1) + return; + + m_CP6033.Request(); + } + + private void CP6033_Received() { List aItems = new List(); - if (Config.GetAccount() == "") - return aItems; - - m_6033.SetInputValue(0, Config.GetAccount()); - m_6033.SetInputValue(1, Config.GetSubAccount()); - m_6033.BlockRequest2(0); - string strCodeList = ""; bool bContinue = true; while (bContinue == true) { - int iCount = m_6033.GetHeaderValue(7); + int iCount = m_CP6033.GetHeaderValue(7); for (int i = 0; i < iCount; i++) { AutoSeller.ITEM Item = new AutoSeller.ITEM(); - Item.m_strCodeName = m_6033.GetDataValue(0, i); + Item.m_strCodeName = m_CP6033.GetDataValue(0, i); if (Item.m_strCodeName != "") { - Item.m_strCode = m_6033.GetDataValue(12, i); - Item.m_iItemCnt = m_6033.GetDataValue(7, i); - Item.m_iAssessedValue = m_6033.GetDataValue(9, i) / 1000; - Item.m_iValuationGains = m_6033.GetDataValue(10, i) / 1000; - Item.m_dYield = m_6033.GetDataValue(11, i); - Item.m_iAvailableQuantity = m_6033.GetDataValue(15, i); - Item.m_dBookUnitPrice = m_6033.GetDataValue(17, i); - Item.m_iProfitUnitPrice = m_6033.GetDataValue(18, i); + Item.m_strCode = m_CP6033.GetDataValue(12, i); + Item.m_iItemCnt = m_CP6033.GetDataValue(7, i); + Item.m_iAssessedValue = m_CP6033.GetDataValue(9, i) / 1000; + Item.m_iValuationGains = m_CP6033.GetDataValue(10, i) / 1000; + Item.m_dYield = m_CP6033.GetDataValue(11, i); + Item.m_iAvailableQuantity = m_CP6033.GetDataValue(15, i); + Item.m_dBookUnitPrice = m_CP6033.GetDataValue(17, i); + Item.m_iProfitUnitPrice = m_CP6033.GetDataValue(18, i); if (strCodeList.Length > 0) strCodeList += ","; @@ -304,17 +205,17 @@ namespace AutoSellerNS } } - bContinue = (m_6033.Continue != 0); + bContinue = (m_CP6033.Continue != 0); bContinue = false; if (bContinue == true) - m_6033.BlockRequest2(0); + BlockRequest(m_CP6033); } if (strCodeList.Length > 0) { DSCBO1Lib.StockMst2 StockMst = new DSCBO1Lib.StockMst2(); StockMst.SetInputValue(0, strCodeList); - StockMst.BlockRequest2(0); + BlockRequest(StockMst); int iCnt = StockMst.GetHeaderValue(0); for (int i = 0; i < iCnt; i++) { @@ -328,78 +229,75 @@ namespace AutoSellerNS // sync List aRemoveKeys = new List(); - foreach (var Item in m_aStockCur) + lock (m_aStockCur) { - if (aItems.Any(s => s.m_strCode == Item.Key) == false) - aRemoveKeys.Add(Item.Key); + foreach (var Item in m_aStockCur) + { + if (aItems.Any(s => s.m_strCode == Item.Key) == false) + { + lock (m_aStockCur[Item.Key]) + { + m_aStockCur[Item.Key].m_StockCur.Unsubscribe(); + m_aStockCur[Item.Key].m_Jpbid.Unsubscribe(); + SavePrice(m_aStockCur[Item.Key]); + aRemoveKeys.Add(Item.Key); + } + } + } + + foreach (var key in aRemoveKeys) + m_aStockCur.Remove(key); } - foreach (var Key in aRemoveKeys) - { - m_aStockCur[Key].m_StockCur.Unsubscribe(); - m_aStockCur[Key].m_Jpbid.Unsubscribe(); - SavePrice(m_aStockCur[Key]); - m_aStockCur.Remove(Key); - } - - return aItems; + m_Listener.UpdateItemCallback(aItems); } - public async Task> UpdateItemsAsync() + public void UpdateNC() { - return await Task>.Run(() => - { - return UpdateItems(); - }); + m_CP5339.SetInputValue(0, Config.GetAccount()); + m_CP5339.SetInputValue(1, Config.GetSubAccount()); + + string Msg1 = m_CP5339.GetDibMsg1(); + string Msg2 = m_CP5339.GetDibMsg2(); + int iStatus = m_CP5339.GetDibStatus(); + if (iStatus == 1) + return; + + m_CP5339.Request(); } - public List UpdateNC() + private void CP5339_Received() { - while(GetLimitRemainCountTrade() < 1) - Thread.Sleep(500); - 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) + while (bContinue) { - int iCnt = CP5339.GetHeaderValue(5); - for(int i = 0; i> UpdateNCAsync() - { - return await Task>.Run(() => { - return UpdateNC(); - }); + m_Listener.UpdateNCItemCallback(NCItems); } private void CpConclusion_Received() @@ -433,15 +331,15 @@ namespace AutoSellerNS case 1: // 체결 m_Listener.UpdateItem(); m_Listener.UpdateNCItem(); - Util.Log(bBid?Util.LOG_TYPE.BUY:Util.LOG_TYPE.SELL, string.Format("{0}:{1} {2} 체결 ({3:n0}원 {4}주) - {5}", strCodeName, strCode, strBidOrAsk, iPrice, iConclusionCnt, strOrderCondition)); + Util.Log(bBid?Util.LOG_TYPE.BUY_CONCLUSION:Util.LOG_TYPE.SELL_CONCLUSION, string.Format("{0}:{1} {2} 체결 ({3:n0}원 {4}주) - {5}", strCodeName, strCode, strBidOrAsk, iPrice, iConclusionCnt, strOrderCondition)); break; case 2: // 확인 - Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("{0}:{1} {2} 확인 - {3} ({4}:{5})", strCodeName, strCode, strBidOrAsk, strOrderCondition, iOrderNumber, iOrgOrderNumber)); + Util.Log(Util.LOG_TYPE.VERBOSE, string.Format("{0}:{1} {2} 확인 - {3} ({4}:{5})", strCodeName, strCode, strBidOrAsk, strOrderCondition, iOrderNumber, iOrgOrderNumber)); break; case 3: // 거부 - Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("{0}:{1} {2} 거부", strCodeName, strCode, strBidOrAsk)); + Util.Log(Util.LOG_TYPE.VERBOSE, string.Format("{0}:{1} {2} 거부", strCodeName, strCode, strBidOrAsk)); break; case 4: // 접수 @@ -451,12 +349,15 @@ namespace AutoSellerNS { if(m_aStockCur.ContainsKey(strCode) == true) { - var priceList = m_aStockCur[strCode].m_PriceList; - List> PriceDealCntList = new List>(); - for (int i = 0; i < Math.Min(5, priceList.Count); i++) - PriceDealCntList.Add(new Tuple(priceList[i].m_iPrice, priceList[i].m_iDealCnt)); + lock(m_aStockCur[strCode].m_PriceList) + { + var priceList = m_aStockCur[strCode].m_PriceList; + List> PriceDealCntList = new List>(); + for (int i = 0; i < Math.Min(5, priceList.Count); i++) + PriceDealCntList.Add(new Tuple(priceList[i].m_iPrice, priceList[i].m_iDealCnt)); - SimulationHelper.InsertSimulationLog(strCode, strCodeName, PriceDealCntList); + SimulationHelper.InsertSimulationLog(strCode, strCodeName, PriceDealCntList); + } } } @@ -496,34 +397,37 @@ namespace AutoSellerNS { if(m_aStockCur.Any(s => s.Key == Item.m_strCode) == false) { - STOCK_CUR_ITEM StockCur = new STOCK_CUR_ITEM(); - StockCur.m_Listener = m_Listener; - StockCur.m_CybosHelper = this; - StockCur.m_strCode = Item.m_strCode; - StockCur.m_strCodeName = Item.m_strCodeName; - - DSCBO1Lib.StockJpbid2 JpBid = new DSCBO1Lib.StockJpbid2(); - JpBid.SetInputValue(0, Item.m_strCode); - JpBid.BlockRequest2(0); - for(int i=0; i<10; i++) + lock (m_aStockCur) { - StockCur.m_aiAskPrice[i] = JpBid.GetDataValue(0, i); - StockCur.m_aiAskCount[i] = JpBid.GetDataValue(2, i); - StockCur.m_aiBidPrice[i] = JpBid.GetDataValue(1, i); - StockCur.m_aiBidCount[i] = JpBid.GetDataValue(3, i); - } + STOCK_CUR_ITEM StockCur = new STOCK_CUR_ITEM(); + StockCur.m_Listener = m_Listener; + StockCur.m_CybosHelper = this; + StockCur.m_strCode = Item.m_strCode; + StockCur.m_strCodeName = Item.m_strCodeName; - StockCur.m_StockCur = new DSCBO1Lib.StockCur(); - StockCur.m_StockCur.SetInputValue(0, Item.m_strCode); - StockCur.m_StockCur.Received += StockCur.OnRecievedPrice; - StockCur.m_StockCur.Subscribe(); - StockCur.m_Jpbid = new DSCBO1Lib.StockJpbid(); - StockCur.m_Jpbid.SetInputValue(0, Item.m_strCode); - StockCur.m_Jpbid.Received += StockCur.OnReceivedCall; - StockCur.m_Jpbid.SubscribeLatest(); - StockCur.m_iCurPrice = Item.m_iCurPrice; - StockCur.m_iMaxPrice = Item.m_iCurPrice; - m_aStockCur.Add(Item.m_strCode, StockCur); + DSCBO1Lib.StockJpbid2 JpBid = new DSCBO1Lib.StockJpbid2(); + JpBid.SetInputValue(0, Item.m_strCode); + BlockRequest(JpBid); + for (int i = 0; i < 10; i++) + { + StockCur.m_aiAskPrice[i] = JpBid.GetDataValue(0, i); + StockCur.m_aiAskCount[i] = JpBid.GetDataValue(2, i); + StockCur.m_aiBidPrice[i] = JpBid.GetDataValue(1, i); + StockCur.m_aiBidCount[i] = JpBid.GetDataValue(3, i); + } + + StockCur.m_StockCur = new DSCBO1Lib.StockCur(); + StockCur.m_StockCur.SetInputValue(0, Item.m_strCode); + StockCur.m_StockCur.Received += StockCur.OnRecievedPrice; + StockCur.m_StockCur.Subscribe(); + StockCur.m_Jpbid = new DSCBO1Lib.StockJpbid(); + StockCur.m_Jpbid.SetInputValue(0, Item.m_strCode); + StockCur.m_Jpbid.Received += StockCur.OnReceivedCall; + StockCur.m_Jpbid.SubscribeLatest(); + StockCur.m_iCurPrice = Item.m_iCurPrice; + StockCur.m_iMaxPrice = Item.m_iCurPrice; + m_aStockCur.Add(Item.m_strCode, StockCur); + } } } @@ -556,6 +460,11 @@ namespace AutoSellerNS public async Task SellItem(string strCode, int iCnt, int iAskPrice) { + if (iCnt <= 0 || m_SellingCode.ContainsKey(strCode) == true) + return; + + m_SellingCode.TryAdd(strCode, iAskPrice); + await Task.Run(() => { int iSellPrice = iAskPrice - GetUnitValue(iAskPrice); @@ -568,7 +477,28 @@ namespace AutoSellerNS Td0311.SetInputValue(4, iCnt); Td0311.SetInputValue(5, iSellPrice); Td0311.SetInputValue(8, "01"); - Td0311.BlockRequest2(1); + BlockRequest(Td0311); + + int val; + m_SellingCode.TryRemove(strCode, out val); + }); + } + + public async Task SellItem(string strCode, int iCnt) + { + if (iCnt <= 0) + return; + + await Task.Run(() => + { + CPTRADELib.CpTd0311 Td0311 = new CPTRADELib.CpTd0311(); + Td0311.SetInputValue(0, "1"); + Td0311.SetInputValue(1, Config.GetAccount()); + Td0311.SetInputValue(2, Config.GetSubAccount()); + Td0311.SetInputValue(3, strCode); + Td0311.SetInputValue(4, iCnt); + Td0311.SetInputValue(8, "03"); + BlockRequest(Td0311); }); } @@ -582,32 +512,115 @@ namespace AutoSellerNS Td0314.SetInputValue(3, Config.GetSubAccount()); Td0314.SetInputValue(4, strCode); Td0314.SetInputValue(5, 0); - Td0314.BlockRequest2(1); + BlockRequest(Td0314); }); } public async Task CorrectionItem(string strCode, int iOrgOrderNo, int iCnt, int iAskPrice) { - if(Config.GetMockTrading() == true) - { - await CancelItem(strCode, iOrgOrderNo); - await SellItem(strCode, iCnt, iAskPrice); + if (m_ItemsInCorrection.ContainsKey(iOrgOrderNo) == true) return; - } - await Task.Run(() => + m_ItemsInCorrection.TryAdd(iOrgOrderNo, strCode); + + if (Config.GetMockTrading() == true) { - int iSellPrice = iAskPrice; + await Task.Run(() => + { + CancelItem(strCode, iOrgOrderNo).Wait(); + SellItem(strCode, iCnt, iAskPrice).Wait(); - CPTRADELib.CpTd0313 Td0313 = new CPTRADELib.CpTd0313(); - Td0313.SetInputValue(1, iOrgOrderNo); - Td0313.SetInputValue(2, Config.GetAccount()); - Td0313.SetInputValue(3, Config.GetSubAccount()); - Td0313.SetInputValue(4, strCode); - Td0313.SetInputValue(5, 0); - Td0313.SetInputValue(6, iSellPrice); - Td0313.BlockRequest2(1); + string strCode2; + m_ItemsInCorrection.TryRemove(iOrgOrderNo, out strCode2); + }); + } + else + { + await Task.Run(() => + { + int iSellPrice = iAskPrice; + + CPTRADELib.CpTd0313 Td0313 = new CPTRADELib.CpTd0313(); + Td0313.SetInputValue(1, iOrgOrderNo); + Td0313.SetInputValue(2, Config.GetAccount()); + Td0313.SetInputValue(3, Config.GetSubAccount()); + Td0313.SetInputValue(4, strCode); + Td0313.SetInputValue(5, 0); + Td0313.SetInputValue(6, iSellPrice); + BlockRequest(Td0313); + + string strCode2; + m_ItemsInCorrection.TryRemove(iOrgOrderNo, out strCode2); + }); + } + } + + public async void GetConclusion() + { + List data = new List(); + + await Task.Run(() => { + m_CP5342.SetInputValue(0, Config.GetAccount()); + m_CP5342.SetInputValue(1, Config.GetSubAccount()); + m_CP5342.SetInputValue(2, 20); + m_CP5342.SetInputValue(3, "1"); + BlockRequest(m_CP5342); + + int iCnt = m_CP5342.GetHeaderValue(8); + bool bContinue = true; + while (bContinue) + { + for (int i = 0; i < Math.Min(iCnt, 20); i++) + { + var newData = new CONCLUSION + { + strCode = m_CP5342.GetDataValue(0, i), + strCodeName = m_CP5342.GetDataValue(1, i), + iConclusionCnt = (int)m_CP5342.GetDataValue(3, i), + iFee = (int)m_CP5342.GetDataValue(4, i), + iSpecialTax = (int)m_CP5342.GetDataValue(5, i), // 농특세 + strSellBuy = m_CP5342.GetDataValue(10, i), + iTransactionTax = (int)m_CP5342.GetDataValue(12, i), // 거래세 + strDate = m_CP5342.GetDataValue(13, i), + iCommitedAmount = (int)m_CP5342.GetDataValue(22, i), // 약정금액 + iSettlementAmount = (int)m_CP5342.GetDataValue(24, i), // 정산금액 + }; + + int iIdx = data.FindLastIndex(t => t.strCode == newData.strCode); + if (iIdx < 0) + data.Add(newData); + else + data.Insert(iIdx + 1, newData); + } + iCnt -= 20; + + bContinue = (iCnt > 0); + if (bContinue) + BlockRequest(m_CP5342); + } + + m_Listener.UpdateConclusionCallback(data); }); } + + public class CONCLUSION + { + public string strCode; + public string strCodeName; + public int iConclusionCnt; + public int iFee; + public int iSpecialTax; + public string strSellBuy; + public int iTransactionTax; + public string strDate; + public int iCommitedAmount; + public int iSettlementAmount; + + public override string ToString() + { + return $"{strCodeName} {strSellBuy} {iSettlementAmount:n}"; + } + } + } } diff --git a/TaskExtensions.cs b/TaskExtensions.cs new file mode 100644 index 0000000..520c655 --- /dev/null +++ b/TaskExtensions.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AutoSellerNS +{ + public static class TaskExtensions + { + //public static async Task TimeoutAfter(this Task task, int millisecondsTimeout) + //{ + // if (task == await Task.WhenAny(task, Task.Delay(millisecondsTimeout))) + // await task; + // else + // throw new TimeoutException(); + //} + + public static async Task TimeoutAfter(Action action, int millisecondsTimeout) + { + Task task = new Task(action); + if (task == await Task.WhenAny(task, Task.Delay(millisecondsTimeout))) + await task; + else + throw new TimeoutException(); + } + } +} diff --git a/Util.cs b/Util.cs index 5e4f2a6..3f63af4 100644 --- a/Util.cs +++ b/Util.cs @@ -16,9 +16,11 @@ namespace AutoSellerNS { DEBUG, ERROR, - VERVOSE, + VERBOSE, BUY, + BUY_CONCLUSION, SELL, + SELL_CONCLUSION, } static string m_strLogFile = null; static RichTextBox m_LogBox = null; @@ -42,6 +44,7 @@ namespace AutoSellerNS Action update = delegate { Color LogColor; + Color LogBackColor = LogBox.BackColor; switch (enType) { case LOG_TYPE.DEBUG: @@ -50,14 +53,22 @@ namespace AutoSellerNS case LOG_TYPE.ERROR: LogColor = Color.DarkRed; break; - case LOG_TYPE.VERVOSE: + case LOG_TYPE.VERBOSE: LogColor = Color.Black; break; case LOG_TYPE.SELL: - LogColor = Color.Blue; + LogColor = Color.FromArgb(0, 104, 232); + break; + case LOG_TYPE.SELL_CONCLUSION: + LogColor = Color.Black; + LogBackColor = Color.FromArgb(127, 179, 243); break; case LOG_TYPE.BUY: - LogColor = Color.Red; + LogColor = Color.FromArgb(244, 45, 45); + break; + case LOG_TYPE.BUY_CONCLUSION: + LogColor = Color.Black; + LogBackColor = Color.FromArgb(249, 150, 150); break; default: LogColor = Color.Black; @@ -67,10 +78,12 @@ namespace AutoSellerNS LogBox.SelectionStart = LogBox.TextLength; LogBox.SelectionLength = 0; LogBox.SelectionColor = LogColor; + LogBox.SelectionBackColor = LogBackColor; LogBox.AppendText(strLog); LogBox.SelectionColor = LogBox.ForeColor; + LogBox.SelectionBackColor = LogBox.BackColor; LogBox.SelectionStart = LogBox.TextLength; LogBox.ScrollToCaret();