예제 #1
0
        private void StartBackTesting(IStrategySetting set)
        {
            button.Text        = string.Concat("Estimated Back Testing Time is ", pro.Rate(Estimate.Count, count).ToString("N0"), " Minutes.");
            button.ForeColor   = Color.Maroon;
            checkBox.ForeColor = Color.DarkRed;
            checkBox.Text      = "BackTesting";
            new Transmit(asset.Account, set.Capital);
            string path = Path.Combine(Application.StartupPath, @"..\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"));

            InterLink = false;
            List <Specify> list = new List <Specify>(131072);

            foreach (string str in Estimate)
            {
                string[] temp = str.Split('^');
                list.Add(new Specify
                {
                    ShortTickPeriod = int.Parse(temp[0]),
                    ShortDayPeriod  = int.Parse(temp[1]),
                    LongTickPeriod  = int.Parse(temp[2]),
                    LongDayPeriod   = int.Parse(temp[3]),
                    Reaction        = int.Parse(temp[4]),
                    Hedge           = int.Parse(temp[5]),
                    Base            = int.Parse(temp[6]),
                    Sigma           = int.Parse(temp[7]),
                    Percent         = int.Parse(temp[8]),
                    Max             = int.Parse(temp[9]),
                    Quantity        = int.Parse(temp[10]),
                    Time            = int.Parse(temp[11]),
                    Repository      = options.Repository,
                    BasicAssets     = set.Capital,
                    PathLog         = path,
                    Strategy        = str
                });
            }
            EstimateCount = Estimate.Count;
            Estimate      = null;
            GC.Collect();
            Count = Process.GetCurrentProcess().Threads.Count;
            new Task(() =>
            {
                Remaining remaining = new Remaining();
                Parallel.ForEach(list, new ParallelOptions
                {
                    MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 1.5)
                },
                                 new Action <Specify>((analysis) =>
                {
                    new Analysize(remaining, analysis);
                    pro.ProgressBarValue++;
                }));
                list             = null;
                button.ForeColor = Color.Yellow;
                SetMarketTick(GC.GetTotalMemory(true));
            }).Start();
        }
예제 #2
0
        private void StartBackTesting(IStrategySetting set)
        {
            Max                = set.EstimatedTime();
            button.Text        = string.Concat("Estimated Back Testing Time is ", pro.Rate(Max, count).ToString("N0"), " Minutes.");
            button.ForeColor   = Color.Maroon;
            checkBox.ForeColor = Color.DarkRed;
            checkBox.Text      = "BackTesting";
            new Transmit(asset.Account, set.Capital);
            string path = string.Concat(Path.Combine(Application.StartupPath, @"..\"), @"\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), @"\");

            InterLink = false;
            List <Specify> list = new List <Specify>(131072);

            foreach (int hedge in set.Hedge)
            {
                foreach (int reaction in set.Reaction)
                {
                    foreach (int sTick in set.ShortTick)
                    {
                        foreach (int sDay in set.ShortDay)
                        {
                            foreach (int lTick in set.LongTick)
                            {
                                foreach (int lDay in set.LongDay)
                                {
                                    if (sTick < lTick && sDay < lDay)
                                    {
                                        list.Add(new Specify
                                        {
                                            Repository      = options.Repository,
                                            ShortTickPeriod = sTick,
                                            ShortDayPeriod  = sDay,
                                            LongTickPeriod  = lTick,
                                            LongDayPeriod   = lDay,
                                            Reaction        = reaction,
                                            Hedge           = hedge,
                                            BasicAssets     = set.Capital,
                                            PathLog         = path,
                                            Strategy        = string.Concat(sDay.ToString("D2"), '^', sTick.ToString("D2"), '^', lDay.ToString("D2"), '^', lTick.ToString("D2"), '^', reaction.ToString("D2"), '^', hedge.ToString("D2"))
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }
            GC.Collect();
            Count = Process.GetCurrentProcess().Threads.Count;
            new Task(() =>
            {
                Parallel.ForEach(list, new ParallelOptions
                {
                    MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 1.5)
                },
                                 new Action <Specify>((analysis) =>
                {
                    new Analysize(analysis);
                    pro.ProgressBarValue++;
                }));
                list.Clear();
                button.ForeColor = Color.Ivory;
                SetMarketTick(GC.GetTotalMemory(true));
            }).Start();
        }
예제 #3
0
        private void StartBackTesting(IStrategySetting set)
        {
            Max                = set.EstimatedTime();
            button.Text        = string.Concat("Estimated Back Testing Time is ", pro.Rate(Max, count).ToString("N0"), " Minutes.");
            button.ForeColor   = Color.Maroon;
            checkBox.ForeColor = Color.DarkRed;
            checkBox.Text      = "BackTesting";
            new Transmit(asset.Account, set.Capital);
            string   path    = string.Concat(Path.Combine(Application.StartupPath, @"..\"), @"\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), @"\");
            IOptions options = new Options();

            GC.Collect();
            Count     = Process.GetCurrentProcess().Threads.Count;
            InterLink = false;

            foreach (int hedge in set.Hedge)
            {
                foreach (int reaction in set.Reaction)
                {
                    foreach (int sTick in set.ShortTick)
                    {
                        foreach (int sDay in set.ShortDay)
                        {
                            foreach (int lTick in set.LongTick)
                            {
                                foreach (int lDay in set.LongDay)
                                {
                                    if (sTick >= lTick || sDay >= lDay)
                                    {
                                        Application.DoEvents();

                                        continue;
                                    }
                                    new Task(() =>
                                    {
                                        new Analysize(new Specify
                                        {
                                            Repository      = options.Repository,
                                            ShortTickPeriod = sTick,
                                            ShortDayPeriod  = sDay,
                                            LongTickPeriod  = lTick,
                                            LongDayPeriod   = lDay,
                                            Reaction        = reaction,
                                            Hedge           = hedge,
                                            BasicAssets     = set.Capital,
                                            PathLog         = path,
                                            Strategy        = string.Concat(sDay.ToString("D2"), '^', sTick.ToString("D2"), '^', lDay.ToString("D2"), '^', lTick.ToString("D2"), '^', reaction.ToString("D2"), '^', hedge.ToString("D2"))
                                        });
                                        if (Max <= ++pro.ProgressBarValue && InterLink == false)
                                        {
                                            button.ForeColor = Color.Ivory;
                                            SetMarketTick(GC.GetTotalMemory(true));
                                        }
                                    }).Start();
                                    Application.DoEvents();
                                }
                            }
                        }
                    }
                }
            }
        }