Exemplo n.º 1
0
        public void DemoAndStratIssue()
        {
            var series = new SortedChunkedMap <DateTime, double> [2];
            var scm1   = new SortedChunkedMap <DateTime, double>();
            var scm2   = new SortedChunkedMap <DateTime, double>();
            var today  = DateTime.UtcNow.Date;

            for (int i = 0; i < 10000; i = i + 2)
            {
                scm1.Add(today.AddMilliseconds(i), i);
            }

            for (int i = 1; i < 10000; i = i + 2)
            {
                scm2.Add(today.AddMilliseconds(i), i);
            }

            series[0] = scm1;
            series[1] = scm2;

            // Zip on repeated used to throw
            var sm = series.Select(x => x.Repeat()).ToArray().Zip((k, vArr) => {
                if (Math.Abs(vArr.Sum(x => Math.Sign(x))) == vArr.Length)
                {
                    return(vArr.Average());
                }
                else
                {
                    return(0.0);
                }
            }).ToSortedMap();

            Console.WriteLine(sm.Count);
        }