Пример #1
0
        protected override void DoStop()
        {
            try
            {
                m_Host.TWS.disconnect();
                this.unWireIBEvents();

                m_Host.Close();
                m_Host = null;

                // Report that we are open - this will show in the Driver view
                // in the dashboard
                this.setStatus(KaiTrade.Interfaces.Status.closed);

            }
            catch (Exception myE)
            {
                _log.Error("doStop", myE);
            }
        }
Пример #2
0
        public KTAIB()
        {
            // initialize member data
            m_Name = "KTA IB TWS  Driver";
            m_ID = "KTIBTWS";
            m_Tag = "";

            _log.Info(m_Name + " Created");
            m_ContractDetailsRequest = new List<KaiTrade.Interfaces.TradableProduct>();
            //m_ClOrdIDCntxMap = new Dictionary<string, OrderContext>();
            //m_IBOrderCntxMap = new Dictionary<int, OrderContext>();
            m_IBReqIDProductMap = new Dictionary<int, KaiTrade.Interfaces.TradableProduct>();
            m_IBReqIDTSSet = new Dictionary<int, KaiTrade.Interfaces.ITSSet>();

            m_QuoteFields = "100,101,104,106,165,221,225,236";
            // create show the IB TWS host form
            m_Host = new Host();
            m_Host.Show();
            m_Host.Adapter = this;
            //m_Host.TWS.c
            // hook up IB events with our handlers
            this.wireIBEvents();

            // use thread to call start/ retry
            UseWatchDogStart = true;
        }
Пример #3
0
        protected override void DoStart(string myPath)
        {
            lock (m_DoStartToken)
            {
                try
                {

                    _log.Info("KT IB(TWS) Driver Started");

                    // are we already open?
                    if ((Status == KaiTrade.Interfaces.Status.open) || (Status == KaiTrade.Interfaces.Status.opening))
                    {
                        _log.Info("KT IB(TWS) Already Open");
                        return;
                    }

                    m_ContractDetailsRequest = new List<KaiTrade.Interfaces.TradableProduct>();

                    this.setStatus(KaiTrade.Interfaces.Status.opening);

                    // try load our config file
                    processConfigFile(m_ConfigPath + "KTAIBConfig.xml");

                    // default to local machine unless they specify elsewise
                    if (!m_Config.IPEndpoint.IsValidServer)
                    {
                        m_Config.IPEndpoint.Server = System.Environment.MachineName;
                        m_Config.IPEndpoint.Server = "";
                    }
                    if (m_Host == null)
                    {
                        m_Host = new Host();
                        m_Host.Show();
                        m_Host.Adapter = this;
                    }
                    m_Host.TWSConnect(m_Config.IPEndpoint.Server, (int)m_Config.IPEndpoint.Port, m_Config.ClientID);

                    if (base.m_State.IsValidHideDriverUI)
                    {
                        if (base.m_State.HideDriverUI)
                        {
                            m_Host.Hide();
                        }
                    }
                    // connect to IB TWS - you need to enable this on the TWS workstation
                    //m_Host.TWS.connect(m_Config.IPEndpoint.Server, (int)m_Config.IPEndpoint.Port, m_Config.ClientID);

                    // if the server responds to this we consider ourselves open
                    //m_Host.TWS.reqCurrentTime();

                    // Report that we are open - this will show in the Driver view
                    // in the dashboard
                    //this.setStatus(KaiTrade.Interfaces.Status.open);
                }
                catch (Exception myE)
                {
                    _log.Error("doStart", myE);
                }
            }
        }