コード例 #1
0
        public static void BuildMinuteDayNodes(ThreadControl tc)
        {
            // this should be called AFTER updated yesterday's ticks AND data tracker no data days updated


            List <string> symbols = new List <string>(Global.State.AllSymbols);

            symbols.Shuffle();

            symbols.Remove("spy");
            symbols.Remove("aapl");
            symbols.Add("spy");
            symbols.Add("aapl");
            symbols.Reverse();



            ZonedDateTime ie = SystemClock.Instance.GetCurrentInstant().InZone(UCDT.TimeZones.Eastern);

            // set the current date to yesterday via eastern timezone just to be safe
            DateTime dt = new DateTime(ie.Year, ie.Month, ie.Day, 0, 0, 0, DateTimeKind.Unspecified).AddDays(-20);


            DateTime firstDataDay = Global.State.DataTracker.DataDays[0].DT;

            while (dt > firstDataDay && tc.CheckNotStopped())
            {
                FD fd = new FD(dt);

                Parallel.For(0, symbols.Count, new ParallelOptions {
                    MaxDegreeOfParallelism = 20
                }, n =>
                {
                    if (DataMethods.DayNodesDataCacheable(symbols[n], fd))
                    {
                        Stopwatch sw = new Stopwatch();
                        sw.Start();
                        NodesData nodes = DataMethods.GetCachedDayNodesData(symbols[n], fd, Interval.HalfSecond, computeNodes: false, justCache: true);
                        sw.Stop();
                        tc.Log.AddLine("[" + symbols[n] + "] " + fd.ToString() + " Done. Took " + UC.MillisecondsToSeconds(sw.ElapsedMilliseconds, 2) + " sec(s)");
                    }
                    else
                    {
                        tc.Log.AddLine("[" + symbols[n] + "] " + fd.ToString() + ". Not cacheable.");
                    }
                });

                dt = dt.AddDays(-1);
            }
        }