예제 #1
0
        void ReadTick()
        {
//            System.Diagnostics.Debug.Write("Am I called here? Tick in AR");
            try
            {
                while (_readtick)
                {
                    if (_tickcache.hasItems && (GotTickQueued != null))
                    {
                        GotTickQueued();
                    }
                    while (_tickcache.hasItems)
                    {
                        //                       System.Diagnostics.Debug.Write("Am I called here? Processing Tick in AR");
                        if (!_readtick)
                        {
                            break;
                        }
                        Tick k = _tickcache.Read();
                        if (k == null)
                        {
                            _nrt++;
                            if (GotBadTick != null)
                            {
                                GotBadTick();
                            }
                            continue;
                        }
                        if (GotTick != null)
                        {
                            GotTick(k);
                        }
                    }
                    // send event that queue is presently empty
                    if (_tickcache.isEmpty && (GotTickQueueEmpty != null))
                    {
                        GotTickQueueEmpty();
                    }
                    // clear current flag signal
                    _tickswaiting.Reset();
                    // wait for a new signal to continue reading
                    _tickswaiting.WaitOne(SLEEP);
                }
            }
            catch (MissingMethodException ex)
            {
                System.Diagnostics.Process.Start(@"http://code.google.com/p/tradelink/wiki/MissingMethodException");
                Stop();
            }
            catch (MissingMemberException ex)
            {
                System.Diagnostics.Process.Start(@"http://code.google.com/p/tradelink/wiki/MissingMethodException");
                Stop();
            }
            catch (ThreadInterruptedException) { }
        }
예제 #2
0
        void ReadImbs()
        {
            System.Diagnostics.Debug.Write("Am I called here? Imbalance in AR");
            try
            {
                while (_readimb)
                {
                    if (_imbcache.hasItems && (GotImbalanceQueued != null))
                    {
                        GotImbalanceQueued();
                    }
                    while (_imbcache.hasItems)
                    {
                        if (!_readimb)
                        {
                            break;
                        }
                        Imbalance imb = _imbcache.Read();
                        if (imb == null)
                        {
                            _nir++;
                            if (GotBadImbalance != null)
                            {
                                GotBadImbalance();
                            }
                            continue;
                        }
                        if (GotImbalance != null)
                        {
                            GotImbalance(imb);
                        }
                    }
                    // send event that queue is presently empty
                    if (_imbcache.isEmpty && (GotImbalanceQueueEmpty != null))
                    {
                        GotImbalanceQueueEmpty();
                    }

                    // clear current flag signal
                    _imbswaiting.Reset();
                    // wait for a new signal to continue reading
                    _imbswaiting.WaitOne(SLEEP);
                }
            }
            catch (ThreadInterruptedException) { }
        }
예제 #3
0
        void readdata(object obj)
        {
            while (_readergo)
            {
                try {
                    while (_kbuf.hasItems)
                    {
                        Tick k = _kbuf.Read();
                        if (gotTick != null)
                        {
                            gotTick(k);
                        }
                    }

                    while (_obuff.hasItems)
                    {
                        Order o = _obuff.Read();
                        if (gotOrder != null)
                        {
                            gotOrder(o);
                        }
                    }

                    while (_cbuff.hasItems)
                    {
                        long c = _cbuff.Read();
                        if (gotOrderCancel != null)
                        {
                            gotOrderCancel(c);
                        }
                    }

                    while (_fbuff.hasItems)
                    {
                        Trade f = _fbuff.Read();
                        if (gotFill != null)
                        {
                            gotFill(f);
                        }
                    }

                    while (_mbuff.hasItems)
                    {
                        GenericMessage m = _mbuff.Read();
                        if (gotUnknownMessage != null)
                        {
                            gotUnknownMessage(m.Type, m.Source, m.Dest, m.ID, m.Request, ref m.Response);
                        }
                    }

                    while (_mqbuff.hasItems)
                    {
                        GenericMessage m = _mqbuff.Read();
                        if (gotUnknownMessage != null)
                        {
                            gotUnknownMessage(m.Type, m.Source, m.Dest, m.ID, m.Request, ref m.Response);
                        }
                    }

                    while (_pbuff.hasItems)
                    {
                        Position p = _pbuff.Read();
                        if (gotPosition != null)
                        {
                            gotPosition(p);
                        }
                    }

                    while (_abuff.hasItems)
                    {
                        string acct = _abuff.Read();
                        if (gotAccounts != null)
                        {
                            gotAccounts(acct);
                        }
                    }


                    Thread.Sleep(100);
                }
                catch (ThreadInterruptedException) { _interrupts++; }
            }
        }