示例#1
0
 public void testStandardDeviation()
 {
     indicator = new StdDeviationOfSample(values);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(3, 0.0);
     addPoint(7, Math.Sqrt(8));
     addPoint(7, Math.Sqrt(16.0 / 3.0));
     addPoint(19, Math.Sqrt(48));
 }
示例#2
0
 public void testZScore5()
 {
     indicator = new EWZScore(values, 5);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     checkPoint(121.79, 0);
     checkPoint(122.35, 2.7793933);
     checkPoint(120.15, -2.658407);
     checkPoint(120.78, -1.273116);
 }
示例#3
0
 public void testZScore1()
 {
     indicator = new EWZScore(values, 1);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     checkPoint(121.79, 0);
     checkPoint(122.35, 1.414214);
     checkPoint(120.15, -1.385064);
     checkPoint(120.78, -0.327512);
 }
示例#4
0
 public void testEWMA()
 {
     indicator = new EWMA(values, 1);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(0, 0);
     addPoint(1, 0.5);
     addPoint(0, 0.25);
     addPoint(1, 0.625);
 }
示例#5
0
 public void testEWSD5()
 {
     indicator = new EWSD(values, 5);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     checkPoint(121.79, 0);
     checkPoint(122.35, 0.175401);
     checkPoint(120.15, 0.560791);
     checkPoint(120.78, 0.588618);
 }
示例#6
0
 public void testEWSD1()
 {
     indicator = new EWSD(values, 1);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     checkPoint(121.79, 0);
     checkPoint(122.35, 0.197990);
     checkPoint(120.15, 0.693109);
     checkPoint(120.78, 0.503798);
 }
示例#7
0
 public void testEWMAJeff()
 {
     indicator = new EWMA(values, 3);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(1, 1);
     addPoint(0, 0.79370052598409979);
     addPoint(0, 0.62996052494743671);
     addPoint(0, 0.50000000000000011);
 }
示例#8
0
 public void testPopulationStandardDeviation()
 {
     indicator = new StdDeviationOfPopulation(values);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(3, 0.0);
     addPoint(7, 2.0);
     addPoint(7);
     AlmostEqual(Math.Sqrt(32.0 / 9.0), indicator[0], 1e-6);
     addPoint(19, 6.0);
 }
示例#9
0
 public void testAverage()
 {
     indicator = new Average(values);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(1, 1);
     addPoint(2, 1.5);
     AreEqual(1.0, indicator[1]);
     addPoint(3, 2);
     addPoint(4, 2.5);
 }
示例#10
0
 public void testATR()
 {
     indicator = new AverageTrueRangeEW(values, 1);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(new Bar(1, 1, 1, 1), 0);
     addPoint(new Bar(2, 2, 2, 2), 0.5);
     AreEqual(0.5, indicator[0]);
     manager.newTick();
     AreEqual(0.25, indicator[0]);
     manager.newTick();
     AreEqual(0.25, indicator[0]);
     manager.newBar();
     AreEqual(0.25, indicator[0]);
 }
示例#11
0
 public void testRSI()
 {
     indicator = new RSI(values, 5);
     Bombs(() => O.info(indicator[0] + ""), "uninitialized");
     addPoint(100);
     addPoint(101, 99.999900000099998);
     addPoint(104, 99.999900000099998);
     addPoint(102, 80.890730966157037);
     addPoint(105, 85.62414928479653);
     addPoint(100, 58.080739717036316);
     addPoint(103, 65.687948919418972);
     addPoint(108, 74.535176039717101);
     addPoint(110, 77.232548433453928);
     addPoint(103, 54.165313650320272);
 }
示例#12
0
        public void testKAMA()
        {
            indicator = new KAMA(values, 2, 30, 8);
            Bombs(() => O.info(indicator[0] + ""), "uninitialized");

            //The values below were originally calced from the ExampleKAMA.xls sheet
            addPoint(38.5, 38.5);
            addPoint(37.2, 37.2);
            addPoint(37.7, 37.7);
            addPoint(38, 38);
            addPoint(38.5, 38.5);
            addPoint(38.4, 38.4);
            addPoint(38.25, 38.25);
            addPoint(39, 39);
            //First point after the initial calc period
            addPointRound(40, 39.0681);
            addPointRound(39, 39.0612);
            addPointRound(38, 39.0502);
            addPointRound(37.5, 39.0260);
            addPointRound(40.3, 39.0838);
            addPointRound(10, 31.2031);
        }
示例#13
0
        [Test] public void testParallelEach()
        {
            string[] content = { "" };
            O.each(
                LETTERS,
                START,
                delegate(int i, string s, int val) {
                content[0] += i + ":" + s + "(" + val + ")";
                O.info(i + ":" + s + "(" + val + ")");
            });
            AreEqual("0:a(5)1:b(6)2:c(7)", content[0]);
            content[0] = "";
            O.each(LETTERS, START, delegate(string s, int val) { content[0] += s + "(" + val + ")"; });
            AreEqual("a(5)b(6)c(7)", content[0]);
            Bombs(() => O.each(O.list(1, 2, 3, 4), O.list(2, 3, 4), delegate(int i1, int i2) { }),
                  "failed",
                  "mismatched");
            Bombs(() => O.each(O.list(1, 2, 3), O.list(1, 2, 3, 4), delegate(int i1, int i2) { }), "mismatched");

            Bombs(() => O.each(O.list(4, 5, 6), val => Bomb.when(val == 5, () => "VALUE IS 5!")),
                  "failed@1, processing: 5 in \\[4, 5, 6\\]", "VALUE IS 5");
        }
示例#14
0
 [Test] public void testLogPrologIsCallable()
 {
     // info(util.Log.prolog() + "some string");
     O.info("some string");
 }