コード例 #1
0
        //
        // *****************************************
        // ****         Setup Begin()           ****
        // *****************************************
        /// <summary>
        /// This is called after all Engines have been created, and added to the master
        /// list inside the Strategy (IEngineContainer).
        /// As a convenience, the PricingEngine class locates useful Engines and keeps
        /// pointers to them.
        /// </summary>
        /// <param name="myEngineHub"></param>
        /// <param name="engineContainer"></param>
        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            base.SetupBegin(myEngineHub, engineContainer);

            // Locate engines we need.
            m_MarketSubscribers = new List <IMarketSubscriber>();
            foreach (IEngine iEngine in engineContainer.GetEngines())
            {
                if (iEngine is ZGraphEngine)
                {
                    m_GraphEngine = (ZGraphEngine)iEngine;                  // PricingEngines also plot a lot.
                }
                else if (iEngine is IMarketSubscriber)
                {
                    m_MarketSubscribers.Add((IMarketSubscriber)iEngine);
                }
            }

            //
            // Subscribe to Pricing instruments.
            //
            List <InstrumentName> instruments = new List <InstrumentName>();

            foreach (PriceLeg leg in m_Legs)                                // Subscribe to each "PricingLeg" object.
            {
                instruments.Add(leg.InstrumentName);
            }
            this.ParentStrategy.StrategyHub.SubscribeToMarketInstruments(instruments, this.ParentStrategy);
        }//SetupBegin()
コード例 #2
0
        //
        //
        // ****         SetupBegin()            ****
        //
        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            base.SetupBegin(myEngineHub, engineContainer);
            m_Parent = (Strategy)engineContainer;
            Log      = ((Hub)myEngineHub).Log;

            // Get Engines of interest.
            int modelCounter = 0;

            foreach (IEngine ieng in m_Parent.GetEngines())
            {
                if (ieng is ZGraphEngine)
                {
                    if (m_GraphEngine == null)
                    {
                        m_GraphEngine = (ZGraphEngine)ieng;                 // take first found graph engine to draw to.
                    }
                }
                else if (ieng is ModelEngine)
                {
                    if (ieng == this)
                    {
                        m_ModelEngineID = modelCounter;
                    }                                                           // store the number of models in front of me (use as my id!)
                    modelCounter++;
                }
            }
        }//SetupBegin()