private void publishPrices(string myMnemonic, string myOfferSz, string myOfferPx, string myBidPx, string myBidSz, string myTradePx, string myTradeSz)
        {
            try
            {
                K2DataObjects.PXUpdateBase upd = new K2DataObjects.PXUpdateBase();
                upd.Mnemonic = myMnemonic;
                upd.BidPrice = decimal.Parse(myBidPx);
                upd.BidSize = decimal.Parse(myBidSz);
                upd.OfferPrice = decimal.Parse(myOfferPx);
                upd.OfferSize = decimal.Parse(myOfferSz);
                upd.TradePrice = decimal.Parse(myTradePx);
                upd.TradeVolume = decimal.Parse(myTradeSz);
                m_Simulator.ApplyPriceUpdate(upd);
            }
            catch (Exception myE)
            {

            }
        }
        private void runPlayBack()
        {
            try
            {
                string myLine = "";
                m_RunPlayBack = true;
                m_ReceivedUpdates = 0;
                K2DataObjects.PXUpdateBase pxUpdate;
                long startTicks = 0;
                int sleepTime = 50;
                while ((!m_Sr.EndOfStream) && (m_RunPlayBack))
                {
                    myLine = m_Sr.ReadLine();
                    if (myLine[0] == '#')
                    {
                        m_Log.Info(myLine);
                        if (myLine.IndexOf("#XML") >= 0)
                        {
                            setupProduct(myLine);
                        }
                    }
                    else
                    {
                        pxUpdate = new K2DataObjects.PXUpdateBase("FILE");
                        pxUpdate.From(myLine, ',');

                        pxUpdate.Mnemonic = "S." + pxUpdate.Mnemonic;
                        if (startTicks > 0)
                        {
                            sleepTime = (int)(pxUpdate.Ticks - startTicks)/10000;
                            startTicks = pxUpdate.Ticks;

                        }
                        else
                        {
                            sleepTime = this.Interval;
                            startTicks = pxUpdate.Ticks;
                        }

                        if (this.m_RunRealTime)
                        {
                            if (sleepTime < 0)
                            {
                                sleepTime = 1;
                            }
                            Thread.Sleep(sleepTime);
                        }
                        else
                        {
                            Thread.Sleep(this.Interval);
                        }
                        this.updateClients(pxUpdate);

                        m_ReceivedUpdates++;
                    }

                }
                if (m_Sr.EndOfStream)
                {
                    updateClients(SrcStatus.ended);
                }
            }
            catch (Exception myE)
            {
                m_Log.Error("runPlayBack", myE);
            }
        }
Exemple #3
0
        private void generateProductPrices(SimulatorProduct product)
        {
            try
            {
                K2DataObjects.PXUpdateBase pxupdate = new K2DataObjects.PXUpdateBase(m_ID);
                pxupdate.Mnemonic = product.Mnemonic;

                pxupdate.BidSize = m_RNGen.Next(100);
                pxupdate.OfferSize = m_RNGen.Next(100);
                pxupdate.BidPrice = product.LowPrice;
                pxupdate.OfferPrice = pxupdate.BidPrice + 1;
                pxupdate.TradePrice = ((pxupdate.BidPrice + pxupdate.OfferPrice) / 2);
                pxupdate.TradeVolume = (pxupdate.BidSize + pxupdate.OfferSize) / 2;
                pxupdate.DayHigh = product.HighPrice;
                pxupdate.DayLow = product.LowPrice;
                if (product.LowPrice != product.HighPrice)
                {
                    pxupdate.BidPrice = (int)product.LowPrice + m_RNGen.Next(10);
                    pxupdate.OfferPrice = pxupdate.BidPrice + 1;
                    pxupdate.TradePrice = ((pxupdate.BidPrice + pxupdate.OfferPrice) / 2);
                }

                pxupdate.Ticks = DateTime.Now.Ticks;

                PriceUpdate(pxupdate);

            }
            catch (Exception myE)
            {

            }
        }