示例#1
0
 protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
 {
     base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
     m_StrategyHub = (StrategyHub)myEngineHub;
     this.m_Log    = m_StrategyHub.Log;                                           // set up our logging
     this.m_Market = m_StrategyHub.m_Market;                                      // grab the market so we can have some instrument details
 }
示例#2
0
        //
        #endregion//Properties


        #region Public Initialization Methods
        // *****************************************************************
        // ****                 Public Initialization                   ****
        // *****************************************************************
        //
        //
        // ****************************************
        // ****     Setup Initialize()         ****
        // ****************************************
        /// <summary>
        /// The Strategy has been created, and now we add its engines.
        /// When we call Engine.SetupInitialize() the engine can make NO assumptions
        /// about the Strategy, except that it and its StrategyHub exists.
        /// Other Engines may or may not exist.
        /// What is allowed is that Engines can spawn other Engines and add them
        /// to the *end* of the Strategy.m_Engines[] list freely.
        /// </summary>
        public void SetupInitialize(IEngineHub myHub)
        {
            StrategyHub = (StrategyHub)myHub;                           // store ptr to new parent hub.

            // First initialize each of my engines.
            int id = 0;

            while (id < m_Engines.Count)                                // Loop using while so that Engines can ADD new engines to end of list.
            {                                                           // Adding new engines spontaneously is allowed here only.
                Engine engine = m_Engines[id];
                engine.SetupInitialize(StrategyHub, this, id);          // Tell Engine his new Hub, and owner, and his new id#.

                // Keep track of important engine ptrs we need.
                if (engine is Engines.PricingEngine)                    // using simple "if"s allows one engine to play multiple roles.
                {
                    m_PricingEngine = (Engines.PricingEngine)engine;
                }
                if (engine is IOrderEngine)
                {
                    m_OrderEngine = (IOrderEngine)engine;
                }
                if (engine is ZGraphEngine)
                {
                    m_GraphEngine = (ZGraphEngine)engine;
                }

                id++;
            } //next engine id
            m_IsInitializeComplete = true;                               // after this point if engines are added, they have to manually Initialize
        }     //SetupInitialize()
示例#3
0
        //
        //
        //
        //
        // ****************************************
        // ****     Setup Initialize()         ****
        // ****************************************
        /// <summary>
        /// The Strategy has been created, and now we add its engines.
        /// When we call Engine.SetupInitialize() the engine can make NO assumptions
        /// about the Strategy, except that it and its StrategyHub exists.
        /// Other Engines may or may not exist.
        /// What is allowed is that Engines can spawn other Engines and add them
        /// to the *end* of the Strategy.m_Engines[] list freely.
        /// </summary>
        public void SetupInitialize(IEngineHub myHub)
        {
            StrategyHub = (StrategyHub)myHub;                           // store ptr to new parent hub.

            // First initialize each of my engines.
            int id = 0;

            while (id < m_Engines.Count)                                // Loop using while so that Engines can ADD new engines to end of list.
            {                                                           // Adding new engines spontaneously is allowed here only.
                Engine engine = m_Engines[id];
                engine.SetupInitialize(StrategyHub, this, id);          // Tell Engine his new Hub, and owner, and his new id#.

                // Keep track of important engine ptrs we need.
                if (engine is PricingEngine)                            // using simple "if"s allows one engine to play multiple roles.
                {
                    PricingEngines.Add((PricingEngine)engine);          //m_PricingEngine = (StrategyEngines.PricingEngine)engine;
                }
                if (engine is TradeEngine)
                {
                    m_OrderEngine = (TradeEngine)engine;
                }
                if (engine is ZGraphEngine)
                {
                    m_GraphEngine = (ZGraphEngine)engine;
                }
                if (engine is FauxQuote)
                {
                    m_QuoteEngine = (FauxQuote)engine;
                }
                id++;
            }//next engine id

            // Create missing basic engines
            if (m_OrderEngine == null)
            {
                m_OrderEngine = new TradeEngine();
                TryAddEngine(m_OrderEngine, myHub);
                m_OrderEngine.SetupInitialize(StrategyHub, this, -1);// Tell Engine his new Hub, and owner, and his new id# (which is already set in TryAddEngine()).
            }
            if (m_GraphEngine == null)
            {
                m_GraphEngine = new ZGraphEngine();
                TryAddEngine(m_GraphEngine, myHub);
                m_GraphEngine.SetupInitialize(StrategyHub, this, -1);
            }
            if (m_QuoteEngine == null)
            {
                QuoteEngine quoteEngine = new QuoteEngine();
                m_QuoteEngine = quoteEngine;
                TryAddEngine(quoteEngine, myHub);
                quoteEngine.SetupInitialize(StrategyHub, this, -1);
            }

            // Exit
            m_IsInitializeComplete = true;                               // Must be last line in this method.
        }//SetupInitialize()
        //
        // *********************************************
        // ****         SetUp Initialize()          ****
        // *********************************************
        /// <summary>
        /// </summary>
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            // Save information about local strategy hub.
            m_EngineContainerId = engineContainer.EngineContainerID;
            if (myEngineHub is IService)
            {
                m_LocalEngineHubName = ((IService)myEngineHub).ServiceName;
            }
            StrategyHub strategyHub = ((StrategyHub)myEngineHub);

            this.Log         = strategyHub.Log;
            m_LocalEngineHub = myEngineHub;

            // Locate our target remote hub/service.
            IEngineHub   remoteEngineHub = null;
            EventHandler del             = new EventHandler(ProcessRemoteEngineEvents);

            if (strategyHub.SubscribeToRemoteEngineHub("ExecutionHub", m_EngineContainerId, m_EngineID, del, out remoteEngineHub))
            {
                m_RemoteEngineHub = remoteEngineHub;
            }
            else
            {
                throw new Exception("Failed to locate remote hub.");
            }


            // Create the parameter table.
            Type remoteEngineType;

            if (Stringifiable.TryGetType(m_RemoteEngineClassName, out remoteEngineType))
            {
                this.m_PInfo = CreateParameterInfo(myEngineHub, engineContainer.EngineContainerID, this.EngineID, remoteEngineType);
            }

            //
            // Add sub-engines to the parent Strategy
            //
            //  They will be automatically initialized outside in StrategyHub loop
            //  that called us, since we will add new engine to the end of the list we are looping thru now.
            List <IStringifiable> subElements = m_Node.GetElements();

            if (subElements != null)
            {
                foreach (IStringifiable iObject in subElements)
                {                                       // Engines that are beneath non-engines will not be found here.
                    if (iObject is ExecutionController) // This remote engine will not need to broad its existance,
                    {
                        ExecutionController subEngine = (ExecutionController)iObject;
                        subEngine.m_IsSubEngine = true;                     // since it will be included in another engine (this one).
                        ((Strategy)engineContainer).TryAddEngine(subEngine, myEngineHub);
                    }
                }
            }
        }//SetupInitialize()
