Ejemplo n.º 1
0
        static unsafe void OnNxCoreMMQuote(NxCoreSystem* pNxCoreSys, NxCoreMessage* pNxCoreMsg)
        {

        }
Ejemplo n.º 2
0
        static unsafe void OnNxCoreTrade(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 Trade data
            NxCoreTrade* Trade = &pNxCoreMsg->coreData.Trade;
            // Get the price and net change
            double Price = NxCore.PriceToDouble(Trade->Price, Trade->PriceType);
            //double NetChange = NxCore.PriceToDouble(Trade->NetChange, Trade->PriceType);
            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;
            string ex = excode2name(pNxCoreMsg->coreHeader.ReportingExg);
            int size = (int)Trade->Size;
            // check for index
            if (size <= 0) return;
            Tick k = new TickImpl();
            k.symbol = _realsym2nxidx.getlabel(idx);
            k.date = tldate;
            k.time = tltime;
            k.trade = (decimal)Price;
            k.ex = ex;
            k.size = size;
            try
            {
                tl.newTick(k);
            }
            catch (Exception e)
            {
                D("bad tick: " + k.symbol + " " + Price + " " + size + " " + ex + " " + e.Message + e.StackTrace);
            }
        }
Ejemplo n.º 3
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);
                }
            }
        }
Ejemplo n.º 4
0
        static unsafe void OnNxCoreStatus(NxCoreSystem* pNxCoreSys, NxCoreMessage* pNxCoreMsg)
        {
            if (DOSAVESTATE)
            {
                if (pNxCoreSys->nxTime.MsOfDay >= nextstatesavetime)
                {
                    D("saving state at: " + nextstatesavetime + " " + statefilepath);
                    NxCore.SaveState(statefilepath, NxCore.NxSAVESTATE_ONEPASS);
                    if (nextstatesavetime == 0)
                        nextstatesavetime = pNxCoreSys->nxTime.MsOfDay;
                    nextstatesavetime += savestateint;
                    D("save complete.  next save time: " + nextstatesavetime);


                }
            }
            STATUS = pNxCoreSys->StatusData;
            // Print the specific NxCore status message
            switch (pNxCoreSys->Status)
            {
                case NxCore.NxCORESTATUS_COMPLETE:
                    D("NxCore Complete Message.");
                    break;
                case NxCore.NxCORESTATUS_INITIALIZING:
                    D("NxCore Initialize Message.");
                    break;
                case NxCore.NxCORESTATUS_SYNCHRONIZING:
                    D("NxCore Synchronizing Message.");
                    break;
                case NxCore.NxCORESTATUS_WAITFORCOREACCESS:
                    {
                        //D("NxCore Wait For Access.");
                        break;
                    }
                case NxCore.NxCORESTATUS_RESTARTING_TAPE:
                    D("NxCore Restart Tape Message.");
                    break;
                case NxCore.NxCORESTATUS_ERROR:
                    D("NxCore Error.");
                    break;
                case NxCore.NxCORESTATUS_RUNNING:
                    break;
                case NxCore.NxCORESTATUS_LOADED_STATE:
                    D("Nxcore has been loaded from a saved state.");
                    break;
                case NxCore.NxCORESTATUS_SAVING_STATE:
                    D("Nxcore is now saving it's current state.");
                    break;
            }
        }