자동 매도 추가

This commit is contained in:
2017-01-26 15:43:12 +09:00
parent 47c8a9532c
commit da9a59622b
13 changed files with 1127 additions and 207 deletions

5
.gitignore vendored
View File

@@ -1,2 +1,7 @@
bin/
obj/
.vs/
configure/
log/
publish/
*.user

494
AutoSeller.Designer.cs generated
View File

@@ -1,4 +1,4 @@
namespace AutoSeller
namespace AutoSellerNS
{
partial class AutoSeller
{
@@ -28,49 +28,53 @@
/// </summary>
private void InitializeComponent()
{
this.materialContextMenuStrip1 = new MaterialSkin.Controls.MaterialContextMenuStrip();
this.materialTabSelector1 = new MaterialSkin.Controls.MaterialTabSelector();
this.materialTabControl1 = new MaterialSkin.Controls.MaterialTabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.btUpdate = new MaterialSkin.Controls.MaterialRaisedButton();
this.btCybos = new MaterialSkin.Controls.MaterialRaisedButton();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.cbAccount = new System.Windows.Forms.ComboBox();
this.tbSubAccount = new MaterialSkin.Controls.MaterialSingleLineTextField();
this.btApply = new MaterialSkin.Controls.MaterialFlatButton();
this.materialLabel1 = new MaterialSkin.Controls.MaterialLabel();
this.tbBidCount = new MaterialSkin.Controls.MaterialSingleLineTextField();
this.materialLabel2 = new MaterialSkin.Controls.MaterialLabel();
this.btSell = new MaterialSkin.Controls.MaterialRaisedButton();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.lvList = new System.Windows.Forms.ListView();
this.tbLog = new System.Windows.Forms.RichTextBox();
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.chBookValue = ((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.Yield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tbLog = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.materialLabel2 = new MaterialSkin.Controls.MaterialLabel();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.lvCurPrice = new System.Windows.Forms.ListView();
this.chYield = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chMaxPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chCheckCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lvCurPrice = new AutoSellerNS.ListViewNF();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((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.materialLabel3 = new MaterialSkin.Controls.MaterialLabel();
this.materialTabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// materialContextMenuStrip1
//
this.materialContextMenuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.materialContextMenuStrip1.Depth = 0;
this.materialContextMenuStrip1.MouseState = MaterialSkin.MouseState.HOVER;
this.materialContextMenuStrip1.Name = "materialContextMenuStrip1";
this.materialContextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// materialTabSelector1
//
this.materialTabSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -80,7 +84,7 @@
this.materialTabSelector1.Location = new System.Drawing.Point(0, 64);
this.materialTabSelector1.MouseState = MaterialSkin.MouseState.HOVER;
this.materialTabSelector1.Name = "materialTabSelector1";
this.materialTabSelector1.Size = new System.Drawing.Size(1003, 49);
this.materialTabSelector1.Size = new System.Drawing.Size(1074, 49);
this.materialTabSelector1.TabIndex = 1;
this.materialTabSelector1.Text = "materialTabSelector1";
//
@@ -92,24 +96,191 @@
this.materialTabControl1.Controls.Add(this.tabPage1);
this.materialTabControl1.Controls.Add(this.tabPage2);
this.materialTabControl1.Depth = 0;
this.materialTabControl1.Location = new System.Drawing.Point(3, 116);
this.materialTabControl1.Location = new System.Drawing.Point(3, 115);
this.materialTabControl1.MouseState = MaterialSkin.MouseState.HOVER;
this.materialTabControl1.Name = "materialTabControl1";
this.materialTabControl1.SelectedIndex = 0;
this.materialTabControl1.Size = new System.Drawing.Size(997, 571);
this.materialTabControl1.Size = new System.Drawing.Size(1068, 572);
this.materialTabControl1.TabIndex = 2;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btSell);
this.tabPage1.Controls.Add(this.splitContainer2);
this.tabPage1.Controls.Add(this.btUpdate);
this.tabPage1.Controls.Add(this.btCybos);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(989, 545);
this.tabPage1.Size = new System.Drawing.Size(1060, 546);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Items";
this.tabPage1.UseVisualStyleBackColor = true;
//
// splitContainer2
//
this.splitContainer2.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.splitContainer2.IsSplitterFixed = true;
this.splitContainer2.Location = new System.Drawing.Point(3, 34);
this.splitContainer2.Name = "splitContainer2";
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.lvCurPrice);
this.splitContainer2.Size = new System.Drawing.Size(1054, 508);
this.splitContainer2.SplitterDistance = 804;
this.splitContainer2.TabIndex = 2;
this.splitContainer2.SizeChanged += new System.EventHandler(this.splitContainer2_SizeChanged);
//
// btUpdate
//
this.btUpdate.AutoSize = true;
this.btUpdate.Depth = 0;
this.btUpdate.Location = new System.Drawing.Point(74, 3);
this.btUpdate.MouseState = MaterialSkin.MouseState.HOVER;
this.btUpdate.Name = "btUpdate";
this.btUpdate.Primary = true;
this.btUpdate.Size = new System.Drawing.Size(68, 28);
this.btUpdate.TabIndex = 3;
this.btUpdate.Text = "Update";
this.btUpdate.UseVisualStyleBackColor = true;
this.btUpdate.Click += new System.EventHandler(this.btUpdate_Click);
//
// btCybos
//
this.btCybos.AutoSize = true;
this.btCybos.Depth = 0;
this.btCybos.Location = new System.Drawing.Point(3, 3);
this.btCybos.MouseState = MaterialSkin.MouseState.HOVER;
this.btCybos.Name = "btCybos";
this.btCybos.Primary = true;
this.btCybos.Size = new System.Drawing.Size(66, 28);
this.btCybos.TabIndex = 3;
this.btCybos.Text = "Cybos";
this.btCybos.UseVisualStyleBackColor = true;
this.btCybos.Click += new System.EventHandler(this.btCybos_Click);
//
// tabPage2
//
this.tabPage2.BackColor = System.Drawing.Color.White;
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.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1060, 546);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Preference";
//
// cbAccount
//
this.cbAccount.FormattingEnabled = true;
this.cbAccount.Location = new System.Drawing.Point(25, 62);
this.cbAccount.Name = "cbAccount";
this.cbAccount.Size = new System.Drawing.Size(121, 20);
this.cbAccount.TabIndex = 0;
//
// tbSubAccount
//
this.tbSubAccount.Depth = 0;
this.tbSubAccount.Hint = "";
this.tbSubAccount.Location = new System.Drawing.Point(154, 62);
this.tbSubAccount.MouseState = MaterialSkin.MouseState.HOVER;
this.tbSubAccount.Name = "tbSubAccount";
this.tbSubAccount.PasswordChar = '\0';
this.tbSubAccount.SelectedText = "";
this.tbSubAccount.SelectionLength = 0;
this.tbSubAccount.SelectionStart = 0;
this.tbSubAccount.Size = new System.Drawing.Size(25, 23);
this.tbSubAccount.TabIndex = 1;
this.tbSubAccount.Text = "10";
this.tbSubAccount.UseSystemPasswordChar = false;
//
// btApply
//
this.btApply.AutoSize = true;
this.btApply.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btApply.Depth = 0;
this.btApply.Location = new System.Drawing.Point(844, 483);
this.btApply.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6);
this.btApply.MinimumSize = new System.Drawing.Size(120, 36);
this.btApply.MouseState = MaterialSkin.MouseState.HOVER;
this.btApply.Name = "btApply";
this.btApply.Primary = false;
this.btApply.Size = new System.Drawing.Size(120, 36);
this.btApply.TabIndex = 2;
this.btApply.Text = "적용하기";
this.btApply.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btApply.UseVisualStyleBackColor = true;
this.btApply.Click += new System.EventHandler(this.btApply_Click);
//
// materialLabel1
//
this.materialLabel1.AutoSize = true;
this.materialLabel1.Depth = 0;
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(62, 18);
this.materialLabel1.TabIndex = 3;
this.materialLabel1.Text = "Account";
//
// tbBidCount
//
this.tbBidCount.Depth = 0;
this.tbBidCount.Hint = "";
this.tbBidCount.Location = new System.Drawing.Point(116, 144);
this.tbBidCount.MouseState = MaterialSkin.MouseState.HOVER;
this.tbBidCount.Name = "tbBidCount";
this.tbBidCount.PasswordChar = '\0';
this.tbBidCount.SelectedText = "";
this.tbBidCount.SelectionLength = 0;
this.tbBidCount.SelectionStart = 0;
this.tbBidCount.Size = new System.Drawing.Size(30, 23);
this.tbBidCount.TabIndex = 4;
this.tbBidCount.Text = "5";
this.tbBidCount.UseSystemPasswordChar = false;
//
// materialLabel2
//
this.materialLabel2.AutoSize = true;
this.materialLabel2.Depth = 0;
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(21, 18);
this.materialLabel2.TabIndex = 5;
this.materialLabel2.Text = "회";
//
// btSell
//
this.btSell.AutoSize = true;
this.btSell.Depth = 0;
this.btSell.Location = new System.Drawing.Point(148, 3);
this.btSell.MouseState = MaterialSkin.MouseState.HOVER;
this.btSell.Name = "btSell";
this.btSell.Primary = true;
this.btSell.Size = new System.Drawing.Size(68, 28);
this.btSell.TabIndex = 4;
this.btSell.Text = "Sell";
this.btSell.UseVisualStyleBackColor = true;
this.btSell.Click += new System.EventHandler(this.btSell_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -119,183 +290,194 @@
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.lvList);
this.splitContainer1.Panel1.Controls.Add(this.lvItems);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tbLog);
this.splitContainer1.Size = new System.Drawing.Size(738, 539);
this.splitContainer1.SplitterDistance = 375;
this.splitContainer1.Size = new System.Drawing.Size(804, 508);
this.splitContainer1.SplitterDistance = 353;
this.splitContainer1.TabIndex = 1;
//
// lvList
//
this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chCodeName,
this.chCurPrice,
this.chBookValue,
this.chCount,
this.chCapitalGains,
this.chAssessedValue,
this.chValuation,
this.Yield});
this.lvList.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvList.Location = new System.Drawing.Point(0, 0);
this.lvList.Name = "lvList";
this.lvList.Size = new System.Drawing.Size(738, 375);
this.lvList.TabIndex = 0;
this.lvList.UseCompatibleStateImageBehavior = false;
this.lvList.View = System.Windows.Forms.View.Details;
//
// chCodeName
//
this.chCodeName.Text = "종목명";
//
// chCurPrice
//
this.chCurPrice.Text = "현재가";
//
// chBookValue
//
this.chBookValue.Text = "장부가";
//
// chCount
//
this.chCount.Text = "잔고수량";
//
// chCapitalGains
//
this.chCapitalGains.Text = "손익단가";
//
// chAssessedValue
//
this.chAssessedValue.Text = "평가금액";
//
// chValuation
//
this.chValuation.Text = "평가손익";
//
// Yield
//
this.Yield.Text = "수익률";
//
// tbLog
//
this.tbLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbLog.Location = new System.Drawing.Point(0, 0);
this.tbLog.Multiline = true;
this.tbLog.Name = "tbLog";
this.tbLog.Size = new System.Drawing.Size(738, 160);
this.tbLog.Size = new System.Drawing.Size(804, 151);
this.tbLog.TabIndex = 0;
this.tbLog.Text = "";
//
// tabPage2
// lvItems
//
this.tabPage2.Controls.Add(this.materialLabel2);
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(776, 545);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Preference";
this.tabPage2.UseVisualStyleBackColor = true;
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.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(804, 353);
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);
//
// materialLabel2
// chCode
//
this.materialLabel2.AutoSize = true;
this.materialLabel2.Depth = 0;
this.materialLabel2.Font = new System.Drawing.Font("Roboto", 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(339, 156);
this.materialLabel2.MouseState = MaterialSkin.MouseState.HOVER;
this.materialLabel2.Name = "materialLabel2";
this.materialLabel2.Size = new System.Drawing.Size(108, 19);
this.materialLabel2.TabIndex = 0;
this.materialLabel2.Text = "materialLabel2";
this.chCode.Text = "코드";
this.chCode.Width = 77;
//
// splitContainer2
// chCodeName
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.IsSplitterFixed = true;
this.splitContainer2.Location = new System.Drawing.Point(3, 3);
this.splitContainer2.Name = "splitContainer2";
this.chCodeName.Text = "종목명";
this.chCodeName.Width = 86;
//
// splitContainer2.Panel1
// chCurPrice
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
this.chCurPrice.Text = "현재가";
this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.chCurPrice.Width = 71;
//
// splitContainer2.Panel2
// chCount
//
this.splitContainer2.Panel2.Controls.Add(this.lvCurPrice);
this.splitContainer2.Size = new System.Drawing.Size(983, 539);
this.splitContainer2.SplitterDistance = 738;
this.splitContainer2.TabIndex = 2;
this.splitContainer2.SizeChanged += new System.EventHandler(this.splitContainer2_SizeChanged);
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;
//
// chCheckCount
//
this.chCheckCount.Text = "조건횟수";
this.chCheckCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lvCurPrice
//
this.lvCurPrice.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3});
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(241, 539);
this.lvCurPrice.Size = new System.Drawing.Size(246, 508);
this.lvCurPrice.TabIndex = 0;
this.lvCurPrice.UseCompatibleStateImageBehavior = false;
this.lvCurPrice.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "매도잔량";
this.columnHeader1.Width = 96;
this.columnHeader1.Width = 10;
//
// columnHeader2
// chAskCount
//
this.columnHeader2.Text = "호가";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.chAskCount.Text = "매도잔량";
this.chAskCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.chAskCount.Width = 75;
//
// columnHeader3
// chCallPrice
//
this.columnHeader3.Text = "매수잔량";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 81;
this.chCallPrice.Text = "호가";
this.chCallPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// Material
// chBidCount
//
this.chBidCount.Text = "매수잔량";
this.chBidCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.chBidCount.Width = 75;
//
// materialLabel3
//
this.materialLabel3.AutoSize = true;
this.materialLabel3.Depth = 0;
this.materialLabel3.Font = new System.Drawing.Font("Roboto", 11F);
this.materialLabel3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.materialLabel3.Location = new System.Drawing.Point(6, 524);
this.materialLabel3.MouseState = MaterialSkin.MouseState.HOVER;
this.materialLabel3.Name = "materialLabel3";
this.materialLabel3.Size = new System.Drawing.Size(165, 19);
this.materialLabel3.TabIndex = 6;
this.materialLabel3.Text = "Version : 2017.01.26.14";
//
// AutoSeller
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1003, 690);
this.ClientSize = new System.Drawing.Size(1074, 690);
this.Controls.Add(this.materialTabSelector1);
this.Controls.Add(this.materialTabControl1);
this.Name = "Material";
this.Text = "Material";
this.Name = "AutoSeller";
this.Text = "AutoSeller";
this.materialTabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
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.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.tabPage1.PerformLayout();
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private MaterialSkin.Controls.MaterialContextMenuStrip materialContextMenuStrip1;
private MaterialSkin.Controls.MaterialTabSelector materialTabSelector1;
private MaterialSkin.Controls.MaterialTabControl materialTabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private MaterialSkin.Controls.MaterialLabel materialLabel2;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.ListView lvList;
private ListViewNF lvItems;
private System.Windows.Forms.ColumnHeader chCodeName;
private System.Windows.Forms.ColumnHeader chCurPrice;
private System.Windows.Forms.ColumnHeader chBookValue;
@@ -303,12 +485,26 @@
private System.Windows.Forms.ColumnHeader chCapitalGains;
private System.Windows.Forms.ColumnHeader chAssessedValue;
private System.Windows.Forms.ColumnHeader chValuation;
private System.Windows.Forms.ColumnHeader Yield;
private System.Windows.Forms.TextBox tbLog;
private System.Windows.Forms.ColumnHeader chYield;
private System.Windows.Forms.RichTextBox tbLog;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.ListView lvCurPrice;
private ListViewNF lvCurPrice;
private System.Windows.Forms.ColumnHeader chAskCount;
private System.Windows.Forms.ColumnHeader chCallPrice;
private System.Windows.Forms.ColumnHeader chBidCount;
private MaterialSkin.Controls.MaterialRaisedButton btCybos;
private MaterialSkin.Controls.MaterialRaisedButton btUpdate;
private System.Windows.Forms.ColumnHeader chCode;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private MaterialSkin.Controls.MaterialFlatButton btApply;
private MaterialSkin.Controls.MaterialSingleLineTextField tbSubAccount;
private System.Windows.Forms.ComboBox cbAccount;
private MaterialSkin.Controls.MaterialLabel materialLabel1;
private MaterialSkin.Controls.MaterialLabel materialLabel2;
private MaterialSkin.Controls.MaterialSingleLineTextField tbBidCount;
private MaterialSkin.Controls.MaterialRaisedButton btSell;
private System.Windows.Forms.ColumnHeader chMaxPrice;
private System.Windows.Forms.ColumnHeader chCheckCount;
private MaterialSkin.Controls.MaterialLabel materialLabel3;
}
}

