Ejemplo n.º 1
0
 public override void GotTick(Tick tick)
 {
     if (RequestedForSymbol.getindex(tick.symbol) == GenericTracker.UNKNOWN
         || RequestedForSymbol[tick.symbol] == false)
     {
         RequestedForSymbol.addindex(tick.symbol, true);
         Order myOrder = new MOCOrder(tick.symbol, true, 100);
         sendorder(myOrder);
         //senddebug(myOrder.TIF);
         senddebug("Sent Order: " + myOrder);
     }
 }
Ejemplo n.º 2
0
        ///////////////////////////////////////////////////////////////////////
        // TradeLink Hooks
        ///////////////////////////////////////////////////////////////////////
        public override void GotTick(Tick tick)
        {
            if (RequestedForSymbol.getindex(tick.symbol) == GenericTracker.UNKNOWN
                || RequestedForSymbol[tick.symbol] == false)
            {
                RequestedForSymbol.addindex(tick.symbol, true);

                // send opening order
                Order Opener = new OrderImpl(tick.symbol, true, 100);
                sendorder(Opener);

                // send closing order
                Order Closer = new MOCOrder(tick.symbol, false, 100);
                sendorder(Closer);
                senddebug("Sent Order: " + Closer);
            }
        }
Ejemplo n.º 3
0
        public void MOCs()
        {
            Broker broker = new Broker();
            const string s = "TST";
            OrderImpl moc = new MOCOrder(s, true, 200);
            Assert.IsTrue(moc.ValidInstruct == OrderInstructionType.MOC, "unexpected order instruction: " + moc.ValidInstruct);
            Assert.AreEqual(0, broker.SendOrderStatus(moc), "send moc order failed");

            TickImpl openingTick = TickImpl.NewTrade(s, Util.ToTLDate(DateTime.Now), Util.TL2FT(9, 30, 00), 9, 10000, "NYS");
            TickImpl endMornTick = TickImpl.NewTrade(s, Util.ToTLDate(DateTime.Now), Util.TL2FT(12, 00, 00), 9, 10000, "NYS");
            TickImpl endLunchTick = TickImpl.NewTrade(s, Util.ToTLDate(DateTime.Now), Util.TL2FT(14, 15, 00), 9, 10000, "NYS");
            TickImpl closingTick = TickImpl.NewTrade(s, Util.ToTLDate(DateTime.Now), Util.TL2FT(16, 00, 00), 9, 10000, "NYS");

            int c = 0;
            c = broker.Execute(openingTick); Assert.AreEqual(0, c,"MOC filled on open");
            c = broker.Execute(endMornTick); Assert.AreEqual(0, c, "MOC filled in morning");
            c = broker.Execute(endLunchTick); Assert.AreEqual(0, c, "MOC filled at lunch");
            c = broker.Execute(closingTick); Assert.AreEqual(1, c, "MOC did not fill at close"); // should execute on the first tick at/after 16:00:00
        }