示例#5
0
        //
        //
        // *****************************************************
        // ****             SetupInitialize()               ****
        // *****************************************************
        protected override void SetupInitialize(IEngineHub engineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            base.SetupInitialize(engineHub, engineContainer, engineID, false);  //suppress gui creation.
            //EngineGui engineGui = base.SetupGuiTemplates();
            //engineGui.HeaderControlFullName = string.Empty;                     // suppress popup gui.
            //engineGui.LowerHudFullName = typeof(Huds.TradeEngineHud).FullName;

            m_StrategyHub = (StrategyHub)engineHub;
            m_Strategy    = (Strategy)engineContainer;

            // Get my associated execution hub.
            IService iservice;

            if (AppServices.GetInstance().TryGetService(this.m_ExecutionHubName, out iservice) && iservice is IEngineHub)
            {
                m_ExecutionHub = (IEngineHub)iservice;
            }
        }// SetupInitialize()
示例#6
0
        //
        // *************************************************************
        // ****                 Setup Initialize()                  ****
        // *************************************************************
        /// <summary>
        /// Since I depend critically on an OrderBookHub, I will look for them now.
        /// </summary>
        /// <param name="myEngineHub"></param>
        /// <param name="engineContainer"></param>
        /// <param name="engineID"></param>
        /// <param name="setupGui"></param>
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);

            // Collect services that I need.
            m_StrategyHub = (StrategyHub)myEngineHub;
            this.Log      = m_StrategyHub.Log;
            m_Strategy    = (Strategy)engineContainer;

            // Locate an order hub.
            List <IService> services = AppServices.GetInstance().GetServices(typeof(OrderBookHub));

            if (services.Count < 1)
            {
                m_StrategyHub.Log.NewEntry(LogLevel.Warning, "OrderEngine: {0} failed to located OrderHub.", m_Strategy.Name);
            }
            else
            {
                m_OrderHub = (OrderBookHub)services[0];
            }
        }// SetupInitialize()
示例#7
0
        //
        //
        /// <summary>
        /// This should be overridden if the user does NOT want the default Gui Template.
        ///     1.) SetupGui = false will skip construction of the basic Engine Gui Template.
        /// </summary>
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            // Save information about local hub.
            m_EngineContainerId = engineContainer.EngineContainerID;
            if (myEngineHub is IService)
            {
                m_LocalEngineHubName = ((IService)myEngineHub).ServiceName;
            }
            m_LocalHub = (Hub)myEngineHub;

            // Locate our target remote hub/service.
            StrategyHub strategyHub = ((StrategyHub)myEngineHub);
            Hub         remoteHub   = null;

            if (strategyHub.SubscribeToRemoteEngineHub("ExecutionHub", engineContainer, out remoteHub))
            {
                m_RemoteEngineHub = remoteHub;
            }
            else
            {
                throw new Exception("Failed to locate remote hub.");
            }


            // Create the parameter table.
            Type remoteEngineType;

            if (Stringifiable.TryGetType(m_EngineClass, out remoteEngineType))
            {
                this.m_PInfo = CreateParameterInfo(myEngineHub, engineContainer.EngineContainerID, this.EngineID, remoteEngineType);
            }

            /*
             * // Create the gui specs.
             * if (setupGui)
             * {
             *  EngineGui engineGui = new EngineGui();
             *  engineGui.EngineID = this.EngineID;
             *  engineGui.DisplayName = this.EngineName;
             *  engineGui.EngineFullName = this.m_EngineClass;
             *  engineGui.ParameterList.AddRange(this.m_PInfo);
             *  m_EngineGuis.Add(engineGui);
             * }
             */
            //
            // Add sub-engines to the parent Strategy
            //
            //  They will be automatically initialized outside in StrategyHub loop
            //  that called us, since we will add new engine to the end of the list we are looping thru now.
            List <IStringifiable> subElements = m_Node.GetElements();

            if (subElements != null)
            {
                foreach (IStringifiable iObject in subElements)
                {                                // Engines that are beneath non-engines will not be found here.
                    if (iObject is RemoteEngine) // This remote engine will not need to broad its existance,
                    {
                        RemoteEngine subEngine = (RemoteEngine)iObject;
                        subEngine.m_IsSubEngine = true;                     // since it will be included in another engine (this one).
                        ((Strategy)engineContainer).TryAddEngine(subEngine, myEngineHub);
                    }
                }
            }
        }//SetupInitialize()