protected String GenerateConfigFile(String filePath, String symbol, String company, String training_file_path, String testing_file_path, String unique_id) { String output_file_base = filePath + "_results_"; String config_file_name = filePath + "_config" + unique_id + ".txt"; List <String> labels = new List <String> { "KNN_num_neighbors", "num_training_pts", "num_groups", "stagger_factor", "window_size", "avg_target", "good_target", "bad_target", "min_samples_pct", "thresh1", "thresh2", "future_lookahead", "s_name", "co_name", "description", "training_file", "training_start", "training_end", "testing_file", "testing_start", "testing_end", "output_csv_file", "output_txt_file", "output_pdf_file" }; List <String> values = new List <String> { KNN_num_neighbors.ToString(), num_training_pts.ToString(), num_groups.ToString(), stagger_factor.ToString(), window_size.ToString(), avg_target.ToString(), good_target.ToString(), bad_target.ToString(), min_samples_pct.ToString(), thresh1.ToString(), thresh2.ToString(), FutureValueDaysToLookAhead.ToString(), symbol, company, description, training_file_path, TrainingStartDate.ToShortDateString(), TrainingEndDate.ToShortDateString(), testing_file_path, TestingStartDate.ToShortDateString(), TestingEndDate.ToShortDateString(), output_file_base + "data" + unique_id + ".csv", output_file_base + "summary" + unique_id + ".txt", output_file_base + "plot" + unique_id + ".pdf", }; List <String> types = new List <String> { "int", "int", "int", "int", "int", "float", "float", "float", "float", "float", "float", "int", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str" }; var cfg = new StringBuilder(); for (int i = 0; i < labels.Count; i++) { cfg.AppendLine(labels[i] + "=" + values[i] + "#" + types[i]); } //mut.WaitOne(); //wait until safe to enter; prior thread has completed writing. try { File.WriteAllText(config_file_name, cfg.ToString()); //mut.ReleaseMutex(); } catch (System.Exception exp) { Log("File write error for file name '" + filePath + "' Error '" + exp.Message + "'", LogLevel.Warning); } return(config_file_name); }
protected String GenerateConfigFile(String filePath, String symbol, String training_file_path, String testing_file_path, String unique_id) { String output_file_base = filePath + "_results_"; String config_file_name = filePath + "_config" + unique_id + ".txt"; List <String> labels = new List <String> { "KNN_num_neighbors", "num_training_pts", "samples_per_group", "window_size", "avg_target", "good_target", "bad_target", "min_samples", "thresh1", "thresh2", "future_lookahead", "s_name", "description", "training_file", "training_start", "training_end", "testing_file", "testing_start", "testing_end", "output_csv_file", "output_txt_file", "output_pdf_file" }; List <String> values = new List <String> { KNN_num_neighbors.ToString(), num_training_pts.ToString(), samples_per_group.ToString(), window_size.ToString(), avg_target.ToString(), good_target.ToString(), bad_target.ToString(), min_samples.ToString(), thresh1.ToString(), thresh2.ToString(), FutureValueDaysToLookAhead.ToString(), symbol, description, training_file_path, TrainingStartDate.ToShortDateString(), TrainingEndDate.ToShortDateString(), testing_file_path, TestingStartDate.ToShortDateString(), TestingEndDate.ToShortDateString(), output_file_base + "data" + unique_id + ".csv", output_file_base + "summary" + unique_id + ".txt", output_file_base + "plot" + unique_id + ".pdf", }; List <String> types = new List <String> { "int", "int", "int", "int", "float", "float", "float", "int", "float", "float", "int", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str" }; var cfg = new StringBuilder(); for (int i = 0; i < labels.Count; i++) { cfg.AppendLine(labels[i] + "=" + values[i] + "#" + types[i]); } File.WriteAllText(config_file_name, cfg.ToString()); return(config_file_name); }
protected String GenerateConfigFile(String filePath, String symbol, String company, String training_file_path, String testing_file_path, String unique_id) { String output_file_base = filePath + "_results_"; String config_file_name = filePath + "_config" + unique_id + ".txt"; List <List <String> > param_list = new List <List <String> >(); param_list.Add(new List <String>() { "uid", uid, "str" }); param_list.Add(new List <String>() { "KNN_num_neighbors", KNN_num_neighbors.ToString(), "int" }); param_list.Add(new List <String>() { "num_training_pts", num_training_pts.ToString(), "int" }); param_list.Add(new List <String>() { "num_groups", num_groups.ToString(), "int" }); param_list.Add(new List <String>() { "stagger_factor", stagger_factor.ToString(), "int" }); param_list.Add(new List <String>() { "window_size", window_size.ToString(), "int" }); param_list.Add(new List <String>() { "avg_target", avg_target.ToString(), "float" }); param_list.Add(new List <String>() { "good_target", good_target.ToString(), "float" }); param_list.Add(new List <String>() { "bad_target", bad_target.ToString(), "float" }); param_list.Add(new List <String>() { "min_samples_pct", min_samples_pct.ToString(), "float" }); param_list.Add(new List <String>() { "thresh1", thresh1.ToString(), "float" }); param_list.Add(new List <String>() { "thresh2", thresh2.ToString(), "float" }); param_list.Add(new List <String>() { "future_lookahead", FutureValueDaysToLookAhead.ToString(), "int" }); param_list.Add(new List <String>() { "s_name", symbol, "str" }); param_list.Add(new List <String>() { "co_name", company, "str" }); param_list.Add(new List <String>() { "description", description, "str" }); param_list.Add(new List <String>() { "indicator", indicator, "str" }); param_list.Add(new List <String>() { "param1", Param1.ToString(), "int" }); param_list.Add(new List <String>() { "param2", Param2.ToString(), "int" }); param_list.Add(new List <String>() { "param3", Param3.ToString(), "int" }); param_list.Add(new List <String>() { "training_file", training_file_path, "str" }); param_list.Add(new List <String>() { "training_start", TrainingStartDate.ToShortDateString(), "str" }); param_list.Add(new List <String>() { "training_end", TrainingEndDate.ToShortDateString(), "str" }); param_list.Add(new List <String>() { "testing_file", testing_file_path, "str" }); param_list.Add(new List <String>() { "testing_start", TestingStartDate.ToShortDateString(), "str" }); param_list.Add(new List <String>() { "testing_end", TestingEndDate.ToShortDateString(), "str" }); param_list.Add(new List <String>() { "output_csv_file", output_file_base + "data" + unique_id + ".csv", "str" }); param_list.Add(new List <String>() { "output_txt_file", output_file_base + "summary" + unique_id + ".txt", "str" }); param_list.Add(new List <String>() { "output_pdf_file", output_file_base + "plot" + unique_id + ".pdf", "str" }); var cfg = new StringBuilder(); for (int i = 0; i < param_list.Count; i++) { cfg.AppendLine(param_list[i][0] + "=" + param_list[i][1] + "#" + param_list[i][2]); } //mut.WaitOne(); //wait until safe to enter; prior thread has completed writing. try { File.WriteAllText(config_file_name, cfg.ToString()); //mut.ReleaseMutex(); } catch (System.Exception exp) { Log("File write error for file name '" + filePath + "' Error '" + exp.Message + "'", LogLevel.Warning); } return(config_file_name); }