Ejemplo n.º 1
0
        void stiQuote_OnSTIQuoteUpdate(ref structSTIQuoteUpdate q)
        {
            Tick k = new TickImpl(q.bstrSymbol);

            k.bid = (decimal)q.fBidPrice;
            k.ask = (decimal)q.fAskPrice;
            k.bs  = q.nBidSize / 100;
            k.os  = q.nAskSize / 100;
            if (q.bstrExch != "*")
            {
                k.ex = q.bstrExch;
            }
            if (q.bstrBidExch != "*")
            {
                k.be = q.bstrBidExch;
            }
            if (q.bstrAskExch != "*")
            {
                k.oe = q.bstrAskExch;
            }
            int now = Convert.ToInt32(q.bstrUpdateTime);

            k.date = Util.ToTLDate(DateTime.Now);
            int sec = now % 100;

            k.time  = now;
            k.trade = (decimal)q.fLastPrice;
            k.size  = q.nLastSize;
            tl.newTick(k);
            if ((q.bValidMktImb == 0) || !imbalance)
            {
                return;
            }
            tl.newImbalance(new ImbalanceImpl(k.symbol, k.ex, q.nMktImbalance, k.time, 0, 0, 0));
        }
Ejemplo n.º 2
0
        private void api_LevelOneStreaming(object sender, Axtdaactx.ITDAAPICommEvents_OnL1QuoteEvent e)
        {
            DateTime DT = new DateTime(1970, 1, 1);
            //Axtdaactx.AxTDAL1Quote quote = (Axtdaactx.AxTDAL1Quote)e.quote;

            //if (args.FunctionType != AmeritradeBrokerAPI.RequestState.AsyncType.LevelOneStreaming) return;
            Tick t = new TickImpl();

            /*  don't understand the time format provided here
             * int date = 0;
             * int ttime = 0;
             * if (int.TryParse(args.oLevelOneData[0].quotedate, out date))
             *  t.date = date;
             * if (int.TryParse(args.oLevelOneData[0].quotetime, out ttime))
             *  t.time = ttime;
             */
            t.date   = Util.ToTLDate(DateTime.Now);
            t.time   = Util.DT2FT(DateTime.Now);
            t.symbol = e.quote.Symbol;
            t.bid    = Convert.ToDecimal(e.quote.Bid);
            t.ask    = Convert.ToDecimal(e.quote.Ask);
            t.ex     = e.quote.Exchange.ToString();
            t.trade  = Convert.ToDecimal(e.quote.Last);
            t.size   = Convert.ToInt32(e.quote.LastSize) * 100;
            t.bs     = Convert.ToInt32(e.quote.BidSize);
            t.os     = Convert.ToInt32(e.quote.AskSize);
            tl.newTick(t);

            //debug(t.symbol + " " + t.ltrade + "\n");
        }
Ejemplo n.º 3
0
        void SimBroker_GotOrderCancel(string sym, bool side, uint id)
        {
            // if we get an order cancel notify from the broker, pass along to our clients
            tl.newOrderCancel(id);
            // send the updated book to our clients for same side as order
            Tick book = OrderToTick(h.SimBroker.BestBidOrOffer(sym, side));

            tl.newTick(book);
        }
Ejemplo n.º 4
0
        void MBTQUOTELib.IMbtQuotesNotify.OnTSData(ref TSRECORD pRec)
        {
            TickImpl k = new TickImpl();

            k.symbol = pRec.bstrSymbol;
            enumTickType tt = (enumTickType)pRec.lType;

            switch (tt)
            {
            case enumTickType.ttAskTick:
                k.ask = (decimal)pRec.dPrice;
                k.oe  = pRec.bstrExchange;
                k.os  = pRec.lSize;
                break;

            case enumTickType.ttBidTick:
                k.bid = (decimal)pRec.dPrice;
                k.be  = pRec.bstrExchange;
                k.bs  = pRec.lSize;
                break;

            case enumTickType.ttTradeTick:
                k.trade = (decimal)pRec.dPrice;
                k.ex    = pRec.bstrExchange;
                k.size  = pRec.lSize;
                break;
            }
            tl.newTick(k);
        }
Ejemplo n.º 5
0
        void rs_LevelOneStreaming_TickWithArgs(DateTime time, AmeritradeBrokerAPI.ATradeArgument args)
        {
            if (args.FunctionType != AmeritradeBrokerAPI.RequestState.AsyncType.LevelOneStreaming)
            {
                return;
            }
            Tick t = new TickImpl();

            /*  don't understand the time format provided here
             * int date = 0;
             * int ttime = 0;
             * if (int.TryParse(args.oLevelOneData[0].quotedate, out date))
             *  t.date = date;
             * if (int.TryParse(args.oLevelOneData[0].quotetime, out ttime))
             *  t.time = ttime;
             */
            t.date   = Util.ToTLDate(DateTime.Now);
            t.time   = Util.DT2FT(DateTime.Now);
            t.symbol = args.oLevelOneData[0].stock;
            t.bid    = Convert.ToDecimal(args.oLevelOneData[0].bid);
            t.ask    = Convert.ToDecimal(args.oLevelOneData[0].ask);
            t.ex     = args.oLevelOneData[0].exchange;
            t.trade  = Convert.ToDecimal(args.oLevelOneData[0].last);
            t.size   = Convert.ToInt32(args.oLevelOneData[0].lastsize) * 100;
            t.bs     = Convert.ToInt32(args.oLevelOneData[0].bid_size);
            t.os     = Convert.ToInt32(args.oLevelOneData[0].ask_size);
            tl.newTick(t);
        }
Ejemplo n.º 6
0
        public void TickTests()
        {
            // havent' sent any ticks, so shouldn't have any counted
            Assert.That(ticks == 0, ticks.ToString());

            // have to subscribe to a stock to get notified on fills for said stock
            c.Subscribe(new BasketImpl(new SecurityImpl(SYM)));

            //send a tick from the server
            TickImpl t = TickImpl.NewTrade(SYM, 10, 100);

            s.newTick(t);

            // make sure the client got it
            Assert.That(ticks == 1, ticks.ToString());
            // make sure other clients did not get ticks
            // (cause we didnt' subscribe from other clients)
            Assert.AreNotEqual(copyticks, ticks);
        }