コード例 #1
0
ファイル: TestOrderDuration.cs プロジェクト: TzarIvan/ratel
        public void testOrderDuration()
        {
            var fillKill = symbol().buy("fill or kill", stop(10), 100, fillOrKill());

            processBar(1, 1, 1, 1);
            symbolSystem.placeOrder(fillKill);
            hasOrders(fillKill);
            processTick(1);
            noOrders();
            fillKill = symbol().buy("fill or kill", stop(10), 100, fillOrKill());
            symbolSystem.placeOrder(fillKill);
            processBar(1, 1, 1, 1);
            noOrders();
            var bar = symbol().buy("one bar", stop(10), 100, oneBar());

            symbolSystem.placeOrder(bar);
            hasOrders(bar);
            processTick(1);
            hasOrders(bar);
            processTick(1);
            hasOrders(bar);
            O.freezeNow("2001/02/03 04:05:06");
            processBar(1, 1, 1, 1, O.now());
            noOrders();
            var dayOrder = symbol().buy("day", stop(10), 100, oneDay());

            symbolSystem.placeOrder(dayOrder);
            hasOrders(dayOrder);
            processBar(1, 1, 1, 1, O.now().AddHours(1));
            hasOrders(dayOrder);
            processBar(1, 1, 1, 1, O.now().AddDays(1));
            noOrders();
        }
コード例 #2
0
        static object prolog()
        {
            var thread    = O.paren("c" + Thread.CurrentThread.ManagedThreadId);
            var reallyNow = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
            var frozenNow = Dates.nowFrozen() ? O.paren(O.ymdHuman(O.now())) : "";

            return(thread + " " + reallyNow + frozenNow + ": ");
        }
コード例 #3
0
        public void testTimerSequence()
        {
            Objects.freezeNow("2008/11/11 11:11:11");
            double currentState = -1;
            var    sequence     = new TimerSequence <double>(d => { currentState = d; });

            sequence.add(1.1, 500);
            sequence.add(2.2, 500);
            sequence.add(3.3);
            IsFalse(sequence.running());
            // starts in 1.1
            sequence.startAsOf(O.now());
            O.wait(() => currentState == 1.1);
            IsTrue(sequence.running());
            Objects.advanceNow(500);
            O.wait(() => currentState == 2.2);
            Objects.advanceNow(500);
            O.wait(() => currentState == 3.3);
            IsFalse(sequence.running());

            sequence.startAsOf(O.now());
            O.wait(() => currentState == 1.1);
            Objects.advanceNow(500);
            O.wait(() => currentState == 2.2);
            sequence.startAsOf(O.now());
            O.wait(() => currentState == 1.1);
            Objects.advanceNow(500);
            O.wait(() => currentState == 2.2);
            Objects.advanceNow(500);
            O.wait(() => currentState == 3.3);

            // starts in 2.2
            var asOf = O.now();

            Objects.advanceNow(500);
            sequence.startAsOf(asOf);
            O.wait(() => currentState == 2.2);
            Objects.advanceNow(500);
            O.wait(() => currentState == 3.3);

            // starts in 3.3
            asOf         = O.now();
            currentState = -1;
            Objects.advanceNow(1000);
            sequence.startAsOf(asOf);
            O.wait(() => currentState == 3.3);
        }
コード例 #4
0
 static DateTime millisAhead(int millis)
 {
     return(O.now().AddMilliseconds(millis));
 }