Exemplo n.º 1
0
 public override void setUp()
 {
     base.setUp();
     symbolSystem.richCheap.enterTestMode();
     symbolSystem.dtd.enterTestMode();
     O.zeroTo(leadBars(), i => newBarWithRC(i));
 }
Exemplo n.º 2
0
 public void testSystem()
 {
     addFirstMonth();
     noOrders();
     close(49, 82, 26, 75, 13); // Close of 8/31/2006
     hasOrders(symbols[0], symbols[0].buy("enter long", market(), 408, oneBar()));
     hasOrders(symbols[1], symbols[1].buy("enter long", market(), 244, oneBar()));
     hasOrders(symbols[2], symbols[2].sell("enter short", market(), 3077, oneBar()));
     hasOrders(symbols[3], symbols[3].buy("enter long", market(), 267, oneBar()));
     hasOrders(symbols[4], symbols[4].buy("enter long", market(), 1538, oneBar()));
     O.zeroTo(5, i => fill(symbols[i], 0, 1));
     close(47, 80, 30, 70, 16); // Close of 9/01/2006
     close(48, 79, 31, 71, 14);
     close(49, 82, 26, 75, 13);
     addThreeDays();
     addThreeDays();
     addThreeDays();
     close(47, 80, 30, 70, 16);
     close(48, 79, 31, 71, 14);
     hasPosition(symbols[0], 408);
     hasPosition(symbols[1], 244);
     hasPosition(symbols[2], -3077);
     hasPosition(symbols[3], 267);
     hasPosition(symbols[4], 1538);
     close(49, 82, 26, 75, 13);
     hasOrders(symbols[0], symbols[0].sell("exit on days in trade", market(), 408, oneBar()));
     hasOrders(symbols[1], symbols[1].sell("exit on days in trade", market(), 244, oneBar()));
     hasOrders(symbols[2], symbols[2].buy("exit on days in trade", market(), 3077, oneBar()));
     hasOrders(symbols[3], symbols[3].sell("exit on days in trade", market(), 267, oneBar()));
     hasOrders(symbols[4], symbols[4].sell("exit on days in trade", market(), 1538, oneBar()));
     O.zeroTo(5, i => fill(symbols[i], 0, 1));
 }
Exemplo n.º 3
0
 public void testNullBarDate()
 {
     addThreeDays();
     O.zeroTo(7, i => addThreeDays());
     close(47, 80, 30, 70, 16);
     AreEqual(null, system().barDate);
 }
Exemplo n.º 4
0
 public override void setUp()
 {
     base.setUp();
     O.zeroTo(arguments().leadBars, i => {
         processBar(1, 3, 1, 2);
         noOrders();
     });
 }
Exemplo n.º 5
0
 public override void setUp()
 {
     base.setUp();
     symbolSystem.modelPrice.enterTestMode();
     symbolSystem.actualPrice.enterTestMode();
     symbolSystem.rollDecimal.enterTestMode();
     lastBar = null;
     O.zeroTo(leadBars(), i => close(1, 0, 0, 0));
 }
Exemplo n.º 6
0
 public override void setUp()
 {
     base.setUp();
     symbolSystem.doRunOnTick = true;
     O.zeroTo(arguments().leadBars, i => {
         processBar(1, 3, 1, 2);
         noOrders();
     });
     emailer.allowMessages();
 }
Exemplo n.º 7
0
        protected override void initializeSymbols()
        {
            base.initializeSymbols();
            var names = new List <string>();

            O.zeroTo(50, i => names.Add("sym" + (i + 1)));
            symbols = O.list(O.convert(names, name => new Symbol(name)));
            O.each(symbols, symbol => insertMarket(symbol.name, 0.0));
            O.each(symbols, symbol => insertSymbol("RC." + symbol.name));
        }
Exemplo n.º 8
0
        protected override void initializeSymbols()
        {
            var names = new List <string>();

            O.zeroTo(5, i => names.Add("sym" + (i + 1)));
            symbols = O.list(O.convert(names, name => new Symbol(name)));
            var series = createEmptyTestSeries();

            O.each(symbols, symbol => setupSymbol(symbol, series));
        }
Exemplo n.º 9
0
        public void testMultiThreadDictionaryLookup()
        {
            var refDict = new WeakRefDictionary <Bar, double>();

            O.zeroTo(10000000, i => {
                refDict[new Bar(1, 1, 1, 1)] = 0.0;
                refDict[new Bar(2, 2, 2, 2)] = 1.0;
                new Thread(() => O.toShortString(refDict.Keys)).Start();
                O.toShortString(refDict.Keys);
            });
        }
