auto cancel

This commit is contained in:
2018-10-16 19:55:00 +09:00
parent 7197272479
commit 22b38609cd
3 changed files with 98 additions and 4 deletions

68
AutoSeller.Designer.cs generated
View File

@@ -86,7 +86,10 @@
this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tabPage3 = new System.Windows.Forms.TabPage();
this.cbMockTrading = new System.Windows.Forms.CheckBox();
this.materialLabel19 = new MaterialSkin.Controls.MaterialLabel();
this.tbAutoCancelDelay = new MaterialSkin.Controls.MaterialSingleLineTextField();
this.cbAutoCancel = new MaterialSkin.Controls.MaterialCheckBox();
this.cbMockTrading = new MaterialSkin.Controls.MaterialCheckBox();
this.materialLabel18 = new MaterialSkin.Controls.MaterialLabel();
this.tbCFIgnorePrice = new MaterialSkin.Controls.MaterialSingleLineTextField();
this.materialLabel17 = new MaterialSkin.Controls.MaterialLabel();
@@ -706,6 +709,9 @@
// tabPage3
//
this.tabPage3.BackColor = System.Drawing.Color.White;
this.tabPage3.Controls.Add(this.materialLabel19);
this.tabPage3.Controls.Add(this.tbAutoCancelDelay);
this.tabPage3.Controls.Add(this.cbAutoCancel);
this.tabPage3.Controls.Add(this.cbMockTrading);
this.tabPage3.Controls.Add(this.materialLabel18);
this.tabPage3.Controls.Add(this.tbCFIgnorePrice);
@@ -748,12 +754,63 @@
this.tabPage3.TabIndex = 1;
this.tabPage3.Text = "Preference";
//
// materialLabel19
//
this.materialLabel19.AutoSize = true;
this.materialLabel19.Depth = 0;
this.materialLabel19.Font = new System.Drawing.Font("Roboto", 11F);
this.materialLabel19.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.materialLabel19.Location = new System.Drawing.Point(80, 504);
this.materialLabel19.MouseState = MaterialSkin.MouseState.HOVER;
this.materialLabel19.Name = "materialLabel19";
this.materialLabel19.Size = new System.Drawing.Size(124, 19);
this.materialLabel19.TabIndex = 41;
this.materialLabel19.Text = "초 후 미체결 매수 취소";
//
// tbAutoCancelDelay
//
this.tbAutoCancelDelay.Depth = 0;
this.tbAutoCancelDelay.Hint = "";
this.tbAutoCancelDelay.Location = new System.Drawing.Point(52, 503);
this.tbAutoCancelDelay.MouseState = MaterialSkin.MouseState.HOVER;
this.tbAutoCancelDelay.Name = "tbAutoCancelDelay";
this.tbAutoCancelDelay.PasswordChar = '\0';
this.tbAutoCancelDelay.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.tbAutoCancelDelay.SelectedText = "";
this.tbAutoCancelDelay.SelectionLength = 0;
this.tbAutoCancelDelay.SelectionStart = 0;
this.tbAutoCancelDelay.Size = new System.Drawing.Size(24, 23);
this.tbAutoCancelDelay.TabIndex = 40;
this.tbAutoCancelDelay.Text = "30";
this.tbAutoCancelDelay.UseSystemPasswordChar = false;
//
// cbAutoCancel
//
this.cbAutoCancel.AutoSize = true;
this.cbAutoCancel.Depth = 0;
this.cbAutoCancel.Font = new System.Drawing.Font("Roboto", 10F);
this.cbAutoCancel.Location = new System.Drawing.Point(23, 497);
this.cbAutoCancel.Margin = new System.Windows.Forms.Padding(0);
this.cbAutoCancel.MouseLocation = new System.Drawing.Point(-1, -1);
this.cbAutoCancel.MouseState = MaterialSkin.MouseState.HOVER;
this.cbAutoCancel.Name = "cbAutoCancel";
this.cbAutoCancel.Ripple = true;
this.cbAutoCancel.Size = new System.Drawing.Size(26, 30);
this.cbAutoCancel.TabIndex = 39;
this.cbAutoCancel.UseVisualStyleBackColor = true;
//
// cbMockTrading
//
this.cbMockTrading.AutoSize = true;
this.cbMockTrading.Location = new System.Drawing.Point(29, 519);
this.cbMockTrading.Depth = 0;
this.cbMockTrading.Font = new System.Drawing.Font("Roboto", 10F);
this.cbMockTrading.Location = new System.Drawing.Point(23, 580);
this.cbMockTrading.Margin = new System.Windows.Forms.Padding(0);
this.cbMockTrading.MouseLocation = new System.Drawing.Point(-1, -1);
this.cbMockTrading.MouseState = MaterialSkin.MouseState.HOVER;
this.cbMockTrading.Name = "cbMockTrading";
this.cbMockTrading.Size = new System.Drawing.Size(76, 16);
this.cbMockTrading.Ripple = true;
this.cbMockTrading.Size = new System.Drawing.Size(94, 30);
this.cbMockTrading.TabIndex = 38;
this.cbMockTrading.Text = "모의 투자";
this.cbMockTrading.UseVisualStyleBackColor = true;
@@ -1548,7 +1605,7 @@
private System.Windows.Forms.ColumnHeader chNCOrgOrderNo;
public MaterialSkin.Controls.MaterialCheckBox chSMHalfTrailing;
private System.Windows.Forms.ColumnHeader chNCOrderNo;
private System.Windows.Forms.CheckBox cbMockTrading;
private MaterialSkin.Controls.MaterialCheckBox cbMockTrading;
private MaterialSkin.Controls.MaterialLabel lbSBCnt;
private MaterialSkin.Controls.MaterialLabel lbRQCnt;
private MaterialSkin.Controls.MaterialLabel lbTRCnt;
@@ -1569,5 +1626,8 @@
private System.Windows.Forms.ColumnHeader columnHeader10;
private MaterialSkin.Controls.MaterialRaisedButton btClearBeforeClosing;
private MaterialSkin.Controls.MaterialRaisedButton btCancel;
private MaterialSkin.Controls.MaterialLabel materialLabel19;
private MaterialSkin.Controls.MaterialSingleLineTextField tbAutoCancelDelay;
private MaterialSkin.Controls.MaterialCheckBox cbAutoCancel;
}
}

