Exemplo n.º 1
0
        public void TestRsiDivideByZero()
        {
            var jsonStr = "[0.00000397,0.00000398,0.00000399,0.00000399,0.00000398,0.00000398,0.00000398,0.00000399,0.00000397,0.00000398,0.00000397,0.00000399,0.00000398,0.00000397,0.00000398,0.00000398,0.00000398,0.00000398,0.00000398,0.00000398,0.00000398,0.00000398,0.00000397,0.00000398,0.00000398,0.00000398,0.00000397,0.00000397,0.00000397,0.00000398,0.00000398,0.00000397,0.00000398,0.00000398,0.00000398,0.00000398,0.00000398,0.00000397,0.00000397,0.00000397,0.00000397,0.00000397,0.00000398,0.00000397,0.00000398,0.00000397,0.00000397,0.00000398,0.00000397,0.00000398,0.00000398,0.00000397,0.00000397,0.00000397,0.00000398,0.00000396,0.00000396,0.00000397,0.00000396,0.00000396,0.00000395,0.00000396,0.00000396,0.00000395,0.00000396,0.00000396,0.00000396,0.00000396,0.00000396,0.00000396,0.00000396,0.00000396,0.00000395,0.00000395,0.00000394,0.00000393,0.00000393,0.00000394,0.00000393,0.00000393,0.00000393,0.00000394,0.00000393,0.00000394,0.00000393,0.00000392,0.00000393,0.00000392,0.00000394,0.00000395,0.00000394,0.00000395,0.00000395,0.00000395,0.00000394,0.00000394,0.00000393,0.00000391,0.00000391,0.00000391,0.00000392,0.00000390,0.00000391,0.00000389,0.00000390,0.00000389,0.00000389,0.00000390,0.00000389,0.00000388,0.00000388,0.00000389,0.00000388,0.00000389,0.00000392,0.00000394,0.00000395,0.00000395,0.00000394,0.00000395,0.00000395,0.00000394,0.00000394,0.00000394,0.00000393,0.00000391,0.00000391,0.00000391,0.00000389,0.00000389,0.00000388,0.00000390,0.00000389,0.00000389,0.00000393,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000391,0.00000393,0.00000393,0.00000392,0.00000393,0.00000394,0.00000393,0.00000394,0.00000393,0.00000392,0.00000392,0.00000392,0.00000391,0.00000392,0.00000391,0.00000392,0.00000391,0.00000391,0.00000391,0.00000392,0.00000392,0.00000393,0.00000394,0.00000393,0.00000394,0.00000393,0.00000394,0.00000393,0.00000395,0.00000394,0.00000394,0.00000394,0.00000394,0.00000394,0.00000393,0.00000394,0.00000395,0.00000393,0.00000394,0.00000394,0.00000393,0.00000394,0.00000392,0.00000393,0.00000392,0.00000392,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000393,0.00000393,0.00000393,0.00000392,0.00000392,0.00000392,0.00000393,0.00000393,0.00000393,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000391,0.00000391,0.00000392,0.00000391,0.00000392,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000390,0.00000390,0.00000391,0.00000390,0.00000390,0.00000389,0.00000390,0.00000390,0.00000390,0.00000390,0.00000391,0.00000391,0.00000391,0.00000390,0.00000390,0.00000390,0.00000391,0.00000391,0.00000391,0.00000390,0.00000390,0.00000390,0.00000390,0.00000390,0.00000391,0.00000392,0.00000391,0.00000393,0.00000393,0.00000393,0.00000394,0.00000393,0.00000392,0.00000394,0.00000392,0.00000393,0.00000393,0.00000391,0.00000393,0.00000393,0.00000392,0.00000392,0.00000393,0.00000391,0.00000392,0.00000392,0.00000391,0.00000391,0.00000393,0.00000392,0.00000392,0.00000392,0.00000393,0.00000393,0.00000392,0.00000392,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000392,0.00000393,0.00000393,0.00000393,0.00000394,0.00000393,0.00000393,0.00000394,0.00000393,0.00000393,0.00000392,0.00000393,0.00000393,0.00000393,0.00000393,0.00000394,0.00000393,0.00000392,0.00000393,0.00000393,0.00000394,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000393,0.00000392,0.00000393,0.00000393,0.00000392,0.00000393,0.00000393,0.00000393,0.00000392,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000391,0.00000392,0.00000392,0.00000393,0.00000392,0.00000392,0.00000393,0.00000392,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000392,0.00000393,0.00000392,0.00000391,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000392,0.00000391,0.00000393,0.00000392,0.00000393,0.00000393,0.00000393,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000392,0.00000393,0.00000393,0.00000392,0.00000393,0.00000393,0.00000392,0.00000392,0.00000392,0.00000393,0.00000393,0.00000394,0.00000393,0.00000394,0.00000393,0.00000393,0.00000394,0.00000394,0.00000394,0.00000394,0.00000393,0.00000394,0.00000394,0.00000393,0.00000392,0.00000394,0.00000393,0.00000392,0.00000393,0.00000393,0.00000394,0.00000394,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000392,0.00000393,0.00000393,0.00000392,0.00000393,0.00000392,0.00000392,0.00000393,0.00000392,0.00000392,0.00000393,0.00000393,0.00000392,0.00000391,0.00000392,0.00000391,0.00000391,0.00000392,0.00000392,0.00000392,0.00000391,0.00000391,0.00000392,0.00000391,0.00000392,0.00000391,0.00000390,0.00000392,0.00000391,0.00000392,0.00000391,0.00000391,0.00000392,0.00000392,0.00000391,0.00000392,0.00000391,0.00000391,0.00000391,0.00000391,0.00000392,0.00000392,0.00000391,0.00000392,0.00000390,0.00000391,0.00000391,0.00000392,0.00000392,0.00000392,0.00000392,0.00000391,0.00000391,0.00000391,0.00000391,0.00000391,0.00000392,0.00000392,0.00000392,0.00000391,0.00000392,0.00000393,0.00000393,0.00000393,0.00000392,0.00000392,0.00000392,0.00000393,0.00000392,0.00000393,0.00000392,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000393,0.00000394,0.00000393,0.00000393,0.00000394,0.00000393,0.00000393]";
            var inputs  = JsonConvert.DeserializeObject <List <decimal?> >(jsonStr);

            var rsi        = new RelativeStrengthIndexByTuple(inputs, 2); // 2 can be interchanged for 3 as well. 8 gives no errors
            var rsiResults = rsi.Compute();

            Assert.IsTrue(rsiResults?.Any() ?? false);
        }
 public RelativeStrengthIndexOvertrade(IEnumerable <TInput> inputs, Func <TInput, decimal> inputMapper, Func <TInput, Overtrade?, TOutput> outputMapper, int periodCount) : base(inputs, inputMapper, outputMapper)
 {
     _rsi = new RelativeStrengthIndexByTuple(inputs.Select(inputMapper), periodCount);
 }