Exemplo n.º 10
0
 public override void setUp()
 {
     base.setUp();
     symbolSystem.zScore.enterTestMode();
     symbolSystem.residual.enterTestMode();
     symbolSystem.betaShort.enterTestMode();
     symbolSystem.tc.enterTestMode();
     symbolSystem.beta.enterTestMode();
     lastBar = null;
     O.zeroTo(leadBars(), i => close(1, 0, 0, 0, 0, 0));
 }
Exemplo n.º 11
0
 public override void setUp()
 {
     base.setUp();
     symbolSystem.zScore.enterTestMode();
     symbolSystem.residual.enterTestMode();
     symbolSystem.tc.enterTestMode();
     symbolSystem.rSquare.enterTestMode();
     symbolSystem.hedge.enterTestMode();
     symbolSystem.scale.enterTestMode();
     lastBar = null;
     O.zeroTo(leadBars(), i => close(1, 0, 0, 0, 0, 0, -999999));
 }
Exemplo n.º 12
0
 public void addFirstMonth()
 {
     addThreeDays();
     O.zeroTo(7, i => addThreeDays());
     close(47, 80, 30, 70, 16);
     AreEqual(O.jDate("2006-08-29"), system().barDate);
     AreEqual(O.jDate("2006-07-31"), system().refDate);
     AreEqual(O.jDate("2006-08-31"), system().evaluationDate);
     close(48, 79, 31, 71, 14);
     AreEqual(O.jDate("2006-08-30"), system().barDate);
     AreEqual(O.jDate("2006-07-31"), system().refDate);
     AreEqual(O.jDate("2006-08-31"), system().evaluationDate);
     AreEqual(5, system().basketSize);
 }
Exemplo n.º 13
0
 public void testCase3()
 {
     processBar(908, 909, 907.5, 908.25, O.date("2009-06-17 09:00:00"));
     processBar(904.25, 905.5, 902.75, 903.25, O.date("2009-06-17 10:00:00"));
     processBar(913, 913.5, 911.75, 912.25, O.date("2009-06-17 14:00:00"));
     processBar(905.5, 905.75, 905, 905, O.date("2009-06-17 16:00:00"));
     processBar(908.5, 909, 907.5, 908.5, O.date("2009-06-18 09:00:00"));
     processBar(907.25, 913.5, 906.25, 913, O.date("2009-06-18 10:00:00"));
     fill(0, 913);
     processBar(916.25, 916.75, 914.75, 915, O.date("2009-06-18 14:00:00"));
     processBar(912.25, 913.75, 911.5, 913.75, O.date("2009-06-18 16:00:00"));
     fill(0, 913.75);
     processBar(921.25, 921.75, 920.5, 921, O.date("2009-06-19 09:00:00"));
     processBar(921.5, 922.5, 920.75, 921.25, O.date("2009-06-19 10:00:00"));
     fill(0, 921.25);
     processBar(915.5, 916.5, 914.5, 917.5, O.date("2009-06-19 14:00:00"));
     processBar(914.75, 916, 914.75, 916, O.date("2009-06-19 16:00:00"));
     fill(0, 916);
     processBar(906.25, 906.75, 906, 906.25, O.date("2009-06-22 09:00:00"));
     AreEqual(0, symbolSystem.scaleWins[0]);
     AreEqual(1, symbolSystem.scaleWins[1]);
     AreEqual(0.5, symbolSystem.scaleWins[2]);
     AreEqual(0.5, symbolSystem.scaleWins[9]);
     O.zeroTo(27, i => processBar(914.75, 916, 914.75, 916, date("2009-06-22 09:00:00").AddDays(i + 1)));
     AreEqual(0, symbolSystem.scaleWins[0]);
     AreEqual(1, symbolSystem.scaleWins[1]);
     processBar(906.25, 906.75, 906, 906.25, date("2009-06-22 09:00:00").AddDays(29));
     AreEqual(0.5, symbolSystem.scaleWins[0]);
     AreEqual(0.5, symbolSystem.scaleWins[1]);
     processBar(908, 909, 907.5, 908.25, O.date("2009-07-21 09:00:00"));
     processBar(904.25, 905.5, 902.75, 903.25, O.date("2009-07-21 10:00:00"));
     processBar(913, 913.5, 911.75, 912.25, O.date("2009-07-21 14:00:00"));
     processBar(905.5, 905.75, 905, 905, O.date("2009-07-21 16:00:00"));
     processBar(908.5, 909, 907.5, 908.5, O.date("2009-07-22 09:00:00"));
     processBar(907.25, 913.5, 906.25, 913, O.date("2009-07-22 10:00:00"));
     hasOrders(buy("Entry L", limit(913.5), 43, oneDay()));
     fill(0, 913);
     processBar(916.25, 916.75, 914.75, 915, O.date("2009-07-22 14:00:00"));
     processBar(912.25, 913.75, 911.5, 913.75, O.date("2009-07-22 16:00:00"));
     hasOrders(
         sell("Stop L", protectiveStop(908.35), 43, oneDay()),
         sell("Exit EOD L", limit(908.75), 43, oneDay())
         );
     fill(0, 913.75);
     AreEqual(1612.5, symbolSystem.lastTradePNL);
     processBar(921.25, 921.75, 920.5, 921, O.date("2009-06-23 09:00:00"));
     AreEqual(1, symbolSystem.scaleWins[0]);
     AreEqual(0.5, symbolSystem.scaleWins[1]);
 }