View File

@@ -10,15 +10,62 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoSeller
namespace AutoSellerNS
{
public partial class AutoSeller : MaterialForm
{
public class ITEM
{
public string m_strCodeName;
public string m_strCode;
public int m_iItemCnt;
public long m_iAssessedValue;
public long m_iValuationGains;
public double m_dYield;
public int m_iAvailableQuantity;
public double m_dBookUnitPrice;
public long m_iProfitUnitPrice;
public int m_iSellableCnt;
public int m_iCurPrice;
}
int m_iCurPricePanelWith;
CybosHelper m_CybosHelper = null;
List<ITEM> m_Items = new List<ITEM>();
string m_strSelectedCode = "";
bool m_bSell = false;
public AutoSeller()
{
InitializeComponent();
Util.SetLogView(tbLog);
Config.Init();
btUpdate.Enabled = false;
btSell.Enabled = false;
for (int i = 0; i < 21; i++)
{
lvCurPrice.Items.Add(new ListViewItem(new string[] { "", "", "", "" }));
lvCurPrice.Items[i].UseItemStyleForSubItems = false;
if (i < 10)
{
lvCurPrice.Items[i].SubItems[chAskCount.Index].BackColor = Color.FromArgb(215, 233, 255);
lvCurPrice.Items[i].SubItems[chCallPrice.Index].BackColor = Color.FromArgb(215, 233, 255);
}
else if (i > 10)
{
lvCurPrice.Items[i].SubItems[chBidCount.Index].BackColor = Color.FromArgb(255, 227, 227);
lvCurPrice.Items[i].SubItems[chCallPrice.Index].BackColor = Color.FromArgb(255, 227, 227);
}
}
lvCurPrice.Items[10].SubItems[chAskCount.Index].Text = "현재가";
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Font = new Font(lvCurPrice.Items[0].SubItems[0].Font, FontStyle.Bold);
m_CybosHelper = new CybosHelper(this);
m_iCurPricePanelWith = splitContainer2.Panel2.Width;
@@ -28,10 +75,267 @@ namespace AutoSeller
materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
}
public void SetAccountList(string[] aAccountList)
{
cbAccount.Items.Clear();
cbAccount.Items.AddRange(aAccountList);
foreach (var account in aAccountList)
{
if (account == Config.GetAccount())
{
cbAccount.SelectedItem = account;
break;
}
}
}
private void splitContainer2_SizeChanged(object sender, EventArgs e)
{
int iDist = Math.Min(Math.Max(splitContainer2.Width-m_iCurPricePanelWith, splitContainer2.Panel1MinSize), splitContainer2.Width-splitContainer2.Panel2MinSize); ;
splitContainer2.SplitterDistance = iDist;
//int iDist = Math.Min(Math.Max(splitContainer2.Width-m_iCurPricePanelWith, splitContainer2.Panel1MinSize), splitContainer2.Width-splitContainer2.Panel2MinSize);
//if(iDist >= splitContainer2.Panel1MinSize && iDist <= splitContainer2.Width - splitContainer2.Panel2MinSize)
// splitContainer2.SplitterDistance = iDist;
}
private void btCybos_Click(object sender, EventArgs e)
{
m_CybosHelper.InitCybos();
btCybos.Primary = false;
btCybos.Enabled = false;
btUpdate.Enabled = true;
btSell.Enabled = true;
btUpdate_Click(null, null);
}
private void AddItem(ITEM Item)
{
m_Items.Add(Item);
if(lvItems.InvokeRequired)
{
lvItems.Invoke(new Action(() => {
lvItems.Items.Add(new ListViewItem(new string[] {
Item.m_strCode,
Item.m_strCodeName,
string.Format("{0:n0}", Item.m_iCurPrice),
string.Format("{0:n0}", Item.m_iAvailableQuantity),
string.Format("{0:n2}", Item.m_dBookUnitPrice),
string.Format("{0:n0}", Item.m_iProfitUnitPrice),
string.Format("{0:n0}", Item.m_iAssessedValue),
string.Format("{0:n0}", Item.m_iValuationGains),
string.Format("{0:n2}", Item.m_dYield),
"",
"",
}));
var listviewItem = lvItems.Items[lvItems.Items.Count - 1];
lvItems.Items[lvItems.Items.Count - 1].UseItemStyleForSubItems = false;
lvItems.Items[lvItems.Items.Count - 1].SubItems[chValuation.Index].ForeColor = (Item.m_iValuationGains > 0) ? Color.Red : (Item.m_iValuationGains < 0) ? Color.Blue : Color.Black;
lvItems.Items[lvItems.Items.Count - 1].SubItems[chYield.Index].ForeColor = (Item.m_dYield > 0) ? Color.Red : (Item.m_dYield < 0) ? Color.Blue : Color.Black;
m_CybosHelper.Subscribe(Item);
}));
}
else
{
lvItems.Items.Add(new ListViewItem(new string[] {
Item.m_strCode,
Item.m_strCodeName,
string.Format("{0:n0}", Item.m_iCurPrice),
string.Format("{0:n0}", Item.m_iAvailableQuantity),
string.Format("{0:n2}", Item.m_dBookUnitPrice),
string.Format("{0:n0}", Item.m_iProfitUnitPrice),
string.Format("{0:n0}", Item.m_iAssessedValue),
string.Format("{0:n0}", Item.m_iValuationGains),
string.Format("{0:n2}", Item.m_dYield),
"",
"",
}));
var listviewItem = lvItems.Items[lvItems.Items.Count - 1];
lvItems.Items[lvItems.Items.Count - 1].UseItemStyleForSubItems = false;
lvItems.Items[lvItems.Items.Count - 1].SubItems[chValuation.Index].ForeColor = (Item.m_iValuationGains > 0) ? Color.Red : (Item.m_iValuationGains < 0) ? Color.Blue : Color.Black;
lvItems.Items[lvItems.Items.Count - 1].SubItems[chYield.Index].ForeColor = (Item.m_dYield > 0) ? Color.Red : (Item.m_dYield < 0) ? Color.Blue : Color.Black;
m_CybosHelper.Subscribe(Item);
}
}
private void btUpdate_Click(object sender, EventArgs e)
{
var Items = m_CybosHelper.UpdateItems();
m_Items.Clear();
lvItems.Items.Clear();
foreach (var Item in Items)
AddItem(Item);
}
public void UpdateItem(string strCode, string strCodeName, bool bBid, int iConclusionCnt, int iRemainCnt, int iBookValue)
{
btUpdate_Click(null, null);
//if(lvList.InvokeRequired)
//{
//}
//else
//{
// ListViewItem Item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode);
// if(Item == default(ListViewItem) && iRemainCnt > 0)
// {
// // 아이템 추가
// }
// else
// {
// // 갱신
// Item.SubItems[chCount.Index].Text = string.Format("{0:n0}", iRemainCnt);
// Item.SubItems[chBookValue.Index].Text = string.Format("{0:n2}", iBookValue);
// }
//}
}
private void btSell_Click(object sender, EventArgs e)
{
btSell.Primary = !btSell.Primary;
m_bSell = (btSell.Primary == false);
}
public bool IsSelling()
{
return m_bSell;
}
public void OnReceivedCurPrice(string strCode, int iPrice, int iMaxPrice, int iCheckCount)
{
ITEM Item = m_Items.FirstOrDefault(s => s.m_strCode == strCode);
if (Item == default(ITEM))
return;
Item.m_iCurPrice = iPrice;
Item.m_iAssessedValue = (int)(iPrice * Item.m_iAvailableQuantity * 99.94 / 100);
Item.m_dYield = (Item.m_iCurPrice - Item.m_iProfitUnitPrice) * 100 / (double)Item.m_iProfitUnitPrice;
if (lvItems.InvokeRequired)
{
lvItems.Invoke(new Action(() =>
{
ListViewItem row = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode);
if (row == default(ListViewItem))
return;
row.SubItems[chCurPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice);
row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue);
row.SubItems[chYield.Index].Text = string.Format("{0:n2}", Item.m_dYield);
row.SubItems[chMaxPrice.Index].Text = string.Format("{0:n0}", iMaxPrice);
row.SubItems[chCheckCount.Index].Text = string.Format("{0:n0}", iCheckCount);
}));
}
else
{
ListViewItem row = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode);
if (row == default(ListViewItem))
return;
row.SubItems[chCurPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice);
row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue);
row.SubItems[chYield.Index].Text = string.Format("{0:n2}", Item.m_dYield);
row.SubItems[chMaxPrice.Index].Text = string.Format("{0:n0}", iMaxPrice);
row.SubItems[chCheckCount.Index].Text = string.Format("{0:n0}", iCheckCount);
}
if(strCode == m_strSelectedCode)
{
if (lvCurPrice.InvokeRequired)
{
lvCurPrice.Invoke(new Action(() => {
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice);
}));
}
else
{
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice);
}
}
}
public void OnReceivedCall(string strCode, int[] aiBidPrice, int[] aiBidCount, int[] aiAskPrice, int[] aiAskCount)
{
if (strCode != m_strSelectedCode)
return;
ITEM Item = m_Items.FirstOrDefault(s => s.m_strCode == strCode);
if (Item == default(ITEM))
return;
if (lvCurPrice.InvokeRequired)
{
lvCurPrice.Invoke(new Action(() => {
for (int i = 0; i < 10; i++)
{
lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9-i]);
lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9-i]);
}
for (int i = 0; i < 10; i++)
{
lvCurPrice.Items[11 + i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]);
lvCurPrice.Items[11 + i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]);
}
}));
}
else
{
for (int i = 0; i < 10; i++)
{
lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9-i]);
lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9-i]);
}
for (int i = 0; i < 10; i++)
{
lvCurPrice.Items[11+i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]);
lvCurPrice.Items[11+i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]);
}
}
}
public int GetSellableCount(string strCode)
{
ITEM Item = m_Items.FirstOrDefault(s => s.m_strCode == strCode);
if(Item == default(ITEM))
return 0;
return Item.m_iSellableCnt;
}
private void lvList_SelectedIndexChanged(object sender, EventArgs e)
{
if (lvItems.SelectedItems.Count <= 0)
return;
string strCode = lvItems.SelectedItems[0].SubItems[chCode.Index].Text;
CybosHelper.STOCK_CUR_ITEM Item = m_CybosHelper.GetItem(strCode);
if (Item == null)
return;
m_strSelectedCode = strCode;
OnReceivedCall(strCode, Item.m_aiBidPrice, Item.m_aiBidCount, Item.m_aiAskPrice, Item.m_aiAskCount);
//OnReceivedCurPrice(strCode, Item.m_iCurPrice);
}
private void btApply_Click(object sender, EventArgs e)
{
string strAccount = (string)cbAccount.SelectedItem;
string strSubAccount = tbSubAccount.Text;
Config.SetAccount(strAccount, strSubAccount);
int iBidCount = 0;
int.TryParse(tbBidCount.Text, out iBidCount);
Config.SetBidCount(iBidCount);
}
}
}

