Esempio n. 1
0
 /// <summary>
 /// Add/replace a publisher to the manager
 /// </summary>
 /// <param name="myPub"></param>
 public void Add(KaiTrade.Interfaces.Publisher myPub)
 {
     if(m_PublisherMap.ContainsKey(myPub.TopicID()))
     {
         m_PublisherMap[myPub.TopicID()] = myPub;
     }
     else
     {
         m_PublisherMap.Add(myPub.TopicID(), myPub);
     }
 }
Esempio n. 2
0
        public void doSubscribeMD(KaiTrade.Interfaces.Publisher myPub, int depthLevels, string requestID)
        {
            try
            {

                // Subscribe to the market data from TWS

                // get the product
                KaiTrade.Interfaces.TradableProduct product = m_Facade.Factory.GetProductManager().GetProductMnemonic(myPub.TopicID());

                // IB's newest API uses its IContract
                // Note the PXPublisher must have a valid product
                if (product == null)
                {
                    throw new Exception("The PXPublisher does not have a product");
                }
                // register the pub against the IB ReqID - updates pass that back

                m_IBReqIDProductMap.Add(++m_NextID, product);

                TWSLib.IContract myContract = getIBContract(product);

                myContract.multiplier = "0";
               // m_Host.TWS.reqMktDataEx(m_NextID, myContract, m_QuoteFields, 0);

                if (depthLevels > 0)
                {
                    m_Host.TWS.reqMktDepthEx(m_NextID, myContract, depthLevels);
                    m_Host.TWS.reqMktDataEx(m_NextID, myContract, m_QuoteFields, 0);
                }
                else
                {
                    m_Host.TWS.reqMktDataEx(m_NextID, myContract, m_QuoteFields, 0);
                }

            }
            catch (Exception myE)
            {
                _log.Error("doSubscribeMD", myE);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Override the base driver's un register publisher method
        /// </summary>
        /// <param name="myPublisher"></param>
        protected override void DoUnRegister(KaiTrade.Interfaces.IPublisher myPublisher)
        {
            try
            {
                if (_publisherRegister.ContainsKey(myPublisher.TopicID()))
                {
                    _publisherRegister.Remove(myPublisher.TopicID());
                }

                //UnSubscribeMD(myPublisher);
            }
            catch (Exception myE)
            {
                log.Error("Driver.UnRegister:publisher", myE);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// remove a publisher
 /// </summary>
 /// <param name="myPub"></param>
 public void Remove(KaiTrade.Interfaces.Publisher myPub)
 {
     m_PublisherMap.Remove(myPub.TopicID());
 }
Esempio n. 5
0
        protected override void UnSubscribeMD(KaiTrade.Interfaces.IPublisher pub)
        {
            try
            {
                // check if the subject is already registered and add or update
                // the map of subjects we are keeping - this can be used to
                // resubscribe

                string myKey = pub.TopicID();

                // Try and get the product def fromn the interest list
                //if (m_ProductDefs.ContainsKey(myKey))
                //{
                //   KaiTrade.Interfaces.IProduct myDef = m_ProductDefs[myKey] as KaiTrade.Interfaces.IProduct;
                //   unSubscribeProduct(myDef);
                //}
            }
            catch (Exception myE)
            {
                log.Error("UnSubscribeMD", myE);
            }
        }