private void queuebut_Click(object sender, EventArgs e) { bt = new BackTest(); bt.BTStatus += new DebugFullDelegate(bt_BTStatus); bt.mybroker.GotOrder += new OrderDelegate(mybox.gotOrderSink); bt.mybroker.GotOrderCancel += new Broker.OrderCancelDelegate(mybroker_GotOrderCancel); if (cleartrades.Checked) { trades.Rows.Clear(); } if (clearorders.Checked) { orders.Rows.Clear(); } if (clearmessages.Checked) { messages.Clear(); } //bt.mybroker.GotFill += new FillDelegate(mybroker_GotFill); //bt.mybroker.GotOrder += new OrderDelegate(mybroker_GotOrder); List <FileInfo> tf = new List <FileInfo>(); string dir = WinGauntlet.Properties.Settings.Default.tickfolder; if (!Directory.Exists(dir)) { string msg = "You must select a valid tick directory containing historical tick files."; MessageBox.Show(msg, "Nonexistent tick directory"); show(msg); return; } DirectoryInfo di = new DirectoryInfo(dir); FileInfo [] fi = di.GetFiles("*.EPF"); for (int i = 0; i < fi.Length; i++) { bool datematch = true; bool symmatch = true; bool ud = usedates.Checked; bool us = usestocks.Checked; DateTime d = Util.ToDateTime(StockFromFileName(fi[i].Name).Date); if (ud) { for (int j = 0; j < yearlist.SelectedItems.Count; j++) { if ((int)yearlist.SelectedItems[j] == d.Year) { datematch &= true; break; } else { datematch &= false; } } for (int j = 0; j < monthlist.SelectedItems.Count; j++) { if ((int)monthlist.SelectedItems[j] == d.Month) { datematch &= true; break; } else { datematch &= false; } } for (int j = 0; j < daylist.SelectedItems.Count; j++) { if ((int)daylist.SelectedItems[j] == d.Day) { datematch &= true; break; } else { datematch &= false; } } } if (us) { for (int j = 0; j < stocklist.SelectedItems.Count; j++) { if (fi[i].Name.Contains((string)stocklist.SelectedItems[j])) { symmatch = true; break; } else { symmatch = false; } } } if ((ud && us && datematch && symmatch) || (ud && datematch) || (us && symmatch)) { tf.Add(fi[i]); } } if (tf.Count == 0) { string msg = "You didn't select any valid tick files, or none were available."; MessageBox.Show(msg, "No tick files selected."); show(msg); return; } bt.name = DateTime.Now.ToString("yyyMMdd.HHmm"); if (mybox != null) { bt.mybox = mybox; bt.mybox.Debug = showdebug.Checked; } else { show("You must select a box to run the gauntlet."); return; } string exfilt = ""; if ((exchlist.SelectedIndices.Count > 0) && !exchlist.SelectedItem.ToString().Contains("NoFilter")) { exfilt = (string)exchlist.SelectedItem; } bt.ExchFilter(exfilt); bt.Path = WinGauntlet.Properties.Settings.Default.tickfolder + "\\"; bt.ProgressChanged += new ProgressChangedEventHandler(bt_ProgressChanged); bt.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bt_RunWorkerCompleted); ProgressBar1.Enabled = true; queuebut.Enabled = false; bt.RunWorkerAsync(tf); }
private void queuebut_Click(object sender, EventArgs e) { bt = new BackTest(); bt.BTStatus += new DebugFullDelegate(bt_BTStatus); bt.mybroker.GotOrder += new OrderDelegate(mybox.gotOrderSink); bt.mybroker.GotOrderCancel += new Broker.OrderCancelDelegate(mybroker_GotOrderCancel); if (cleartrades.Checked) trades.Rows.Clear(); if (clearorders.Checked) orders.Rows.Clear(); if (clearmessages.Checked) messages.Clear(); //bt.mybroker.GotFill += new FillDelegate(mybroker_GotFill); //bt.mybroker.GotOrder += new OrderDelegate(mybroker_GotOrder); List<FileInfo> tf = new List<FileInfo>(); string dir = WinGauntlet.Properties.Settings.Default.tickfolder; if (!Directory.Exists(dir)) { string msg = "You must select a valid tick directory containing historical tick files."; MessageBox.Show(msg,"Nonexistent tick directory"); show(msg); return; } DirectoryInfo di = new DirectoryInfo(dir); FileInfo [] fi = di.GetFiles("*.EPF"); for (int i = 0; i < fi.Length; i++) { bool datematch = true; bool symmatch = true; bool ud = usedates.Checked; bool us = usestocks.Checked; DateTime d = Util.ToDateTime(StockFromFileName(fi[i].Name).Date); if (ud) { for (int j = 0; j < yearlist.SelectedItems.Count; j++) if ((int)yearlist.SelectedItems[j] == d.Year) { datematch &= true; break; } else datematch &= false; for (int j = 0; j < monthlist.SelectedItems.Count; j++) if ((int)monthlist.SelectedItems[j] == d.Month) { datematch &= true; break; } else datematch &= false; for (int j = 0; j < daylist.SelectedItems.Count; j++) if ((int)daylist.SelectedItems[j] == d.Day) { datematch &= true; break; } else datematch &= false; } if (us) { for (int j = 0; j < stocklist.SelectedItems.Count; j++) if (fi[i].Name.Contains((string)stocklist.SelectedItems[j])) { symmatch = true; break; } else symmatch = false; } if ((ud && us && datematch && symmatch) || (ud && datematch) || (us && symmatch)) tf.Add(fi[i]); } if (tf.Count == 0) { string msg = "You didn't select any valid tick files, or none were available."; MessageBox.Show(msg, "No tick files selected."); show(msg); return; } bt.name = DateTime.Now.ToString("yyyMMdd.HHmm"); if (mybox != null) { bt.mybox = mybox; bt.mybox.Debug = showdebug.Checked; } else { show("You must select a box to run the gauntlet."); return; } string exfilt = ""; if ((exchlist.SelectedIndices.Count > 0) && !exchlist.SelectedItem.ToString().Contains("NoFilter")) exfilt = (string)exchlist.SelectedItem; bt.ExchFilter(exfilt); bt.Path = WinGauntlet.Properties.Settings.Default.tickfolder+"\\"; bt.ProgressChanged += new ProgressChangedEventHandler(bt_ProgressChanged); bt.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bt_RunWorkerCompleted); ProgressBar1.Enabled = true; queuebut.Enabled = false; bt.RunWorkerAsync(tf); }