View File

@@ -12,6 +12,21 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -32,6 +47,21 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaterialSkin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll</HintPath>
@@ -50,6 +80,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="CybosHelper.cs" />
<Compile Include="AutoSeller.cs">
<SubType>Form</SubType>
@@ -57,6 +88,9 @@
<Compile Include="AutoSeller.Designer.cs">
<DependentUpon>AutoSeller.cs</DependentUpon>
</Compile>
<Compile Include="ListViewNF.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Util.cs" />
@@ -73,6 +107,9 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -151,7 +188,28 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if NOT "$(ConfigurationName)" == "Release" (goto :nocopy)
copy $(TargetPath) $(ProjectDir)publish\ /y
copy $(TargetDir)*.dll $(ProjectDir)publish\ /y
:nocopy
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@@ -117,7 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="materialContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

89
Config.cs Normal file
View File

@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace AutoSellerNS
{
static class Config
{
static Dictionary<string, string> m_Data = new Dictionary<string, string>();
static Random m_Random = new Random();
public static void Init()
{
m_Data.Add("account", "");
m_Data.Add("sub-account", "");
m_Data.Add("bid-count", "5");
Load();
}
static void Load()
{
string strPath = Util.GetConfigPath()+"/config.ini";
if(File.Exists(strPath) == false)
return;
string[] aLines = File.ReadAllLines(strPath);
foreach(string strLine in aLines)
{
if(strLine.Trim().Length <= 0)
continue;
string[] aTokens = strLine.Trim().Split('=');
if(aTokens.Length < 2)
continue;
if(m_Data.ContainsKey(aTokens[0]) == true)
m_Data[aTokens[0]] = aTokens[1];
else
m_Data.Add(aTokens[0], aTokens[1]);
}
}
static void Save()
{
string strContents = "";
foreach(KeyValuePair<string, string> pair in m_Data)
strContents += pair.Key + "=" + pair.Value + Environment.NewLine;
string strPath = Util.GetConfigPath()+"/config.ini";
File.WriteAllText(strPath, strContents, new UTF8Encoding(true));
}
public static void SetAccount(string strAccount, string strAccountSub)
{
m_Data["account"] = strAccount;
m_Data["sub-account"] = strAccountSub;
Save();
}
public static string GetAccount()
{
return m_Data["account"];
}
public static string GetSubAccount()
{
return m_Data["sub-account"];
}
public static void SetBidCount(int iCount)
{
m_Data["bid-count"] = iCount.ToString();
Save();
}
public static int GetBidCount()
{
int iCount = 0;
int.TryParse(m_Data["bid-count"], out iCount);
return iCount;
}
}
}

