コード例 #1
0
        //! [tickprice]
        public virtual void tickPrice(int tickerId, int field, double price, TickAttrib attribs)
        {
            if (field == (int)TickType.BidPrice || field == (int)TickType.AskPrice)
            {
                var symbol   = subscription.GetSymbolNameByRequestId(tickerId);
                var tickType = (TickType)field;

                quotes.AddOrUpdate(symbol, s => new Quote
                {
                    Time   = DateTimeOffset.UtcNow,
                    Symbol = symbol,
                    Ask    = tickType == TickType.AskPrice ? price : 0,
                    Bid    = tickType == TickType.BidPrice ? price : 0
                }, (s, q) => new Quote
                {
                    Time   = DateTimeOffset.UtcNow,
                    Symbol = symbol,
                    Ask    = tickType == TickType.AskPrice ? price : q.Ask,
                    Bid    = tickType == TickType.BidPrice ? price : q.Bid
                });

                if (quotes.TryGetValue(symbol, out Quote quote))
                {
                    if (quote.IsFilled())
                    {
                        queue.AddItem(quote);
                    }
                }
            }
        }
コード例 #2
0
 public virtual void error(Exception e)
 {
     state.AddItem(e.Message);
     logger.LogError("Exception thrown: {0}:{1}", e.GetType().Name, e.Message);
     throw e;
 }