Пример #1
0
        private void gaForMultiplePeriod()
        {
            TickData.readTickData(0);

            int start     = 5000000;
            int slide     = 100000;
            int opt_term  = 60000;
            int test_term = 12500;

            using (StreamWriter sw = new StreamWriter("./multi ga.csv", false, Encoding.Default))
            {
                sw.WriteLine("from,to,best pl per min,best total pl,best num trade per hour,best win rate,pl per min,total pl,win rate,total perfoamnce,pl_per_min_P,profit_factor_P,num_trade_per_hour_P");
                for (int i = 0; i < 10; i++)
                {
                    GA  ga   = new GA();
                    int from = TickData.time.Count - start + (i * slide);
                    int to   = TickData.time.Count - start + opt_term + (i * slide);
                    Form1.Form1Instance.setLabel3("#" + i.ToString() + ":doing for " + from.ToString() + " - " + to.ToString());
                    var chro = ga.startGA(20, 50, from, to, false);
                    SIM s    = new SIM();
                    var ac   = s.startContrarianSashine(from, to, chro.Gene_exit_time_sec, chro.Gene_kairi_term, chro.Gene_entry_kairi, chro.Gene_rikaku_percentage, false);
                    var ac2  = s.startContrarianSashine(to, to + test_term, chro.Gene_exit_time_sec, chro.Gene_kairi_term, chro.Gene_entry_kairi, chro.Gene_rikaku_percentage, false);

                    VerifyChrome vc  = new VerifyChrome();
                    var          res = vc.verifyBestChrome(chro, from, to);
                    sw.WriteLine(TickData.time[from].ToString() + "," + TickData.time[to].ToString() + "," + ac.pl_per_min.ToString() + "," + ac.total_pl_log.Values.ToList()[ac.total_pl_log.Values.ToList().Count - 1].ToString() + "," + ac.num_trade.ToString() + "," + ac.win_rate.ToString() +
                                 "," + ac2.pl_per_min.ToString() + "," + ac2.total_pl_log.Values.ToList()[ac2.total_pl_log.Values.ToList().Count - 1].ToString() + "," + ac2.win_rate.ToString()
                                 + "," + res["total performance"].ToString() + ", " + res["pl_per_min"].ToString() + "," + res["profit_factor"].ToString() + "," + res["num_trade_per_hour"]);

                    Form1.Form1Instance.addListBox2("#" + i.ToString() + ", total performance:" + res["total performance"].ToString() + ", pl_per_min_P:" + res["pl_per_min"].ToString() + ", profit_factor_P:" + res["profit_factor"].ToString()
                                                    + ", num_trade_per_hour_P:" + res["num_trade_per_hour"].ToString());
                }
            }
            Form1.Form1Instance.setLabel3("Completed all calc");
        }
Пример #2
0
        private void doGA()
        {
            TickData.readTickData(0);
            GA ga = new GA();

            ga.startGA(20, 30, TickData.time.Count - 6000000, TickData.time.Count - 4000000, true);
        }
Пример #3
0
        private Chrome getOptStrategy(int from, int to, int num_chrom, int num_generation)
        {
            Form1.Form1Instance.setLabel2("Calculating GA");
            GA ga = new GA();

            return(ga.startGA(num_chrom, num_generation, from, to, false));
        }