View File

@@ -4,62 +4,202 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutoSeller
namespace AutoSellerNS
{
class CybosHelper
{
public class STOCK_CUR_ITEM
{
public AutoSeller m_Listener = null;
public CybosHelper m_CybosHelper = null;
public string m_strCode;
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_iCurPrice = 0;
public int m_iMaxPrice = 0;
public int m_iCheckCount = 0;
public void OnRecievedPrice()
{
m_iCurPrice = m_StockCur.GetHeaderValue(13);
m_iMaxPrice = Math.Max(m_iCurPrice, m_iMaxPrice);
int iAskPrice = m_StockCur.GetHeaderValue(7);
int iBidPrice = m_StockCur.GetHeaderValue(8);
if (m_iCurPrice <= iBidPrice)
m_iCheckCount++;
else
m_iCheckCount = 0;
if (m_iCheckCount >= Config.GetBidCount() && m_Listener.IsSelling() == true)
m_CybosHelper.SellItem(m_strCode, m_iCurPrice, m_Listener.GetSellableCount(m_strCode));
m_Listener.OnReceivedCurPrice(m_strCode, m_iCurPrice, m_iMaxPrice, m_iCheckCount);
}
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, 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();
bool m_bInitialized = false;
public CybosHelper()
CPTRADELib.CpTd6033 m_6033 = new CPTRADELib.CpTd6033();
Dictionary<string, STOCK_CUR_ITEM> m_aStockCur = new Dictionary<string, STOCK_CUR_ITEM>();
public CybosHelper(AutoSeller Listener)
{
short iResult = m_CPUtil.TradeInit();
switch(iResult)
{
case -1:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 오류");
break;
case 0:
m_bInitialized = true;
Util.Log(Util.LOG_TYPE.VERVOSE, "[TradeInit] 로그인 되었습니다");
break;
case 1:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 업무 키 입력 잘못됨");
break;
case 2:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 계좌 비밀번호가 잘못되었습니다");
break;
case 3:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 취소되었습니다");
break;
}
string strAccount = m_CPUtil.AccountNumber[0];
m_CpConclusion.Received += CpConclusion_Received;
m_CpConclusion.Subscribe();
m_Listener = Listener;
}
public string[] GetAccounts()
public void InitCybos()
{
short iResult = m_CPUtil.TradeInit();
switch (iResult)
{
case -1:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 오류");
break;
case 0:
Util.Log(Util.LOG_TYPE.VERVOSE, "[TradeInit] 로그인 되었습니다");
break;
case 1:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 업무 키 입력 잘못됨");
break;
case 2:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 계좌 비밀번호가 잘못되었습니다");
break;
case 3:
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 취소되었습니다");
break;
}
m_Listener.SetAccountList(m_CPUtil.AccountNumber);
m_CpConclusion.Received += CpConclusion_Received;
m_CpConclusion.Subscribe();
}
public List<AutoSeller.ITEM> UpdateItems()
{
return m_CPUtil.AccountNumber;
List<AutoSeller.ITEM> aItems = new List<AutoSeller.ITEM>();
if (Config.GetAccount() == "")
return aItems;
m_6033.SetInputValue(0, Config.GetAccount());
m_6033.SetInputValue(1, Config.GetSubAccount());
m_6033.BlockRequest2(1);
string strCodeList = "";
int iCount = m_6033.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_strCode = m_6033.GetDataValue(12, i);
Item.m_iItemCnt = m_6033.GetDataValue(7, i);
Item.m_iAssessedValue = m_6033.GetDataValue(9, i);
Item.m_iValuationGains = m_6033.GetDataValue(10, i);
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_iSellableCnt = m_6033.GetDataValue(15, i);
if (strCodeList.Length > 0)
strCodeList += ",";
strCodeList += Item.m_strCode;
aItems.Add(Item);
}
if (strCodeList.Length > 0)
{
DSCBO1Lib.StockMst2 StockMst = new DSCBO1Lib.StockMst2();
StockMst.SetInputValue(0, strCodeList);
StockMst.BlockRequest2(0);
int iCnt = StockMst.GetHeaderValue(0);
for (int i = 0; i < iCnt; i++)
{
string strCode = StockMst.GetDataValue(0, i);
int iPrice = StockMst.GetDataValue(3, i);
AutoSeller.ITEM Item = aItems.FirstOrDefault(s => s.m_strCode == strCode);
if (Item != default(AutoSeller.ITEM))
Item.m_iCurPrice = iPrice;
}
}
return aItems;
}
private void CpConclusion_Received()
{
string strCodeName = m_CpConclusion.GetHeaderValue(2);
int iCount = m_CpConclusion.GetHeaderValue(3);
int iPrice = m_CpConclusion.GetHeaderValue(4);
string strBuyOrSell = m_CpConclusion.GetHeaderValue(12);
string strType = m_CpConclusion.GetHeaderValue(14);
int iType = 0;
int.TryParse(strType, out iType);
bool bBid = (m_CpConclusion.GetHeaderValue(12) == "2");
string strCode = m_CpConclusion.GetHeaderValue(9);
string strCodeName = m_CpConclusion.GetHeaderValue(2);
int iConclusionCnt = m_CpConclusion.GetHeaderValue(3);
int iPrice = m_CpConclusion.GetHeaderValue(4);
string strCancel = m_CpConclusion.GetHeaderValue(16);
int iBookValue = m_CpConclusion.GetHeaderValue(21);
int iRemainCnt = m_CpConclusion.GetHeaderValue(23);
string strBidOrAsk = bBid ? "매수" : "매도";
switch (iType)
{
case 1: // 체결
m_Listener.UpdateItem(strCode, strCodeName, bBid, iConclusionCnt, iRemainCnt, iBookValue);
Util.Log(bBid?Util.LOG_TYPE.BUY:Util.LOG_TYPE.SELL, string.Format("{0}:{1} {2} 체결 ({3:n0}원 {4}주)", strCodeName, strCode, strBidOrAsk, iPrice, iConclusionCnt));
break;
case 2: // 확인
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("{0}:{1} {2} 확인", strCodeName, strCode, strBidOrAsk));
break;
case 3: // 거부
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("{0}:{1} {2} 거부", strCodeName, strCode, strBidOrAsk));
break;
case 4: // 접수
Util.Log(bBid ? Util.LOG_TYPE.BUY : Util.LOG_TYPE.SELL, string.Format("{0}:{1} {2} 접수 ({3:n0}원 {4}주)", strCodeName, strCode, strBidOrAsk, iPrice, iConclusionCnt));
break;
}
}
public int GetLimitRemainCountTrade()
@@ -81,5 +221,48 @@ namespace AutoSeller
{
return (m_CPCybos.IsConnect==1);
}
public STOCK_CUR_ITEM GetItem(string strCode)
{
if (m_aStockCur.ContainsKey(strCode) == false)
return null;
return m_aStockCur[strCode];
}
public void Subscribe(AutoSeller.ITEM Item)
{
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_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);
}
}
public void SellItem(string strCode, int iPrice, int iCnt)
{
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(5, 0);
Td0311.SetInputValue(8, "03");
Td0311.BlockRequest2(0);
}
}
}

