diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index c2c8700..984ced0 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -28,335 +28,441 @@ /// private void InitializeComponent() { - this.tbLog = new System.Windows.Forms.TextBox(); - this.tbSearchMax = new System.Windows.Forms.TextBox(); - this.tbBidMin = new System.Windows.Forms.TextBox(); - this.tbBidAmount = new System.Windows.Forms.TextBox(); - this.tbTimeout = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.tbTrailing = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.tbLossCut = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.tbSearchMin = new System.Windows.Forms.TextBox(); - this.btApply = new System.Windows.Forms.Button(); - this.btCancel = new System.Windows.Forms.Button(); - this.tbBidMax = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.btBalance = new System.Windows.Forms.Button(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.splitContainer3 = new System.Windows.Forms.SplitContainer(); - this.lbSBCnt = new System.Windows.Forms.Label(); - this.lbRQCnt = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); - this.splitContainer2.Panel1.SuspendLayout(); - this.splitContainer2.Panel2.SuspendLayout(); - this.splitContainer2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); - this.splitContainer3.SuspendLayout(); - this.SuspendLayout(); - // - // tbLog - // - this.tbLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.tbLog = new System.Windows.Forms.TextBox(); + this.tbSearchMax = new System.Windows.Forms.TextBox(); + this.tbBidMin = new System.Windows.Forms.TextBox(); + this.tbBidAmount = new System.Windows.Forms.TextBox(); + this.tbTimeout = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.tbTrailing = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.tbLossCut = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.tbSearchMin = new System.Windows.Forms.TextBox(); + this.btApply = new System.Windows.Forms.Button(); + this.btCancel = new System.Windows.Forms.Button(); + this.tbBidMax = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.btBalance = new System.Windows.Forms.Button(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.splitContainer3 = new System.Windows.Forms.SplitContainer(); + this.btTimeSync = new System.Windows.Forms.Button(); + this.cbStart = new System.Windows.Forms.CheckBox(); + this.btCybosPlus = new System.Windows.Forms.Button(); + this.btCybos5 = new System.Windows.Forms.Button(); + this.lbSBCnt = new System.Windows.Forms.Label(); + this.lbRQCnt = new System.Windows.Forms.Label(); + this.statusBar1 = new System.Windows.Forms.StatusBar(); + this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel(); + this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.btMATest = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); + this.splitContainer3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); + this.SuspendLayout(); + // + // tbLog + // + this.tbLog.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.tbLog.BackColor = System.Drawing.SystemColors.Control; - this.tbLog.HideSelection = false; - this.tbLog.Location = new System.Drawing.Point(12, 3); - this.tbLog.Multiline = true; - this.tbLog.Name = "tbLog"; - this.tbLog.ReadOnly = true; - this.tbLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.tbLog.Size = new System.Drawing.Size(862, 73); - this.tbLog.TabIndex = 2; - // - // tbSearchMax - // - this.tbSearchMax.Location = new System.Drawing.Point(160, 23); - this.tbSearchMax.Name = "tbSearchMax"; - this.tbSearchMax.Size = new System.Drawing.Size(37, 21); - this.tbSearchMax.TabIndex = 6; - this.tbSearchMax.Text = "10.5%"; - this.tbSearchMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // tbBidMin - // - this.tbBidMin.Location = new System.Drawing.Point(97, 50); - this.tbBidMin.Name = "tbBidMin"; - this.tbBidMin.Size = new System.Drawing.Size(37, 21); - this.tbBidMin.TabIndex = 8; - this.tbBidMin.Text = "9.0%"; - this.tbBidMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // tbBidAmount - // - this.tbBidAmount.Location = new System.Drawing.Point(97, 77); - this.tbBidAmount.Name = "tbBidAmount"; - this.tbBidAmount.Size = new System.Drawing.Size(100, 21); - this.tbBidAmount.TabIndex = 9; - this.tbBidAmount.Text = "100,000"; - this.tbBidAmount.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // tbTimeout - // - this.tbTimeout.Location = new System.Drawing.Point(97, 104); - this.tbTimeout.Name = "tbTimeout"; - this.tbTimeout.Size = new System.Drawing.Size(100, 21); - this.tbTimeout.TabIndex = 10; - this.tbTimeout.Text = "120"; - this.tbTimeout.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(38, 26); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(53, 12); - this.label1.TabIndex = 11; - this.label1.Text = "검색범위"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(38, 53); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(53, 12); - this.label2.TabIndex = 12; - this.label2.Text = "매수범위"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(38, 80); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(41, 12); - this.label3.TabIndex = 13; - this.label3.Text = "매수금"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(38, 107); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(53, 12); - this.label4.TabIndex = 13; - this.label4.Text = "타임아웃"; - // - // tbTrailing - // - this.tbTrailing.Location = new System.Drawing.Point(97, 131); - this.tbTrailing.Name = "tbTrailing"; - this.tbTrailing.Size = new System.Drawing.Size(100, 21); - this.tbTrailing.TabIndex = 10; - this.tbTrailing.Text = "3.0%"; - this.tbTrailing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(38, 134); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(53, 12); - this.label5.TabIndex = 13; - this.label5.Text = "트레일링"; - // - // tbLossCut - // - this.tbLossCut.Location = new System.Drawing.Point(97, 158); - this.tbLossCut.Name = "tbLossCut"; - this.tbLossCut.Size = new System.Drawing.Size(100, 21); - this.tbLossCut.TabIndex = 10; - this.tbLossCut.Text = "3.0%"; - this.tbLossCut.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(38, 161); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(29, 12); - this.label6.TabIndex = 13; - this.label6.Text = "손절"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(140, 26); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(14, 12); - this.label7.TabIndex = 11; - this.label7.Text = "~"; - // - // tbSearchMin - // - this.tbSearchMin.Location = new System.Drawing.Point(97, 23); - this.tbSearchMin.Name = "tbSearchMin"; - this.tbSearchMin.Size = new System.Drawing.Size(37, 21); - this.tbSearchMin.TabIndex = 14; - this.tbSearchMin.Text = "7.0%"; - this.tbSearchMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // btApply - // - this.btApply.Location = new System.Drawing.Point(97, 185); - this.btApply.Name = "btApply"; - this.btApply.Size = new System.Drawing.Size(44, 23); - this.btApply.TabIndex = 15; - this.btApply.Text = "적용"; - this.btApply.UseVisualStyleBackColor = true; - this.btApply.Click += new System.EventHandler(this.btApply_Click); - // - // btCancel - // - this.btCancel.Location = new System.Drawing.Point(153, 185); - this.btCancel.Name = "btCancel"; - this.btCancel.Size = new System.Drawing.Size(44, 23); - this.btCancel.TabIndex = 16; - this.btCancel.Text = "취소"; - this.btCancel.UseVisualStyleBackColor = true; - this.btCancel.Click += new System.EventHandler(this.btCancel_Click); - // - // tbBidMax - // - this.tbBidMax.Location = new System.Drawing.Point(160, 50); - this.tbBidMax.Name = "tbBidMax"; - this.tbBidMax.Size = new System.Drawing.Size(37, 21); - this.tbBidMax.TabIndex = 8; - this.tbBidMax.Text = "10.0%"; - this.tbBidMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(140, 53); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(14, 12); - this.label8.TabIndex = 11; - this.label8.Text = "~"; - // - // btBalance - // - this.btBalance.Location = new System.Drawing.Point(122, 214); - this.btBalance.Name = "btBalance"; - this.btBalance.Size = new System.Drawing.Size(75, 23); - this.btBalance.TabIndex = 17; - this.btBalance.Text = "잔고"; - this.btBalance.UseVisualStyleBackColor = true; - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.tbLog); - this.splitContainer1.Size = new System.Drawing.Size(886, 642); - this.splitContainer1.SplitterDistance = 550; - this.splitContainer1.TabIndex = 20; - // - // splitContainer2 - // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Name = "splitContainer2"; - // - // splitContainer2.Panel1 - // - this.splitContainer2.Panel1.Controls.Add(this.splitContainer3); - // - // splitContainer2.Panel2 - // - this.splitContainer2.Panel2.Controls.Add(this.lbSBCnt); - this.splitContainer2.Panel2.Controls.Add(this.lbRQCnt); - this.splitContainer2.Panel2.Controls.Add(this.btBalance); - this.splitContainer2.Panel2.Controls.Add(this.label1); - this.splitContainer2.Panel2.Controls.Add(this.label5); - this.splitContainer2.Panel2.Controls.Add(this.tbTimeout); - this.splitContainer2.Panel2.Controls.Add(this.tbSearchMax); - this.splitContainer2.Panel2.Controls.Add(this.label7); - this.splitContainer2.Panel2.Controls.Add(this.btCancel); - this.splitContainer2.Panel2.Controls.Add(this.label6); - this.splitContainer2.Panel2.Controls.Add(this.label2); - this.splitContainer2.Panel2.Controls.Add(this.label4); - this.splitContainer2.Panel2.Controls.Add(this.tbBidMin); - this.splitContainer2.Panel2.Controls.Add(this.tbBidAmount); - this.splitContainer2.Panel2.Controls.Add(this.tbLossCut); - this.splitContainer2.Panel2.Controls.Add(this.label8); - this.splitContainer2.Panel2.Controls.Add(this.btApply); - this.splitContainer2.Panel2.Controls.Add(this.tbSearchMin); - this.splitContainer2.Panel2.Controls.Add(this.tbTrailing); - this.splitContainer2.Panel2.Controls.Add(this.label3); - this.splitContainer2.Panel2.Controls.Add(this.tbBidMax); - this.splitContainer2.Size = new System.Drawing.Size(886, 550); - this.splitContainer2.SplitterDistance = 645; - this.splitContainer2.TabIndex = 0; - // - // splitContainer3 - // - this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer3.Location = new System.Drawing.Point(0, 0); - this.splitContainer3.Name = "splitContainer3"; - this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; - this.splitContainer3.Size = new System.Drawing.Size(645, 550); - this.splitContainer3.SplitterDistance = 231; - this.splitContainer3.TabIndex = 0; - // - // lbSBCnt - // - this.lbSBCnt.AutoSize = true; - this.lbSBCnt.Location = new System.Drawing.Point(29, 278); - this.lbSBCnt.Name = "lbSBCnt"; - this.lbSBCnt.Size = new System.Drawing.Size(70, 12); - this.lbSBCnt.TabIndex = 19; - this.lbSBCnt.Text = "SB Count : "; - // - // lbRQCnt - // - this.lbRQCnt.AutoSize = true; - this.lbRQCnt.Location = new System.Drawing.Point(29, 254); - this.lbRQCnt.Name = "lbRQCnt"; - this.lbRQCnt.Size = new System.Drawing.Size(71, 12); - this.lbRQCnt.TabIndex = 18; - this.lbRQCnt.Text = "RQ Count : "; - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(886, 642); - this.Controls.Add(this.splitContainer1); - this.Name = "MainForm"; - this.Text = "Upper Limit"; - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.splitContainer2.Panel1.ResumeLayout(false); - this.splitContainer2.Panel2.ResumeLayout(false); - this.splitContainer2.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); - this.splitContainer2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); - this.splitContainer3.ResumeLayout(false); - this.ResumeLayout(false); + this.tbLog.BackColor = System.Drawing.SystemColors.Control; + this.tbLog.HideSelection = false; + this.tbLog.Location = new System.Drawing.Point(12, 3); + this.tbLog.Multiline = true; + this.tbLog.Name = "tbLog"; + this.tbLog.ReadOnly = true; + this.tbLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.tbLog.Size = new System.Drawing.Size(862, 84); + this.tbLog.TabIndex = 2; + // + // tbSearchMax + // + this.tbSearchMax.Location = new System.Drawing.Point(160, 23); + this.tbSearchMax.Name = "tbSearchMax"; + this.tbSearchMax.Size = new System.Drawing.Size(37, 21); + this.tbSearchMax.TabIndex = 6; + this.tbSearchMax.Text = "10.5%"; + this.tbSearchMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // tbBidMin + // + this.tbBidMin.Location = new System.Drawing.Point(97, 50); + this.tbBidMin.Name = "tbBidMin"; + this.tbBidMin.Size = new System.Drawing.Size(37, 21); + this.tbBidMin.TabIndex = 8; + this.tbBidMin.Text = "9.0%"; + this.tbBidMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // tbBidAmount + // + this.tbBidAmount.Location = new System.Drawing.Point(97, 77); + this.tbBidAmount.Name = "tbBidAmount"; + this.tbBidAmount.Size = new System.Drawing.Size(100, 21); + this.tbBidAmount.TabIndex = 9; + this.tbBidAmount.Text = "100,000"; + this.tbBidAmount.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // tbTimeout + // + this.tbTimeout.Location = new System.Drawing.Point(97, 104); + this.tbTimeout.Name = "tbTimeout"; + this.tbTimeout.Size = new System.Drawing.Size(100, 21); + this.tbTimeout.TabIndex = 10; + this.tbTimeout.Text = "120"; + this.tbTimeout.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(38, 26); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 12); + this.label1.TabIndex = 11; + this.label1.Text = "검색범위"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(38, 53); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(53, 12); + this.label2.TabIndex = 12; + this.label2.Text = "매수범위"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(38, 80); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(41, 12); + this.label3.TabIndex = 13; + this.label3.Text = "매수금"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(38, 107); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(53, 12); + this.label4.TabIndex = 13; + this.label4.Text = "타임아웃"; + // + // tbTrailing + // + this.tbTrailing.Location = new System.Drawing.Point(97, 131); + this.tbTrailing.Name = "tbTrailing"; + this.tbTrailing.Size = new System.Drawing.Size(100, 21); + this.tbTrailing.TabIndex = 10; + this.tbTrailing.Text = "3.0%"; + this.tbTrailing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(38, 134); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(53, 12); + this.label5.TabIndex = 13; + this.label5.Text = "트레일링"; + // + // tbLossCut + // + this.tbLossCut.Location = new System.Drawing.Point(97, 158); + this.tbLossCut.Name = "tbLossCut"; + this.tbLossCut.Size = new System.Drawing.Size(100, 21); + this.tbLossCut.TabIndex = 10; + this.tbLossCut.Text = "3.0%"; + this.tbLossCut.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(38, 161); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(29, 12); + this.label6.TabIndex = 13; + this.label6.Text = "손절"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(140, 26); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(14, 12); + this.label7.TabIndex = 11; + this.label7.Text = "~"; + // + // tbSearchMin + // + this.tbSearchMin.Location = new System.Drawing.Point(97, 23); + this.tbSearchMin.Name = "tbSearchMin"; + this.tbSearchMin.Size = new System.Drawing.Size(37, 21); + this.tbSearchMin.TabIndex = 14; + this.tbSearchMin.Text = "7.0%"; + this.tbSearchMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // btApply + // + this.btApply.Location = new System.Drawing.Point(97, 185); + this.btApply.Name = "btApply"; + this.btApply.Size = new System.Drawing.Size(44, 23); + this.btApply.TabIndex = 15; + this.btApply.Text = "적용"; + this.btApply.UseVisualStyleBackColor = true; + this.btApply.Click += new System.EventHandler(this.btApply_Click); + // + // btCancel + // + this.btCancel.Location = new System.Drawing.Point(153, 185); + this.btCancel.Name = "btCancel"; + this.btCancel.Size = new System.Drawing.Size(44, 23); + this.btCancel.TabIndex = 16; + this.btCancel.Text = "취소"; + this.btCancel.UseVisualStyleBackColor = true; + this.btCancel.Click += new System.EventHandler(this.btCancel_Click); + // + // tbBidMax + // + this.tbBidMax.Location = new System.Drawing.Point(160, 50); + this.tbBidMax.Name = "tbBidMax"; + this.tbBidMax.Size = new System.Drawing.Size(37, 21); + this.tbBidMax.TabIndex = 8; + this.tbBidMax.Text = "10.0%"; + this.tbBidMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(140, 53); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(14, 12); + this.label8.TabIndex = 11; + this.label8.Text = "~"; + // + // btBalance + // + this.btBalance.Location = new System.Drawing.Point(122, 214); + this.btBalance.Name = "btBalance"; + this.btBalance.Size = new System.Drawing.Size(75, 23); + this.btBalance.TabIndex = 17; + this.btBalance.Text = "잔고"; + this.btBalance.UseVisualStyleBackColor = true; + // + // splitContainer1 + // + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.tbLog); + this.splitContainer1.Size = new System.Drawing.Size(886, 714); + this.splitContainer1.SplitterDistance = 611; + this.splitContainer1.TabIndex = 20; + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.splitContainer3); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.btMATest); + this.splitContainer2.Panel2.Controls.Add(this.button1); + this.splitContainer2.Panel2.Controls.Add(this.btTimeSync); + this.splitContainer2.Panel2.Controls.Add(this.cbStart); + this.splitContainer2.Panel2.Controls.Add(this.btCybosPlus); + this.splitContainer2.Panel2.Controls.Add(this.btCybos5); + this.splitContainer2.Panel2.Controls.Add(this.lbSBCnt); + this.splitContainer2.Panel2.Controls.Add(this.lbRQCnt); + this.splitContainer2.Panel2.Controls.Add(this.btBalance); + this.splitContainer2.Panel2.Controls.Add(this.label1); + this.splitContainer2.Panel2.Controls.Add(this.label5); + this.splitContainer2.Panel2.Controls.Add(this.tbTimeout); + this.splitContainer2.Panel2.Controls.Add(this.tbSearchMax); + this.splitContainer2.Panel2.Controls.Add(this.label7); + this.splitContainer2.Panel2.Controls.Add(this.btCancel); + this.splitContainer2.Panel2.Controls.Add(this.label6); + this.splitContainer2.Panel2.Controls.Add(this.label2); + this.splitContainer2.Panel2.Controls.Add(this.label4); + this.splitContainer2.Panel2.Controls.Add(this.tbBidMin); + this.splitContainer2.Panel2.Controls.Add(this.tbBidAmount); + this.splitContainer2.Panel2.Controls.Add(this.tbLossCut); + this.splitContainer2.Panel2.Controls.Add(this.label8); + this.splitContainer2.Panel2.Controls.Add(this.btApply); + this.splitContainer2.Panel2.Controls.Add(this.tbSearchMin); + this.splitContainer2.Panel2.Controls.Add(this.tbTrailing); + this.splitContainer2.Panel2.Controls.Add(this.label3); + this.splitContainer2.Panel2.Controls.Add(this.tbBidMax); + this.splitContainer2.Size = new System.Drawing.Size(886, 611); + this.splitContainer2.SplitterDistance = 645; + this.splitContainer2.TabIndex = 0; + // + // splitContainer3 + // + this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer3.Location = new System.Drawing.Point(0, 0); + this.splitContainer3.Name = "splitContainer3"; + this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; + this.splitContainer3.Size = new System.Drawing.Size(645, 611); + this.splitContainer3.SplitterDistance = 256; + this.splitContainer3.TabIndex = 0; + // + // btTimeSync + // + this.btTimeSync.Location = new System.Drawing.Point(16, 341); + this.btTimeSync.Name = "btTimeSync"; + this.btTimeSync.Size = new System.Drawing.Size(84, 57); + this.btTimeSync.TabIndex = 22; + this.btTimeSync.Text = "Time Sync"; + this.btTimeSync.UseVisualStyleBackColor = true; + this.btTimeSync.Click += new System.EventHandler(this.btTimeSync_Click); + // + // cbStart + // + this.cbStart.Appearance = System.Windows.Forms.Appearance.Button; + this.cbStart.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.cbStart.Location = new System.Drawing.Point(16, 404); + this.cbStart.Name = "cbStart"; + this.cbStart.Size = new System.Drawing.Size(84, 57); + this.cbStart.TabIndex = 21; + this.cbStart.Text = "Start"; + this.cbStart.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.cbStart.UseVisualStyleBackColor = true; + this.cbStart.CheckedChanged += new System.EventHandler(this.cbStart_CheckedChanged); + // + // btCybosPlus + // + this.btCybosPlus.Location = new System.Drawing.Point(113, 467); + this.btCybosPlus.Name = "btCybosPlus"; + this.btCybosPlus.Size = new System.Drawing.Size(84, 67); + this.btCybosPlus.TabIndex = 20; + this.btCybosPlus.Text = "Cybos Plus"; + this.btCybosPlus.UseVisualStyleBackColor = true; + this.btCybosPlus.Click += new System.EventHandler(this.btCybosPlus_Click); + // + // btCybos5 + // + this.btCybos5.Location = new System.Drawing.Point(16, 467); + this.btCybos5.Name = "btCybos5"; + this.btCybos5.Size = new System.Drawing.Size(84, 67); + this.btCybos5.TabIndex = 20; + this.btCybos5.Text = "Cybos 5"; + this.btCybos5.UseVisualStyleBackColor = true; + this.btCybos5.Click += new System.EventHandler(this.btCybos5_Click); + // + // lbSBCnt + // + this.lbSBCnt.AutoSize = true; + this.lbSBCnt.Location = new System.Drawing.Point(29, 278); + this.lbSBCnt.Name = "lbSBCnt"; + this.lbSBCnt.Size = new System.Drawing.Size(70, 12); + this.lbSBCnt.TabIndex = 19; + this.lbSBCnt.Text = "SB Count : "; + // + // lbRQCnt + // + this.lbRQCnt.AutoSize = true; + this.lbRQCnt.Location = new System.Drawing.Point(29, 254); + this.lbRQCnt.Name = "lbRQCnt"; + this.lbRQCnt.Size = new System.Drawing.Size(71, 12); + this.lbRQCnt.TabIndex = 18; + this.lbRQCnt.Text = "RQ Count : "; + // + // statusBar1 + // + this.statusBar1.Location = new System.Drawing.Point(0, 720); + this.statusBar1.Name = "statusBar1"; + this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { + this.statusBarPanel1, + this.statusBarPanel2}); + this.statusBar1.ShowPanels = true; + this.statusBar1.Size = new System.Drawing.Size(886, 22); + this.statusBar1.TabIndex = 21; + this.statusBar1.Text = "statusBar1"; + // + // statusBarPanel1 + // + this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; + this.statusBarPanel1.Name = "statusBarPanel1"; + this.statusBarPanel1.Width = 749; + // + // statusBarPanel2 + // + this.statusBarPanel2.MinWidth = 120; + this.statusBarPanel2.Name = "statusBarPanel2"; + this.statusBarPanel2.Width = 120; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(142, 371); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 23; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // btMATest + // + this.btMATest.Location = new System.Drawing.Point(138, 430); + this.btMATest.Name = "btMATest"; + this.btMATest.Size = new System.Drawing.Size(75, 23); + this.btMATest.TabIndex = 24; + this.btMATest.Text = "ma test"; + this.btMATest.UseVisualStyleBackColor = true; + this.btMATest.Click += new System.EventHandler(this.btMATest_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(886, 742); + this.Controls.Add(this.statusBar1); + this.Controls.Add(this.splitContainer1); + this.Name = "MainForm"; + this.Text = "Upper Limit"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + this.splitContainer2.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); + this.splitContainer3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); + this.ResumeLayout(false); } @@ -386,6 +492,15 @@ private System.Windows.Forms.SplitContainer splitContainer3; private System.Windows.Forms.Label lbRQCnt; private System.Windows.Forms.Label lbSBCnt; + private System.Windows.Forms.Button btCybosPlus; + private System.Windows.Forms.Button btCybos5; + private System.Windows.Forms.CheckBox cbStart; + private System.Windows.Forms.Button btTimeSync; + private System.Windows.Forms.StatusBar statusBar1; + private System.Windows.Forms.StatusBarPanel statusBarPanel1; + private System.Windows.Forms.StatusBarPanel statusBarPanel2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button btMATest; } } diff --git a/MainForm.cs b/MainForm.cs index 0438468..64160ba 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -2,6 +2,7 @@ using System.Windows.Forms; using System.Collections; using System.Reflection; +using System.Diagnostics; namespace upper_limit_crawler { @@ -37,7 +38,6 @@ namespace upper_limit_crawler SetDoubleBuffered(tbLog); UlUtil.Init(tbLog); - //UlUtil.GetServerTime(); btApply_Click(null, null); @@ -96,6 +96,12 @@ namespace upper_limit_crawler return; } + if(cbStart.Checked == true && UlUtil.IsConnected() == false) + { + cbStart.Checked = false; + return; + } + int iDeltaT = iCurTime - m_iLastTime; m_Own.Refresh(iCurTime); @@ -103,10 +109,49 @@ namespace upper_limit_crawler lbRQCnt.Text = "RQ Count : " + UlUtil.GetLimitRemainCountRQ().ToString(); lbSBCnt.Text = "SB Count : " + UlUtil.GetLimitRemainCountSB().ToString(); + statusBar1.Panels[1].Text = UlUtil.GetCurTimeString() + " "; + m_iLastTime = iCurTime; } - private void AddTrace(string strCode) + void StartAll() + { + m_MonitorDlg.Start(); + m_BalanceDlg.Start(); + m_DataMgr.StartAll(); + } + + void StopAll() + { + m_MonitorDlg.Stop(); + m_BalanceDlg.Stop(); + m_DataMgr.StopAll(); + } + + private void cbStart_CheckedChanged(object sender, EventArgs e) + { + if (cbStart.Checked == true) + { + if (UlUtil.IsConnected() == false) + UlUtil.Reset(); + + if (UlUtil.IsConnected() == false) + { + cbStart.Checked = false; + MessageBox.Show("Cybos Plus를 실행해주세요"); + return; + } + + m_DataMgr.Init(); + StartAll(); + } + else + { + StopAll(); + } + } + + private void AddTrace(string strCode) { if (m_TraceList.Contains(strCode) == true) return; @@ -146,5 +191,104 @@ namespace upper_limit_crawler tbTrailing.Text = (m_DataMgr.m_Setting.m_fTrailing*100).ToString("0.0") + "%"; tbLossCut.Text = (m_DataMgr.m_Setting.m_fLossCut*100).ToString("0.0") + "%"; } - } + + private void btCybos5_Click(object sender, EventArgs e) + { + string strappname = @"C:\DAISHIN\STARTER\ncStarter.exe"; + Process.Start(strappname); + } + + private void btCybosPlus_Click(object sender, EventArgs e) + { + string strappname = @"C:\DAISHIN\STARTER\ncStarter.exe"; + Process.Start(strappname, @"/prj:cp"); + } + + private void btTimeSync_Click(object sender, EventArgs e) + { + UlUtil.SyncServerTime(); + } + + DSCBO1Lib.StockCur cur = new DSCBO1Lib.StockCur(); + DSCBO1Lib.StockOutCur outCur = new DSCBO1Lib.StockOutCur(); + string strCheckCode = "A004565"; + + private void button1_Click(object sender, EventArgs e) + { + { + DSCBO1Lib.StockMst mst = new DSCBO1Lib.StockMst(); + mst.SetInputValue(0, strCheckCode); + mst.BlockRequest(); + short time = mst.GetHeaderValue(4); + Console.WriteLine("StockMst : {0}", time); + } + + { + DSCBO1Lib.StockMst2 mst2 = new DSCBO1Lib.StockMst2(); + mst2.SetInputValue(0, strCheckCode); + mst2.BlockRequest(); + long time = mst2.GetDataValue(2, 0); + Console.WriteLine("StockMst2 : {0}", time); + } + + { + cur.SetInputValue(0, strCheckCode); + cur.Received += Cur_Received; + cur.SubscribeLatest(); + } + + { + outCur.SetInputValue(0, strCheckCode); + outCur.Received += OutCur_Received; + outCur.SubscribeLatest(); + } + } + + private void OutCur_Received() + { + long time = outCur.GetHeaderValue(1); + Console.WriteLine("StockOutCur : {0}", time); + } + + private void Cur_Received() + { + long time = cur.GetHeaderValue(3); + long time2 = cur.GetHeaderValue(18); + Console.WriteLine("StockCur : {0} / {1}", time, time2); + } + + private void btMATest_Click(object sender, EventArgs e) + { + CPSYSDIBLib.StockChart stockChart = new CPSYSDIBLib.StockChart(); + stockChart.SetInputValue(0, "A043580"); + stockChart.SetInputValue(1, '1'); + stockChart.SetInputValue(2, "20160722"); + stockChart.SetInputValue(3, "20160722"); + stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 10 }); + stockChart.SetInputValue(6, 'm'); + stockChart.BlockRequest2(1); + + int iCnt = (int)stockChart.GetHeaderValue(3); + int iFieldCnt = stockChart.GetHeaderValue(1); + string[] astrFieldName = stockChart.GetHeaderValue(2); + + ULWatchItem item = new ULWatchItem(); + + for (int i=iCnt-1; i>=0; i--) + { + int iTime = (int)stockChart.GetDataValue(1, i); + int iPrice = (int)stockChart.GetDataValue(5, i); + int iVolume = (int)stockChart.GetDataValue(5, i); + + iTime *= 100; + + item.m_iCurPrice = iPrice; + item.InsertPriceNode(iTime, iPrice); + } + + //item.MakeChart(); + //item.MakeMAChart(); + item.PrintChart(); + } + } } diff --git a/ULBalanceDlg.cs b/ULBalanceDlg.cs index e45959d..9ab3fde 100644 --- a/ULBalanceDlg.cs +++ b/ULBalanceDlg.cs @@ -37,7 +37,6 @@ namespace upper_limit_crawler List m_OwnList = new List(); - DSCBO1Lib.StockMst2 m_StockMst2 = new DSCBO1Lib.StockMst2(); Timer m_MainTimer = new Timer(); int m_iLastTime = 0; @@ -45,8 +44,7 @@ namespace upper_limit_crawler ULDataMgr m_DataMgr = null; - CPTRADELib.CpTd6033 m_Td6033 = new CPTRADELib.CpTd6033(); - DSCBO1Lib.StockCur m_StockCur = new DSCBO1Lib.StockCur(); + CPTRADELib.CpTd6033 m_Td6033 = null; public ULBalanceDlg(ULDataMgr DataMgr) { @@ -61,18 +59,28 @@ namespace upper_limit_crawler MainForm.SetDoubleBuffered(lvBalance); btSell.Enabled = false; - RefreshBalance(); - m_MainTimer.Interval=15; m_MainTimer.Tick+=RefreshData; - m_MainTimer.Start(); } + public void Start() + { + m_Td6033 = new CPTRADELib.CpTd6033(); + + RefreshBalance(); + + m_MainTimer.Start(); + } + + public void Stop() + { + m_MainTimer.Stop(); + } + private void RefreshBalance() { m_Td6033.SetInputValue(0, m_DataMgr.GetAccount()); m_Td6033.SetInputValue(2, 50); - m_Td6033.BlockRequest2(1); lvBalance.Items.Clear(); @@ -147,13 +155,13 @@ namespace upper_limit_crawler private void RefreshCurPrice() { - Dictionary WatchList = m_DataMgr.GetWatchList(); + Dictionary WatchList = m_DataMgr.GetWatchList(); foreach (ListViewItem lvItem in lvBalance.Items) { string strCode = lvItem.SubItems[chCode.Index].Text; if (WatchList.ContainsKey(strCode) == true) { - WATCH_ITEM WatchItem = WatchList[strCode]; + ULWatchItem WatchItem = WatchList[strCode]; OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode); if (OwnItem == null) continue; @@ -192,7 +200,7 @@ namespace upper_limit_crawler // loss cut if (iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut)) { - UlUtil.Trace(string.Format("[{0}] 손절 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"))); + UlUtil.Trace(string.Format("[{0}] 손절 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"))); m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance); m_OwnList.Remove(OwnItem); m_DataMgr.RemoveWatch(strCode); @@ -204,7 +212,7 @@ namespace upper_limit_crawler // trailing else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing) { - UlUtil.Trace(string.Format("[{0}] 트레일링 매도 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"))); + UlUtil.Trace(string.Format("[{0}] 트레일링 매도 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"))); m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance); m_OwnList.Remove(OwnItem); m_DataMgr.RemoveWatch(strCode); diff --git a/ULDataMgr.cs b/ULDataMgr.cs index 78b03f2..fa9c3a2 100644 --- a/ULDataMgr.cs +++ b/ULDataMgr.cs @@ -20,45 +20,24 @@ namespace upper_limit_crawler public float m_fLossCut; } - public class WATCH_ITEM - { - public string m_strCode; - public string m_strCodeName; - public DSCBO1Lib.StockCur m_StockCur = null; - public void Received() - { - m_iCurPrice = m_StockCur.GetHeaderValue(13); - m_iPrevClosing = m_iCurPrice - m_StockCur.GetHeaderValue(2); - m_iStartPrice = m_StockCur.GetHeaderValue(4); - m_iHighestPrice = m_StockCur.GetHeaderValue(5); - m_iVolume = m_StockCur.GetHeaderValue(9); - m_iBidPrice = m_StockCur.GetHeaderValue(8); - m_iBidCnt = 0; - } - - public int m_iCurPrice; - public int m_iPrevClosing; - public int m_iStartPrice; - public int m_iHighestPrice; - - public int m_iVolume; - public int m_iBidPrice; - public int m_iBidCnt; - } - public class ULDataMgr { public SETTING m_Setting = new SETTING(); ULTrader m_Trader = new ULTrader(); - Dictionary m_WatchList = new Dictionary(); + Dictionary m_WatchList = new Dictionary(); List m_BlackList = new List(); public ULDataMgr() { } + public void Init() + { + m_Trader.Init(); + } + public string GetAccount() { return m_Trader.GetAccount(); @@ -74,7 +53,7 @@ namespace upper_limit_crawler if (m_WatchList.ContainsKey(strCode)) return; - WATCH_ITEM item = new WATCH_ITEM(); + ULWatchItem item = new ULWatchItem(); item.m_strCode = strCode; item.m_strCodeName = strCodeName; item.m_iCurPrice = iCurPrice; @@ -97,6 +76,25 @@ namespace upper_limit_crawler m_WatchList.Remove(strCode); } + public void StartAll() + { + foreach (KeyValuePair item in m_WatchList) + { + item.Value.m_StockCur = new DSCBO1Lib.StockCur(); + item.Value.m_StockCur.SetInputValue(0, item.Value.m_strCode); + item.Value.m_StockCur.Received += item.Value.Received; + item.Value.m_StockCur.SubscribeLatest(); + } + } + + public void StopAll() + { + foreach (KeyValuePair item in m_WatchList) + { + item.Value.m_StockCur.Unsubscribe(); + } + } + public void AddBlackList(string strCode) { m_BlackList.Add(strCode); @@ -107,7 +105,7 @@ namespace upper_limit_crawler return m_BlackList.Contains(strCode); } - public Dictionary GetWatchList() + public Dictionary GetWatchList() { return m_WatchList; } diff --git a/ULMonitorDlg.cs b/ULMonitorDlg.cs index 1d4dec9..aa424e7 100644 --- a/ULMonitorDlg.cs +++ b/ULMonitorDlg.cs @@ -16,14 +16,12 @@ namespace upper_limit_crawler const int MONITOR_DELAY = 15000; ULDataMgr m_DataMgr; - CPSYSDIBLib.CpSvrNew7043 m_7043 = new CPSYSDIBLib.CpSvrNew7043(); + CPSYSDIBLib.CpSvrNew7043 m_7043 = null; Timer m_Timer = new Timer(); int m_iMonitorDelay = 0; int m_iLastTime = 0; bool m_bRequesting = false; - DSCBO1Lib.StockCur m_StockCur = new DSCBO1Lib.StockCur(); - public ULMonitorDlg(ULDataMgr DataMgr) { InitializeComponent(); @@ -33,30 +31,36 @@ namespace upper_limit_crawler this.TopLevel = false; m_DataMgr = DataMgr; - - m_7043.SetInputValue(0, '0'); - m_7043.SetInputValue(1, '2'); - m_7043.SetInputValue(2, '1'); - m_7043.SetInputValue(3, 21); - m_7043.SetInputValue(4, '1'); - m_7043.SetInputValue(5, '0'); - m_7043.SetInputValue(6, '0'); - m_7043.SetInputValue(7, (short)(m_DataMgr.m_Setting.m_fSearchMin*100)); - m_7043.SetInputValue(8, (short)((m_DataMgr.m_Setting.m_fSearchMax+0.009)*100)); - - m_StockCur.Received += StockCur_Received; - + m_Timer.Interval = 100; m_Timer.Tick += Refresh; - m_Timer.Start(); } - private void StockCur_Received() - { - - } + public void Start() + { + m_7043 = new CPSYSDIBLib.CpSvrNew7043(); + m_7043.SetInputValue(0, '0'); + m_7043.SetInputValue(1, '2'); + m_7043.SetInputValue(2, '1'); + m_7043.SetInputValue(3, 21); + m_7043.SetInputValue(4, '1'); + m_7043.SetInputValue(5, '0'); + m_7043.SetInputValue(6, '0'); + m_7043.SetInputValue(7, (short)(m_DataMgr.m_Setting.m_fSearchMin * 100)); + m_7043.SetInputValue(8, (short)((m_DataMgr.m_Setting.m_fSearchMax + 0.009) * 100)); - bool Check() + + RefreshMonitorItem(); + + m_Timer.Start(); + } + + public void Stop() + { + m_Timer.Stop(); + } + + bool RefreshMonitorItem() { if (m_bRequesting == true || UlUtil.GetLimitRemainCountRQ() < 30) return false; @@ -129,13 +133,13 @@ namespace upper_limit_crawler void RefreshData() { - Dictionary WatchList = m_DataMgr.GetWatchList(); + Dictionary WatchList = m_DataMgr.GetWatchList(); foreach (ListViewItem lvItem in lvWatch.Items) { string strCode = lvItem.SubItems[chCode.Index].Text; if (WatchList.ContainsKey(strCode) == true) { - WATCH_ITEM item = WatchList[strCode]; + ULWatchItem item = WatchList[strCode]; int iDisplayCurPrice = 0; if (lvItem.SubItems[chCurPrice.Index].Text.Length > 0) @@ -154,10 +158,11 @@ namespace upper_limit_crawler if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax && - m_DataMgr.IsInBlackList(strCode) == false) + item.IsUpSlope() == true && + m_DataMgr.IsInBlackList(strCode) == false) { // bid and add to black list - UlUtil.Trace(string.Format("[{0}] 조건 매수 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate)); + UlUtil.Trace(string.Format("[{0}] 조건 매수 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"))); m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount); m_DataMgr.AddBlackList(strCode); @@ -180,7 +185,7 @@ namespace upper_limit_crawler m_iMonitorDelay -= iDeltaT; if (m_iMonitorDelay <= 0) { - bool bRequest = Check(); + bool bRequest = RefreshMonitorItem(); m_iMonitorDelay = (bRequest == true) ? MONITOR_DELAY : 1000; } diff --git a/ULTrader.cs b/ULTrader.cs index d848d1b..f82ef39 100644 --- a/ULTrader.cs +++ b/ULTrader.cs @@ -8,10 +8,8 @@ namespace upper_limit_crawler { public class ULTrader { - CPFORETRADELib.CpForeTdUtil m_Util = new CPFORETRADELib.CpForeTdUtil(); - DSCBO1Lib.CpConclusion m_Conclusion = new DSCBO1Lib.CpConclusion(); - //CPTRADELib.CpTd0311 m_Td0311Bid = new CPTRADELib.CpTd0311(); - //CPTRADELib.CpTd0311 m_Td0311Ask = new CPTRADELib.CpTd0311(); + CPFORETRADELib.CpForeTdUtil m_Util = null; + DSCBO1Lib.CpConclusion m_Conclusion = null; string[] m_astrAccounts = null; @@ -20,9 +18,16 @@ namespace upper_limit_crawler public ULTrader() { - m_Util.TradeInit(); + } + + public void Init() + { + m_Util = new CPFORETRADELib.CpForeTdUtil(); + m_Conclusion = new DSCBO1Lib.CpConclusion(); + + m_Util.TradeInit(); m_astrAccounts = m_Util.AccountNumber; - + StartConclusion(); } diff --git a/ULWatchItem.cs b/ULWatchItem.cs new file mode 100644 index 0000000..49b88f4 --- /dev/null +++ b/ULWatchItem.cs @@ -0,0 +1,252 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace upper_limit_crawler +{ + public class ULWatchItem + { + public class PriceNode + { + public PriceNode(int iTime, int iPrice) + { + m_iTime = iTime; + m_iPrice = iPrice; + } + + public int m_iTime; + public int m_iPrice; + } + + public class CandleTick + { + public CandleTick(int iTime, int iPrice) + { + m_iTime = iTime; + m_iStart = iPrice; + m_iEnd = iPrice; + m_iLowest = iPrice; + m_iHighest = iPrice; + } + + public int m_iTime; + public int m_iStart; + public int m_iEnd; + public int m_iLowest; + public int m_iHighest; + } + + public class MATick + { + public MATick(int iTime, float fMA) + { + m_iTime = iTime; + m_fMA = fMA; + } + + public int m_iTime; + public float m_fMA; + } + + + public string m_strCode; + public string m_strCodeName; + public DSCBO1Lib.StockCur m_StockCur = null; + public int m_iCurPrice; + public int m_iPrevClosing; + public int m_iStartPrice; + public int m_iHighestPrice; + + public int m_iVolume; + public int m_iBidPrice; + public int m_iBidCnt; + + + List m_PriceList = new List(); + + // key : time(hh:mm:ss) + SortedList m_1MinChart = new SortedList(); + SortedList m_5MAChart = new SortedList(); + + public void InsertPriceNode(int iTime, int iPrice) + { + PriceNode node = new PriceNode(iTime, iPrice); + m_PriceList.Add(node); + + Insert1MinChart(iTime, iPrice); + Insert5MinChart(iTime); + } + + public void Received() + { + int iTime = (int)m_StockCur.GetHeaderValue(18); + int iTime2 = m_StockCur.GetHeaderValue(3); + + m_iCurPrice = m_StockCur.GetHeaderValue(13); + m_iPrevClosing = m_iCurPrice - m_StockCur.GetHeaderValue(2); + m_iStartPrice = m_StockCur.GetHeaderValue(4); + m_iHighestPrice = m_StockCur.GetHeaderValue(5); + m_iVolume = m_StockCur.GetHeaderValue(9); + m_iBidPrice = m_StockCur.GetHeaderValue(8); + m_iBidCnt = 0; + + InsertPriceNode(iTime, m_iCurPrice); + } + + public int GetHour(int iTime) + { + return iTime / 10000; + } + + public int GetMinute(int iTime) + { + return (iTime / 100) % 100; + } + + public int GetSecond(int iTime) + { + return iTime % 100; + } + + public int GetTimeKey1Min(int iHour, int iMin, int iSecond) + { + return iHour*10000 + iMin*100 + iSecond; + } + + void Insert1MinChart(int iTime, int iPrice) + { + int iHour = GetHour(iTime); + int iMin = GetMinute(iTime); + int iSec = GetSecond(iTime); + + int iKey = GetTimeKey1Min(iHour, iMin, iSec); + + if (m_1MinChart.ContainsKey(iKey) == false) + { + CandleTick tick1 = new CandleTick(iTime, iPrice); + m_1MinChart.Add(iKey, tick1); + } + else + { + CandleTick tick1 = m_1MinChart[iKey]; + tick1.m_iTime = iTime; + tick1.m_iEnd = iPrice; + tick1.m_iLowest = Math.Min(tick1.m_iLowest, iPrice); + tick1.m_iHighest = Math.Max(tick1.m_iHighest, iPrice); + } + } + + public void MakeChart() + { + foreach (PriceNode node in m_PriceList) + { + int iTime = node.m_iTime; + int iPrice = node.m_iPrice; + + int iHour = GetHour(iTime); + int iMin = GetMinute(iTime); + int iSec = GetSecond(iTime); + + int iKey = GetTimeKey1Min(iHour, iMin, iSec); + + if (m_1MinChart.ContainsKey(iKey) == false) + { + CandleTick tick1 = new CandleTick(iTime, node.m_iPrice); + m_1MinChart.Add(iKey, tick1); + } + else + { + CandleTick tick1 = m_1MinChart[iKey]; + tick1.m_iTime = iTime; + tick1.m_iEnd = iPrice; + tick1.m_iLowest = Math.Min(tick1.m_iLowest, iPrice); + tick1.m_iHighest = Math.Max(tick1.m_iHighest, iPrice); + } + } + } + + bool IsIn5Min(int iBaseKey, int iKeyCheck) + { + int iBaseIdx = m_1MinChart.IndexOfKey(iBaseKey); + int iIdxCheck = m_1MinChart.IndexOfKey(iKeyCheck); + + return (iIdxCheck > iBaseIdx - 5 && iIdxCheck <= iBaseIdx); + } + + void Insert5MinChart(int iTime) + { + int iHour = GetHour(iTime); + int iMin = GetMinute(iTime); + int iSec = GetSecond(iTime); + + int iKey = GetTimeKey1Min(iHour, iMin, iSec); + MATick tick = null; + if (m_5MAChart.ContainsKey(iKey) == false) + tick = new MATick(iTime, 0); + else + tick = m_5MAChart[iKey]; + + int iIdx = m_1MinChart.IndexOfKey(iKey); + IEnumerable> Search = m_1MinChart.Where(r => IsIn5Min(iKey, r.Key)); + float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0; + tick.m_fMA = fMA; + + if(m_5MAChart.ContainsKey(iKey) == true) + m_5MAChart[iKey] = tick; + else + m_5MAChart.Add(iKey, tick); + } + + public void MakeMAChart() + { + foreach (KeyValuePair node in m_1MinChart) + { + int iTime = node.Key; + + int iHour = GetHour(iTime); + int iMin = GetMinute(iTime); + int iSec = GetSecond(iTime); + + int iKey = GetTimeKey1Min(iHour, iMin, iSec); + MATick tick = null; + if (m_5MAChart.ContainsKey(iKey) == false) + tick = new MATick(iTime, 0); + else + tick = m_5MAChart[iKey]; + + int iIdx = m_1MinChart.IndexOfKey(iKey); + IEnumerable> Search = m_1MinChart.Where(r => IsIn5Min(iKey, r.Key)); + float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0; + tick.m_fMA = fMA; + + m_5MAChart.Add(iKey, tick); + } + } + + public void PrintChart() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("======= 1 MINUTE CHART ======="); + + for(int i=0; i< m_1MinChart.Keys.Count; i++) + { + int iKey = m_1MinChart.Keys[i]; + CandleTick node1Min = m_1MinChart.Values[i]; + MATick node5MA = m_5MAChart.ContainsKey(iKey) ? m_5MAChart[iKey] : null; + + sb.AppendFormat("{0:######} : {1:###,###,###} ({2:###,###.###})\n", iKey, node1Min.m_iEnd, node5MA != null ? node5MA.m_fMA : 0); + } + + sb.AppendLine("======= END ======="); + Console.WriteLine(sb.ToString()); + } + + public bool IsUpSlope() + { + + return true; + } + } +} diff --git a/UlUtil.cs b/UlUtil.cs index 92c756a..34daac1 100644 --- a/UlUtil.cs +++ b/UlUtil.cs @@ -14,7 +14,7 @@ namespace upper_limit_crawler { //static string m_strLogServer = "http://mjjo53.us.to:8000"; - static CPUTILLib.CpCybos m_Util = new CPUTILLib.CpCybos(); + static CPUTILLib.CpCybos m_CPUtil = new CPUTILLib.CpCybos(); static TextBox m_tbLog = null; static string m_strLogFileName; static TimeSpan m_TimeDiff = TimeSpan.Zero; @@ -23,9 +23,6 @@ namespace upper_limit_crawler { m_tbLog = tbLog; - DateTime time = GetFastestNISTDate(); - m_TimeDiff = time - DateTime.Now; - if (Debugger.IsAttached == true) m_strLogFileName = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName+"\\"; m_strLogFileName += "log\\"; @@ -34,6 +31,12 @@ namespace upper_limit_crawler m_strLogFileName += "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".txt"; } + public static void SyncServerTime() + { + DateTime time = GetFastestNISTDate(); + m_TimeDiff = time - DateTime.Now; + } + public static DateTime GetCurTime() { return DateTime.Now + m_TimeDiff; @@ -198,17 +201,31 @@ namespace upper_limit_crawler public static int GetLimitRemainCountTrace() { - return m_Util.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST); + return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST); } public static int GetLimitRemainCountRQ() { - return m_Util.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST); + return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST); } public static int GetLimitRemainCountSB() { - return m_Util.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE); + return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE); } + + public static bool IsConnected() + { + return (m_CPUtil.IsConnect==1); + } + + public static void Reset() + { + m_CPUtil = null; + System.GC.Collect(0, GCCollectionMode.Forced); + System.GC.WaitForFullGCComplete(); + + m_CPUtil = new CPUTILLib.CpCybos(); + } } } diff --git a/upper-limit-crawler.csproj b/upper-limit-crawler.csproj index d310f9e..b52523c 100644 --- a/upper-limit-crawler.csproj +++ b/upper-limit-crawler.csproj @@ -57,6 +57,7 @@ + Form