View File

@@ -117,6 +117,9 @@ namespace AutoSellerNS
tbCFTimeDown.Text = Config.GetTimeDown().ToString();
tbCFIgnorePrice.Text = Config.GetIgnorePrice().ToString();
cbAutoCancel.Checked = Config.IsAutoCancel();
tbAutoCancelDelay.Text = Config.GetAutoCancelDelay().ToString();
cbMockTrading.Checked = Config.GetMockTrading();
m_CybosHelper = new CybosHelper(this);
@@ -355,6 +358,20 @@ namespace AutoSellerNS
}
private async void AutoCancelProc()
{
TimeSpan delay = TimeSpan.FromSeconds(Config.GetAutoCancelDelay());
List<NCITEM> cloned;
lock (m_NCItems)
cloned = m_NCItems.ConvertAll(s => s);
foreach (var nc in cloned)
{
if (nc.m_bAsk == false && DateTime.Now >= nc.m_Time + delay)
await m_CybosHelper.CancelItem(nc.m_strCode, nc.m_iOrgOrderNo);
}
}
private async void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
await CorrectItems();
@@ -371,6 +388,9 @@ namespace AutoSellerNS
if(m_bClearBeforeClosing == true)
ClearBeforeClsosingProc();
if (Config.IsAutoCancel() == true)
AutoCancelProc();
}
private void btUpdate_Click(object sender, EventArgs e)
@@ -641,6 +661,11 @@ namespace AutoSellerNS
int.TryParse(tbCFIgnorePrice.Text, out iIgnorePrice);
Config.SetVolatility(iListSize, dFastSD, dFastUp, dFastDown, dSlowSD, dSlowUp, dSlowDown, iTimeLimit, dTimeDown, iIgnorePrice);
int iAutoCancelDelay;
int.TryParse(tbAutoCancelDelay.Text, out iAutoCancelDelay);
Config.SetAutoCancel(cbAutoCancel.Checked, iAutoCancelDelay);
Config.SetMockTrading(cbMockTrading.Checked);
}

View File

@@ -33,6 +33,8 @@ namespace AutoSellerNS
m_Data.Add("time-down", 0.02);
m_Data.Add("ignore-price", 50000);
m_Data.Add("mock-trading", false);
m_Data.Add("auto-cancel", false);
m_Data.Add("auto-cancel-delay", 30);
Load();
}
@@ -145,6 +147,13 @@ namespace AutoSellerNS
public static int GetTimeLimit() { return (int)m_Data["time-limit"]; }
public static double GetTimeDown() { return (double)m_Data["time-down"]; }
public static int GetIgnorePrice() { return (int)m_Data["ignore-price"]; }
public static void SetAutoCancel(bool bCancel, int iDelay)
{
m_Data["auto-cancel"] = bCancel;
m_Data["auto-cancel-delay"] = iDelay;
}
public static bool IsAutoCancel() { return (bool)m_Data["auto-cancel"]; }
public static int GetAutoCancelDelay() { return (int)m_Data["auto-cancel-delay"]; }
public static void SetMockTrading(bool bMockTrading) { m_Data["mock-trading"] = bMockTrading; Save(); }
public static bool GetMockTrading() { return (bool)m_Data["mock-trading"]; }