예제 #1
0
파일: Program.cs 프로젝트: cadoogi/IBNet
 static void client_TickSize(object sender, TickSizeEventArgs e)
 {
     Console.WriteLine("Tick Size: " + e.Size + " Tick Type: " + EnumDescConverter.GetEnumDescription(e.TickType));
 }
예제 #2
0
        void client_TickSize(object sender, TickSizeEventArgs e)
        {
            Symbol symbol = null;
            TickData data;
            GotTickData listener = null;

            lock (_lockObject)
            {
                symbol = idToSymbol(e.TickerId);
                if (symbol == null)
                {
                    //	Not a watched symbol
                    return;
                }

                data = new TickData();
                data.time = GetAccountTime("size tick");
                data.size = AdjustVolume(symbol, (UInt64)e.Size);
                if (e.TickType == KRSTickType.BidSize)
                {
                    //	Bid size
                    data.tickType = TickType.Bid;
                    lastBidPrices.TryGetValue(symbol, out data.price);
                    lastBidSizes[symbol] = data.size;
                }
                else if (e.TickType == KRSTickType.AskSize)
                {
                    //	Ask size
                    data.tickType = TickType.Ask;
                    lastAskPrices.TryGetValue(symbol, out data.price);
                    lastAskSizes[symbol] = data.size;
                }
                else if (e.TickType == KRSTickType.LastSize)
                {
                    //	Last Size
                    return;
                    //data.tickType = TickType.LastSize;
                }
                else if (e.TickType == KRSTickType.Volume)
                {
                    //	Volume
                    bool bSend = true;
                    UInt64 lastVolume;
                    TickData tradeTick = new TickData();
                    if (!lastVolumes.TryGetValue(symbol, out lastVolume))
                    {
                        bSend = false;
                    }
                    else if ((UInt64)e.Size <= lastVolume)
                    {
                        bSend = false;
                    }
                    else if (!lastPrices.TryGetValue(symbol, out tradeTick.price))
                    {
                        bSend = false;
                    }
                    //if (lastVolume == -1 || data.value <= lastVolume)
                    //{
                    //    bSend = false;
                    //}

                    if (bSend)
                    {
                        tradeTick.time = data.time;
                        tradeTick.tickType = TickType.Trade;
                        tradeTick.size = AdjustVolume(symbol, (UInt64)e.Size - lastVolume);

                        //lastVolume = e.size * 100;

                        if (tickListener != null)
                        {
                            tickListener(symbol, tradeTick);
                        }
                    }

                    if (e.Size > 0)
                    {
                        lastVolumes[symbol] = (UInt64)e.Size;
                    }

                    data.tickType = TickType.DailyVolume;

                }
                else
                {
                    //	Unknown tick type
                    return;
                }
                listener = tickListener;
            }

            if (listener != null)
            {
                listener(symbol, data);
            }
        }
예제 #3
0
        public void sizeChangeTick(Object sender, TickSizeEventArgs e)
        {
            Product p = tickerIdsToProduct[e.TickerId];
            p.asOf = DateTime.UtcNow;
            log.Debug("Size change for " + p.symbol + " on " + e.TickType.ToString() + " New size = " + Convert.ToString(e.Size));

            switch (e.TickType)
            {
                case Krs.Ats.IBNet.TickType.BidSize:
                    p.bidQty = e.Size;
                    if (BidQtyUpdate != null)
                        BidQtyUpdate(p);
                    break;
                case Krs.Ats.IBNet.TickType.AskSize:
                    p.askQty = e.Size;
                    if (AskQtyUpdate != null)
                        AskQtyUpdate(p);
                    break;
                case Krs.Ats.IBNet.TickType.LastSize:
                    p.lastQty = e.Size;
                    if (LastQtyUpdate != null)
                        LastQtyUpdate(p);
                    break;
                default:
                    break;
            }
        }
예제 #4
0
        void client_TickSize(object sender, TickSizeEventArgs e)
        {
            //Console.WriteLine("Tick Size: " + e.Size + " Tick Type: " + EnumDescConverter.GetEnumDescription(e.TickType));
            int secondFraction = (int)(DateTime.Now.Ticks % TimeSpan.TicksPerSecond / (TimeSpan.TicksPerSecond / 256));

            lock (capturingWriterLock)
            {
                capturingWriter.Write((byte)secondFraction);
                capturingWriter.Write((byte)e.TickType);
                capturingWriter.Write((byte)e.TickerId);
                capturingWriter.Write((float)e.Size);
            }
            if ((totalCaptureEventsForDisplay & 0x3C) == 0) //only shows the first 4 for every 64
                logger.Trace("{0} : {1} : {2} : {3}", e.TickType, symbols[e.TickerId].Symbol, e.TickerId, e.Size);
            totalCaptureEventsForDisplay++;
        }