Exemplo n.º 14
0
        internal void close(double tri0, double tri1, double tri2, double tri3, double tri4)
        {
            if (lastBars != null)
            {
                processBar(lastBars);
            }
            var tris = O.array(tri0, tri1, tri2, tri3, tri4);

            lastBars = new Dictionary <Symbol, Bar>();
            O.zeroTo(5, i => lastBars.Add(symbols[i], bar(tris[i])));
            processClose(lastBars);
            var jTime = O.jDate(time);

            time = O.date(Dates.businessDaysAhead(1, jTime, "nyb"));
        }
Exemplo n.º 15
0
        public void testMemoryCalculator()
        {
            var l = new List <double>();

            Stopwatch.doMemoryProfiling();
            Stopwatch.start("foo");
            O.zeroTo(10, i => {
                Stopwatch.start("foo");
                l.Add(1.0);
                Stopwatch.stop("foo");
            });
            IsTrue(Stopwatch.bytesUsed("foo") >= 80 && Stopwatch.bytesUsed("foo") < 160, "used " + Stopwatch.bytesUsed("foo"));
            IsTrue(Stopwatch.bytesUsedPer("foo") >= 8 && Stopwatch.bytesUsedPer("foo") < 16);
            Matches("bytes", Stopwatch.report("foo"));
        }
Exemplo n.º 16
0
        public void testAccumulatingSomeRunTime()
        {
            const string A = "a";
            const string B = "b";

            O.zeroTo(10, i => {
                Stopwatch.start(A);
                Objects.sleep(10);
                Stopwatch.stop(A);
            });
            Stopwatch.start(B);
            O.zeroTo(100, i => O.sleep(10));
            Stopwatch.stop(B);
            IsTrue(Stopwatch.millis(A) > 100, "elapsed outside allowed range: " + Stopwatch.millis(A) + " " + Stopwatch.seconds(A));
            IsTrue(Stopwatch.seconds(A) < 0.3, "elapsed outside allowed range: " + Stopwatch.millis(A) + " " + Stopwatch.seconds(A));
            IsTrue(Stopwatch.millis(B) > 1000 && Stopwatch.seconds(B) < 4, "elapsed outside allowed range: " + Stopwatch.seconds(B));
            IsTrue(Stopwatch.millisPer(A) >= 10 && Stopwatch.millisPer(A) < 30);
            Matches("a - total", Stopwatch.report(A));
        }
Exemplo n.º 17
0
 public void testSystem()
 {
     addThreeDays();
     O.zeroTo(7, i => addThreeDays());
     close(47, 80, 30, 70, 16);
     close(48, 79, 31, 71, 14);
     noOrders();
     close(49, 82, 26, 75, 13); // Close of 8/31/2006
     close(47, 80, 30, 70, 16); // Close of 9/01/2006
     close(48, 79, 31, 71, 14);
     close(49, 82, 26, 75, 13);
     addThreeDays();
     addThreeDays();
     addThreeDays();
     close(47, 80, 30, 70, 16);
     close(48, 79, 31, 71, 14);
     close(49, 82, 26, 75, 13);
     O.zeroTo(25, i => addThreeDays());
 }
Exemplo n.º 18
0
 public void addColumns(int n)
 {
     O.zeroTo(n, i => addColumn());
 }
