예제 #1
0
        private static void ReportGroupByTradeStartTime(Report report, BestTradeTime bestTradeTime)
        {
            var dict = new Dictionary <int, List <Tuple <int[], int[]> > >();

            foreach (var t in bestTradeTime.Calculate())
            {
                int tradeStartTime = t.Item1[2];
                if (!dict.ContainsKey(tradeStartTime))
                {
                    dict[tradeStartTime] = new List <Tuple <int[], int[]> >();
                }
                dict[tradeStartTime].Add(t);
            }
            var list = new List <Tuple <int[], int[]> >();

            foreach (var tuples in dict.Values)
            {
                list.Add(tuples.OrderByDescending(t => bestTradeTime.Comparator(t.Item2)).First());
            }
            foreach (var t in list.OrderByDescending(t => bestTradeTime.Comparator(t.Item2)))
            {
                foreach (var time in t.Item1)
                {
                    report.Write(bestTradeTime.HMString(time));
                }
                foreach (var c in t.Item2)
                {
                    report.Write(c);
                }
                report.WriteLine();
            }
        }
예제 #2
0
        private static void ReportGroupByTradeStartAndEndTime(Report report, BestTradeTime bestTradeTime)
        {
            var dict = new Dictionary <int[], List <Tuple <int[], int[]> > >();

            foreach (var t in bestTradeTime.Calculate())
            {
                if (bestTradeTime.Comparator(t.Item2) < 5500)
                {
                    continue;
                }
                int   tradeStartTime = t.Item1[2];
                int   tradeEndTime   = t.Item1[3];
                int[] key            = new int[] { tradeStartTime, tradeEndTime };
                if (!dict.ContainsKey(key))
                {
                    dict[key] = new List <Tuple <int[], int[]> >();
                }
                dict[key].Add(t);
            }
            var list = new List <Tuple <int[], int[]> >();

            foreach (var tuples in dict.Values)
            {
                int[] pre = null;
                foreach (var t in tuples.OrderByDescending(t => bestTradeTime.Comparator(t.Item2)))
                {
                    if (pre != null)
                    {
                        if (IsIntersect(pre, t.Item1))
                        {
                            continue;
                        }
                    }
                    pre = t.Item1;
                    list.Add(t);
                }
            }

            foreach (var t in list.OrderByDescending(t => bestTradeTime.Comparator(t.Item2)).Take(10000))
            {
                foreach (var time in t.Item1)
                {
                    report.Write(bestTradeTime.HMString(time));
                }
                foreach (var c in t.Item2)
                {
                    report.Write(c);
                }
                report.WriteLine();
            }
        }