Пример #1
0
        // OnNxCoreQuote: Function to handle NxCore ExgQuote messages.
        //--------------------------------------------------------------
        static unsafe void OnNxCoreExgQuote(NxCoreSystem *pNxCoreSys, NxCoreMessage *pNxCoreMsg)
        {
            // Get the symbol for category message
            String Symbol = new String(&pNxCoreMsg->coreHeader.pnxStringSymbol->String);

            // Assign a pointer to the ExgQuote data
            NxCoreExgQuote *Quote = &pNxCoreMsg->coreData.ExgQuote;

            // Get bid and ask price
            double Bid = NxCore.PriceToDouble(Quote->coreQuote.BidPrice, Quote->coreQuote.PriceType);
            double Ask = NxCore.PriceToDouble(Quote->coreQuote.AskPrice, Quote->coreQuote.PriceType);

            // Write out Symbol, Time, Bid, Ask, Bidsize, Asksize, Reporting Exg
            Console.WriteLine("ExgQuote for Symbol: {0:S}, Time: {1:d}:{2:d}:{3:d}  Bid: {4:f}  Ask: {5:f}  BidSize: {6:d}  AskSise: {7:d}  Exchg: {8:d} ",
                              Symbol,
                              pNxCoreMsg->coreHeader.nxExgTimestamp.Hour, pNxCoreMsg->coreHeader.nxExgTimestamp.Minute, pNxCoreMsg->coreHeader.nxExgTimestamp.Second,
                              Bid, Ask, Quote->coreQuote.BidSize, Quote->coreQuote.AskSize,
                              pNxCoreMsg->coreHeader.ReportingExg);
        }
Пример #2
0
        static unsafe void OnNxCoreExgQuote(NxCoreSystem *pNxCoreSys, NxCoreMessage *pNxCoreMsg)
        {
            if (keepcurrent && (STATUS < 4))
            {
                return;
            }
            if (DOLIVESKIPTEST)
            {
                if (pNxCoreSys->nxTime.MsOfDay < (DateTime.UtcNow.TimeOfDay.TotalMilliseconds - (DateTime.Now.IsDaylightSavingTime() ? (1000 * 60 * 60 * 4) : (1000 * 60 * 60 * 5))))
                {
                    return;
                }
                DOLIVESKIPTEST = false;
                D("NxCore starting realtime data");
            }
            // Get the symbol for category message

            int idx = _nxsyms.getindex(new string(&pNxCoreMsg->coreHeader.pnxStringSymbol->String));

            if (idx < 0)
            {
                return;
            }
            if (!_nxsyms[idx])
            {
                return;
            }

            // Assign a pointer to the ExgQuote data
            NxCoreExgQuote *Quote = &pNxCoreMsg->coreData.ExgQuote;
            NxCoreQuote     cq    = Quote->coreQuote;
            // Get bid and ask price
            double bid  = 0;
            double ask  = 0;
            int    bs   = 0;
            int    os   = 0;
            string be   = string.Empty;
            string oe   = string.Empty;
            bool   bbid = false;
            bool   bask = false;

            if ((cq.BidPriceChange != 0) || (cq.BidSizeChange != 0))
            {
                bid  = NxCore.PriceToDouble(Quote->coreQuote.BidPrice, Quote->coreQuote.PriceType);
                bs   = Quote->coreQuote.BidSize;
                be   = excode2name(Quote->BestBidExg);
                bbid = true;
            }
            if ((cq.AskPriceChange != 0) || (cq.AskSizeChange != 0))
            {
                ask  = NxCore.PriceToDouble(Quote->coreQuote.AskPrice, Quote->coreQuote.PriceType);
                os   = Quote->coreQuote.AskSize;
                oe   = excode2name(Quote->BestAskExg);
                bask = true;
            }
            if (bask || bbid)
            {
                NxTime time   = pNxCoreMsg->coreHeader.nxExgTimestamp;
                int    tltime = time.Hour * 10000 + time.Minute * 100 + time.Second;
                NxDate date   = pNxCoreMsg->coreHeader.nxSessionDate;
                int    tldate = (int)date.Year * 10000 + (int)date.Month * 100 + (int)date.Day;
                Tick   k      = new TickImpl();
                k.symbol = _realsym2nxidx.getlabel(idx);
                k.date   = tldate;
                k.time   = tltime;
                if (bask && bbid)
                {
                    k.bid = (decimal)bid;
                    k.bs  = bs;
                    k.be  = be;
                    k.ask = (decimal)ask;
                    k.os  = os;
                    k.oe  = oe;
                }
                else if (bbid)
                {
                    k.bid = (decimal)bid;
                    k.bs  = bs;
                    k.be  = be;
                }
                else
                {
                    k.ask = (decimal)ask;
                    k.os  = os;
                    k.oe  = oe;
                }
                try
                {
                    tl.newTick(k);
                }
                catch (Exception ex)
                {
                    D("bad tick: " + k.ToString() + " " + ex.Message + ex.StackTrace);
                }
            }
        }