Пример #1
0
        public void ThrottlesTest()
        {
            LimitsTest b = new LimitsTest();
            // we're skipping the first trade bc it's pre-market and we're not testing
            // that in this test
            int      i = 1;
            Order    o;
            Position p = new Position(s);

            Assert.That(b.Turns == 0);
            Assert.That(b.Adjusts == 0);
            Assert.That(b.TradeCaps);
            Assert.That(!b.Off);
            Assert.That(b.PosSize == 0);
            o = b.Trade(timesales[i++], new BarList(), p, new BoxInfo());
            Assert.That(o.isValid);
            // fill our order with next tick and just our position
            o.Fill(timesales[i]);
            p.Adjust((Trade)o);
            Assert.That(b.Adjusts == 1);
            Assert.That(b.Turns == 0);
            o = b.Trade(timesales[i++], new BarList(), p, new BoxInfo());
            Assert.That(o.isValid);
            Assert.That(b.Adjusts == 2);
            Assert.That(b.Turns == 1); // should be flat now
            o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo());
            Assert.That(!o.isValid);   // no more orders, as
            Assert.That(b.Off);        // we should be shutdown
        }
Пример #2
0
 public void ThrottlesTest()
 {
     LimitsTest b = new LimitsTest();
     // we're skipping the first trade bc it's pre-market and we're not testing
     // that in this test
     int i = 1;
     Order o;
     Position p = new Position(s);
     Assert.That(b.Turns == 0);
     Assert.That(b.Adjusts == 0);
     Assert.That(b.TradeCaps);
     Assert.That(!b.Off);
     Assert.That(b.PosSize == 0);
     o = b.Trade(timesales[i++], new BarList(), p, new BoxInfo());
     Assert.That(o.isValid);
     // fill our order with next tick and just our position
     o.Fill(timesales[i]);
     p.Adjust((Trade)o);
     Assert.That(b.Adjusts == 1);
     Assert.That(b.Turns == 0);
     o = b.Trade(timesales[i++], new BarList(), p, new BoxInfo());
     Assert.That(o.isValid);
     Assert.That(b.Adjusts == 2);
     Assert.That(b.Turns == 1); // should be flat now
     o = b.Trade(timesales[i++], new BarList(), new Position(s), new BoxInfo());
     Assert.That(!o.isValid); // no more orders, as
     Assert.That(b.Off); // we should be shutdown
 }