Exemple #1
0
 protected void start()
 {
     RealtimeDataCenter.getInstance().registry(getCodes(), this);
     this.th = new Thread(this.worker)
     {
         IsBackground = true
     };
     this.th.Start();
 }
Exemple #2
0
        protected void unregistry(string code)
        {
            if (this.ssCode.Contains(code))
            {
                this.ssCode.Remove(code);
            }

            if (this.th != null)
            {
                RealtimeDataCenter.getInstance().unregistry(code, this);
            }
        }
Exemple #3
0
        private void worker()
        {
            List <RealtimeDataCenter.RealtimeData> ltRd = new List <RealtimeDataCenter.RealtimeData>();

            bool bHasData = true;

            while (true)
            {
                if (!bHasData)
                {
                    System.Threading.Thread.Sleep(1);
                }

                RealtimeDataCenter.getInstance().getData(this, ref ltRd);
                if (ltRd.Count <= 0)
                {
                    bHasData = false;
                }
                else
                {
                    bHasData = true;

                    this.bNeedSort = false;
                    foreach (var rd in ltRd)
                    {
                        recv(rd); //this.bNeedSort' value may be changed in here
                    }

                    if (bNeedSort)
                    {
                        sort();
                        this.bNeedSort = false;
                    }

                    ltRd.Clear();
                }

                if (this.iTimerMS >= 0)
                {
                    TimeSpan tsNow  = new TimeSpan(DateTime.Now.Ticks);
                    TimeSpan tsLast = new TimeSpan(this.dtTimerLast.Ticks);
                    if (tsNow.Subtract(tsLast).TotalMilliseconds >= this.iTimerMS)
                    {
                        timer();
                        this.dtTimerLast = DateTime.Now;
                    }
                }
            }
        }
Exemple #4
0
        protected bool registry(string code)
        {
            if (this.ssCode.Contains(code))
            {
                return(false);
            }

            this.ssCode.Add(code);
            if (this.th != null)
            {
                RealtimeDataCenter.getInstance().registry(code, this);
            }

            return(true);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            /*
             * string szTime = DateTime.Now.ToString("HHmmss");
             * while (string.Compare(szTime, "091500") < 0
             || string.Compare(szTime, "150000") > 0)
             ||{
             || Console.WriteLine(szTime);
             || System.Threading.Thread.Sleep(1000);
             || szTime = DateTime.Now.ToString("HHmmss");
             ||}
             */

            StringBuilder sErrInfo = new StringBuilder(256);
            int           ret      = TradeXB.OpenTdx(sErrInfo);

            if (ret < 0)
            {
                Console.WriteLine("TradeXB.OpenTdx error: " + sErrInfo);
                Console.ReadLine();
                return;
            }

            RealtimeDataCenter.getInstance(5, "999999,399001,399006", RealtimeDataCenter.EDataSource.tradeX);
            Limit.getInstance();
            Reactor.getInstance();

            TN   tn   = new TN();
            MAID maid = new MAID();
            RI   ri   = new RI();
            RT   rt   = new RT();

            while (true)
            {
                Console.ReadLine();
            }
        }
Exemple #6
0
 protected void stop()
 {
     RealtimeDataCenter.getInstance().unregistry(getCodes(), this);
     this.th.Abort();
 }