Exemplo n.º 19
0
 public void testSystem()
 {
     addFirstMonth();
     noOrders();
     close(49, 82, 26, 75, 13); // Close of 8/31/2006
     hasOrders(symbols[0], symbols[0].buy("enter long", market(), 408, oneBar()));
     hasOrders(symbols[1], symbols[1].buy("enter long", market(), 244, oneBar()));
     hasOrders(symbols[2], symbols[2].sell("enter short", market(), 1154, oneBar()));
     hasOrders(symbols[3], symbols[3].buy("enter long", market(), 267, oneBar()));
     hasOrders(symbols[4], symbols[4].sell("enter short", market(), 2308, oneBar()));
     AreEqual(O.jDate("2006-08-31"), system().barDate);
     AreEqual(O.jDate("2006-07-31"), system().refDate);
     AreEqual(O.jDate("2006-08-31"), system().evaluationDate);
     AreEqual(O.jDate("2006-08-31"), system().rebalancingDate);
     AreEqual(O.jDate("2006-09-22"), system().tradeExitDate);
     O.zeroTo(5, i => fill(symbols[i], 0, 1));
     close(47, 80, 30, 70, 16); // Close of 9/01/2006
     AreEqual(O.jDate("2006-09-01"), system().barDate);
     AreEqual(O.jDate("2006-07-31"), system().refDate);
     AreEqual(O.jDate("2006-08-31"), system().evaluationDate);
     AreEqual(O.jDate("2006-08-31"), system().rebalancingDate);
     AreEqual(O.jDate("2006-09-22"), system().tradeExitDate);
     hasPosition(symbols[0], 408);
     hasPosition(symbols[1], 244);
     hasPosition(symbols[2], -1154);
     hasPosition(symbols[3], 267);
     hasPosition(symbols[4], -2308);
     close(48, 79, 31, 71, 14);
     close(49, 82, 26, 75, 13);
     addThreeDays();
     addThreeDays();
     addThreeDays();
     close(47, 80, 30, 70, 16);
     close(48, 79, 31, 71, 14);
     hasPosition(symbols[0], 408);
     hasPosition(symbols[1], 244);
     hasPosition(symbols[2], -1154);
     hasPosition(symbols[3], 267);
     hasPosition(symbols[4], -2308);
     AreEqual(O.jDate("2006-09-21"), system().barDate);
     close(49, 82, 26, 75, 13);
     AreEqual(O.jDate("2006-09-22"), system().barDate);
     hasOrders(symbols[0], symbols[0].sell("exit on days in trade", market(), 408, oneBar()));
     hasOrders(symbols[1], symbols[1].sell("exit on days in trade", market(), 244, oneBar()));
     hasOrders(symbols[2], symbols[2].buy("exit on days in trade", market(), 1154, oneBar()));
     hasOrders(symbols[3], symbols[3].sell("exit on days in trade", market(), 267, oneBar()));
     hasOrders(symbols[4], symbols[4].buy("exit on days in trade", market(), 2308, oneBar()));
     O.zeroTo(5, i => fill(symbols[i], 0, 1));
     close(47, 80, 30, 70, 16);
     AreEqual(O.jDate("2006-09-25"), system().barDate);
     AreEqual(O.jDate("2006-08-31"), system().refDate);
     AreEqual(O.jDate("2006-09-29"), system().evaluationDate);
     AreEqual(O.jDate("2006-09-29"), system().rebalancingDate);
     //AreEqual(O.jDate("2006-10-23"), system().tradeExitDate);
     noOrders();
     close(48, 79, 31, 71, 14);
     close(49, 82, 26, 75, 13);
     close(47, 80, 30, 70, 16);
     close(48, 79, 31, 71, 14);
     hasOrders(symbols[0], symbols[0].buy("enter long", market(), 417, oneBar()));
     hasOrders(symbols[1], symbols[1].sell("enter short", market(), 380, oneBar()));
     hasOrders(symbols[2], symbols[2].buy("enter long", market(), 645, oneBar()));
     hasOrders(symbols[3], symbols[3].sell("enter short", market(), 423, oneBar()));
     hasOrders(symbols[4], symbols[4].buy("enter long", market(), 1429, oneBar()));
 }
Exemplo n.º 20
0
 public override void setUp()
 {
     base.setUp();
     O.zeroTo(leadBars(), i => processBar(0, 0, 0, 0));
 }
Exemplo n.º 21
0
 public void testRaceCondition()
 {
     O.zeroTo(10000000, i => new WeakRef <Bar>(new Bar(1, 1, 1, 1)).safeValue());
 }