27
ListViewNF.cs Normal file
View File

@@ -0,0 +1,27 @@
using System.Windows.Forms;
namespace AutoSellerNS
{
public partial class ListViewNF : ListView
{
public ListViewNF()
{
//Activate double buffering
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
//Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
}
protected override void OnNotifyMessage(Message m)
{
//Filter out the WM_ERASEBKGND message
if (m.Msg != 0x14)
{
base.OnNotifyMessage(m);
}
}
}
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoSeller
namespace AutoSellerNS
{
static class Program
{

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoSeller.Properties
namespace AutoSellerNS.Properties
{

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoSeller.Properties
namespace AutoSellerNS.Properties
{

70
Properties/app.manifest Normal file
View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

15
Util.cs
View File

@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoSeller
namespace AutoSellerNS
{
static class Util
{
@@ -17,13 +17,8 @@ namespace AutoSeller
DEBUG,
ERROR,
VERVOSE,
NEGATIVE,
POSITIVE,
MANUAL_KEYWORD,
MANUAL_CODE,
DUPLICATED,
DENIAL,
BUY,
SELL,
}
static string m_strLogFile = null;
static RichTextBox m_LogBox = null;
@@ -61,13 +56,9 @@ namespace AutoSeller
case LOG_TYPE.VERVOSE:
LogColor = Color.Black;
break;
case LOG_TYPE.NEGATIVE:
case LOG_TYPE.DENIAL:
case LOG_TYPE.DUPLICATED:
case LOG_TYPE.SELL:
LogColor = Color.Blue;
break;
case LOG_TYPE.POSITIVE:
case LOG_TYPE.MANUAL_KEYWORD:
case LOG_TYPE.BUY:
LogColor = Color.Red;
break;