private void btnAutoTradeCancel_Click(object sender, EventArgs e) { this.currentAutoTradeSettings = new AutoTradeSettings(); this.gbAutoTradeExecution.Enabled = false; this.lblAutoTradeRules.Text = string.Empty; }
private void btnConfirm_Click(object sender, EventArgs e) { try { currentAutoTradeSettings.Trade = this.cbAutoTrade.Checked; if (currentAutoTradeSettings.Trade) { currentAutoTradeSettings.TradeType = this.comboAutoTradeType.SelectedIndex == 0 ? AutoTradeSettings.OrderType.Buy : AutoTradeSettings.OrderType.Sell; currentAutoTradeSettings.TradeAmount = Double.Parse(this.txtAutoTradeAmount.Text.Trim()); } currentAutoTradeSettings.Warn = this.cbWarning.Checked; if (currentAutoTradeSettings.Warn) { currentAutoTradeSettings.Sound = this.comboAutoTradeWarningSound.SelectedItem.ToString(); } currentAutoTradeSettings.OrderTime = DateTime.Now; currentAutoTradeSettings.Status = AutoTradeSettings.OrderStatus.Pending; autoTradeSettingsList.Add(currentAutoTradeSettings); currentAutoTradeSettings = new AutoTradeSettings(); this.gbAutoTradeExecution.Enabled = false; this.lblAutoTradeRules.Text = string.Empty; } catch (Exception ex) { } LoadAutoTradeSettings(); }
private void InitializeData() { tickerEvent = new AutoResetEvent(false); formEvent = new AutoResetEvent(false); dtAccount = new DataTable(); dtTrade = new DataTable(); this.lblAutoTradeRules.Text = string.Empty; this.lblAutoTradePercent.Visible = false; this.lblWarning.Text = ""; currentAutoTradeSettings = new AutoTradeSettings(); autoTradeSettingsList = new List<AutoTradeSettings>(); try { stopOrderList = new List<StopOrder>(); configFolder = Path.Combine(Application.StartupPath, Consts.DataFolder); this.stopOrderFullPath = Path.Combine(configFolder, Consts.StopOrderFileName); if (!Directory.Exists(configFolder)) { Directory.CreateDirectory(configFolder); } List<StopOrder> orderList = (List<StopOrder>)Utils.LoadFromFile(this.stopOrderFullPath, typeof(List<StopOrder>)); if (orderList != null) this.stopOrderList = orderList; } catch { } try { this.comboAlarm.Items.Add(""); this.comboAutoTradeWarningSound.Items.Add(""); DirectoryInfo folder = new DirectoryInfo(Path.Combine(Application.StartupPath, Consts.SoundFolder)); foreach (FileInfo file in folder.GetFiles()) { if (Consts.SoundTypes.Contains(file.Extension.ToLower())) { this.comboAlarm.Items.Add(file.Name); this.comboAutoTradeWarningSound.Items.Add(file.Name); } } this.comboAlarm.SelectedIndex = 0; this.comboAutoTradeWarningSound.SelectedIndex = 0; } catch { } }