private void gaIsland2() { TickData.readTickData(0); using (StreamWriter sw = new StreamWriter("./multi ga.csv", false, Encoding.Default)) { int opt_period = 420000; int sim_period = 180000; int slide = 100000; sw.WriteLine("pl per min,num trade,vola,fired[0],fired[1],fired[2],pl per min,num trade,vola,fired[0],fired[1],fired[2]"); for (int i = 0; i < 30; i++) { var gim = new GAIslandMaster2(); int from = TickData.price.Count - 6000000 + i * slide; int to = from + opt_period; var chro = gim.startGA(from, to, 3, 15, 15, 3, 0.05, 10, 30, 10, 10, false); var s = new SIM2(); var ac = s.startContrarianTrendFollowSashine(from, to, chro, false, false); Form1.Form1Instance.addListBox2(i.ToString() + " - " + "GA period - pl per min=" + Math.Round(ac.pl_per_min, 2) + ",num trade=" + Math.Round(ac.num_trade_per_hour, 2) + ", vola=" + Math.Round(ac.total_pl_vola, 2) + ", fired box num=" + ac.fired_box_ind_num[0] + " : " + ac.fired_box_ind_num[1] + " : " + ac.fired_box_ind_num[2]); s = new SIM2(); var ac2 = s.startContrarianTrendFollowSashine(to, to + sim_period, chro, true, false); //var ac2 = s.startContrarianTrendFollowSashine(from, to, chro, true, false); Form1.Form1Instance.addListBox2("SIM period - pl per min=" + Math.Round(ac2.pl_per_min, 2) + ",num trade=" + Math.Round(ac2.num_trade_per_hour, 2) + ", vola=" + Math.Round(ac2.total_pl_vola, 2) + ", fired box num=" + ac2.fired_box_ind_num[0] + " : " + ac2.fired_box_ind_num[1] + " : " + ac2.fired_box_ind_num[2]); sw.WriteLine(Math.Round(ac.pl_per_min, 2) + "," + Math.Round(ac.num_trade_per_hour, 6) + "," + Math.Round(ac.total_pl_vola) + "," + ac.fired_box_ind_num[0] + "," + ac.fired_box_ind_num[1] + "," + ac.fired_box_ind_num[2] + "," + Math.Round(ac2.pl_per_min, 2) + "," + Math.Round(ac2.num_trade_per_hour, 6) + "," + Math.Round(ac2.total_pl_vola) + "," + ac2.fired_box_ind_num[0] + "," + ac2.fired_box_ind_num[1] + "," + ac2.fired_box_ind_num[2]); } } }
private Chrome2 getOptStrategy(int from, int to, int num_chrom, int num_generation, int num_box, int num_island, double immigration_rate, int elite_crossover_genera, double pl_importance, double num_trade_importance, double pl_vola_importance) { Form1.Form1Instance.setLabel2("Calculating GA"); var ga = new GAIslandMaster2(); return(ga.startGA(from, to, num_box, num_chrom, num_generation, num_island, immigration_rate, elite_crossover_genera, pl_importance, num_island, pl_vola_importance, false)); }