コード例 #1
0
 //
 //
 public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
 {
     if (ParentStrategy != null)
     {
         m_QuoteTickSize = ParentStrategy.m_OrderEngine.QuoteTickSize;
     }
 }
コード例 #2
0
 protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
 {
     base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
     m_Hub      = (Hub)myEngineHub;
     this.m_Log = m_Hub.Log;                                              // set up our logging
     this.m_ExecutionContainer = (ExecutionContainer)engineContainer;
 }
コード例 #3
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
 }
コード例 #4
0
        //
        // ****         Setup Initialize()          ****
        //
        /// <summary>
        /// This is called by the local execution hub thread.
        /// </summary>
        /// <param name="hub"></param>
        public void SetupInitialize(IEngineHub hub)
        {
            // Keep pointers to my local hub.
            m_LocalEngineHub     = hub;
            m_LocalEngineHubName = hub.ServiceName;
            Log = ((Hub)m_LocalEngineHub).Log;
            // Initialize all my engines.
            int ptr = 0;

            while (ptr < m_IEngineList.Count)
            {
                if (m_IEngineList[ptr] is Engine)
                {
                    Engine engine = (Engine)m_IEngineList[ptr];
                    engine.SetupInitialize(hub, this, engine.EngineID);
                }
                ptr++;
            }

            m_ConfirmSynthOrderEventArg.Status            = EngineEventArgs.EventStatus.Confirm; // create reusable event arg.
            m_ConfirmSynthOrderEventArg.EngineHubName     = this.RemoteEngineHub.ServiceName;
            m_ConfirmSynthOrderEventArg.EngineContainerID = this.EngineContainerID;
            m_ConfirmSynthOrderEventArg.MsgType           = EngineEventArgs.EventType.SyntheticOrder;
            m_ConfirmSynthOrderEventArg.DataObjectList    = new List <object>();
        }// SetupInitialize()
コード例 #5
0
        //
        //
        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            base.SetupBegin(myEngineHub, engineContainer);
            foreach (IEngine ieng in engineContainer.GetEngines())
            { // Find order Engine
                if (ieng is IOrderEngine)
                {
                    this.m_IOrderEngine = (IOrderEngine)ieng;                                             // find our order engine
                }
            }
            if (m_IOrderEngine is SingleLegExecutor)
            { // if this is a single leg order engine
                m_SingleLegExecutor = (SingleLegExecutor)m_IOrderEngine;
                this.m_Leg          = m_SingleLegExecutor.m_PriceLeg;
                m_MaxPossibleWorkingQuoteQtyPerLot += (int)(Math.Abs(m_Leg.Weight) * 2);            // leg ratios * 2 (each side)
            }
            // If we subscribe to order book creation, we can be sure to get all the info for all fills and submissions
            // this only works if create order books after setup beging.
            m_IOrderEngine.GetExecutionListener().OrderBookCreated += new EventHandler(ExecutionListener_OrderBookCreated);

            if (m_Hub is ExecutionHub)
            {                                                                    // set up ITimer to work
                ((ExecutionHub)m_Hub).SubscribeToTimer((ITimerSubscriber)m_ExecutionContainer.m_ExecutionListener);
                m_ExecutionContainer.m_ExecutionListener.SubscribeToTimer(this); // subscrie to updates
            }
        }
コード例 #6
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()
コード例 #7
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()
コード例 #8
0
        //
        //
        // ******************************************************
        // ****             Setup Initialize()               ****
        // ******************************************************
        /// <summary>
        /// Since we are a specialized gui manager, we override SetupInitialize()
        /// and don't create a default popup gui.
        /// </summary>
        /// <param name="myEngineHub"></param>
        /// <param name="engineContainer"></param>
        /// <param name="engineID"></param>
        /// <param name="isSetupGui"></param>
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool isSetupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, false);// call base class first.

            m_Parent = (Strategy)engineContainer;
            m_ParentEngineContainerID = engineContainer.EngineContainerID;
            Log = m_Parent.StrategyHub.Log;

            // Set the plotting hour offset.
            m_StartTime = m_Parent.StrategyHub.GetLocalTime();
            m_StartHour = m_StartTime.Hour + m_StartTime.Minute / 60.0 + m_StartTime.Second / 3600.0;
            if (m_StartHour >= 16.0)
            {
                m_StartHour -= 24.0;                            // after 4pm, shift to negative numbers (new trading day).
            }
            //
            // Add our custom ZGraphControl template
            //
            UV.Lib.FrontEnds.GuiTemplates.EngineGui engineGui = new Lib.FrontEnds.GuiTemplates.EngineGui();
            engineGui.DisplayName           = "Graph";
            engineGui.EngineID              = this.m_EngineID;
            engineGui.EngineFullName        = this.GetType().FullName;
            engineGui.HeaderControlFullName = typeof(UV.Lib.FrontEnds.Graphs.ZGraphControl).FullName;
            engineGui.ParameterList.AddRange(this.m_PInfo);
            m_EngineGuis.Add(engineGui);
        }//SetupInitialize()
コード例 #9
0
 //
 //
 // ****             Setup Begin()               ****
 //
 public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
 {
     base.SetupBegin(myEngineHub, engineContainer);
     m_Name   = base.EngineName;
     m_Parent = (Strategy)engineContainer;
     this.Log = ((StrategyHub)myEngineHub).Log;
 }//SetupBegin()
コード例 #10
0
ファイル: Strategy.cs プロジェクト: nagyist/mkbiltek.trading
        //
        #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()
コード例 #11
0
ファイル: Strategy.cs プロジェクト: nagyist/mkbiltek.trading
        }//SetupInitialize()

        //
        //
        // ****************************************
        // ****         Setup Begin()          ****
        // ****************************************
        /// <summary>
        /// The setup phase continues.
        /// Here, the Strategy and each of its engines have been created, and labeled.
        ///
        /// Strategy may attempt to find the resources and other dependences it requires to run.
        /// Engine are free to look for each other now.
        /// This method is called after ALL strategies have been created (and their engines), and
        /// after SetupInitialize().  The purpose of this is that
        /// by this time, engine can be assured that there exists a complete list of all
        /// strategies and engines available.  They can find specific engines (of other strategies)
        /// that they need to link to, and make those initial linkages.
        ///
        /// While not ideal, if an engine must add another one during this process it is still
        /// possible however it is much better to add them during SetupInitialize.
        /// TODO:
        ///     1) To prevent multithread problems in future, Strategy must ask for pointer to
        ///         another strategy, and this is monitored by hub, and pricing engines are
        ///         ordered in tiers using this information.
        /// </summary>
        public void SetupBegin(IEngineHub myHub)
        {
            foreach (Engine engine in m_Engines)
            {
                engine.SetupBegin(myHub, this);
            }
            m_IsBeginComplete = true;
        }//end Initialize()
コード例 #12
0
        //
        //
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
            ExecutionContainer execContainer = (ExecutionContainer)engineContainer;

            execContainer.TryAddEngine(m_Hedger);   // add my sub engines to the container.
            execContainer.TryAddEngine(m_HedgeRuleManager);
        }
コード例 #13
0
        }//SetupInitialize()

        //
        //
        // *************************************************
        // ****             SetupBegin()                 ****
        // *************************************************

        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            base.SetupBegin(myEngineHub, engineContainer);


            // ParentStrategy.StrategyHub.SubscribeToTimer(ParentStrategy, this);
            // ParentStrategy.m_OrderEngine.QuoteTickSize = m_QuoteTickSize; // set our quote tick size for proper rounding
        }
コード例 #14
0
ファイル: Engine.cs プロジェクト: nagyist/mkbiltek.trading
        //
        //
        public void BroadcastParameter(IEngineHub hub, IEngineContainer parent, string parameterName)
        {
            int id = GetParameterId(parameterName);

            if (id > -1)
            {
                BroadcastParameter(hub, parent, id);
            }
        }
コード例 #15
0
        protected ConcurrentQueue <EventArgs> m_InQueue = new ConcurrentQueue <EventArgs>(); // threadsafe queue to push events to processed onto.
        #endregion                                                                           //members

        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public ExecutionListener(string name, IEngineHub engineHub)
        {
            m_EngineHub = engineHub;
            if (engineHub is Hub)
            {
                this.Log = ((Hub)engineHub).Log;
            }
            m_Name = name;
        }
コード例 #16
0
 //
 // *****************************************
 // ****     Setup Initialize()          ****
 // *****************************************
 protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
 {
     base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
     //
     // Keep pointers to important objects.
     //
     this.ParentStrategy = (Strategy)engineContainer;
     this.Log            = ((Hub)myEngineHub).Log;                   // Pricing engines tend to log a lot, so keep a pointer.
 }
コード例 #17
0
ファイル: Strategy.cs プロジェクト: nagyist/mkbiltek.trading
        //
        //
        //
        //
        // ****************************************
        // ****     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()
コード例 #18
0
        //
        // *****************************************
        // ****     Setup Initialize()          ****
        // *****************************************
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);

            // Keep pointers to important objects.
            this.ParentStrategy = (Strategy)engineContainer;


            // TODO: Locate the Alarm service.
        }
コード例 #19
0
ファイル: Engine.cs プロジェクト: nagyist/mkbiltek.trading
 //
 //
 // ************************************************
 // ****             SetupInitialize()          ****
 // ************************************************
 /// <summary>
 /// This is called immediately after construction, when we add this engine to its strategy.
 /// During this call the Parameter tables *must* be created, and all *Gui Templates* must be
 /// created.
 /// If an Engine wants to create additional Engines, it should be done here.  Since *after*
 /// this initialize call (that is, during the SetupBegin() call), Engines can assume that all
 /// other Engines have been created and added to the EngineList of the WStrategy.
 /// The short explanation:
 ///     Setup Initialize:   Strategy, StrategyHub and other ApplicationServices exist.
 ///     Setup Begin:        All Engines within my Strategy exist, and were SetupInitialize().
 ///     Setup Complete:     All Engines in all Strategies exist and were SetUpBegin().
 /// Note:
 ///     1)  At this point, the Strategy has been created, but possibly no others.
 ///     2)  The other engines in the Strategy may also not be created at this point.
 ///         * Therefore, Engines should not look for other Strategies of other Engines.
 ///     3)  Subclasses should call this base-class method FIRST (so engineID is set) before other implementations.
 /// </summary>
 public void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID)
 {
     if (engineID >= 0)                                              // If engineID provide is positive, then
     {
         m_EngineID = engineID;                                      // accept ID provided by my parent Strategy. Otherwise leave it alone.
     }
     // This is useful when its assigned at construction time already.
     m_Parent = engineContainer;
     SetupInitialize(myEngineHub, engineContainer, engineID, true);  // default is to creaet the default Gui templates.
 }// SetupInitialize()
コード例 #20
0
        //
        //
        //
        //
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
            // Request historic data for plots.
            DateTime end   = ParentStrategy.StrategyHub.GetLocalTime();
            DateTime start = end.AddHours(-m_NHoursHistoricData);            // TODO: allow this to passed in as istringifiable param?

            base.RequestHistoricData(start, end);
            m_IEngineHub = myEngineHub;
        }
コード例 #21
0
        //
        // *********************************************
        // ****         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()
コード例 #22
0
        //
        //
        #endregion//Public Methods

        #region no Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        #endregion//Private Methods

        #region Event Handlers
        // *****************************************************************
        // ****                     Event Handlers                     ****
        // *****************************************************************
        //
        //
        // *****************************************************************
        // ****           ExecutionListener_Initialized()               ****
        // *****************************************************************
        /// <summary>
        /// Called once dispatcher is attached to thread allowing us to finish our setup.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ExecutionListener_Initialized(object sender, EventArgs eventArgs)
        {
            IEngineHub iEngHub = (IEngineHub)m_Hub;     // cast our generic hub to an Ieng hub

            //foreach (Engine eng in m_ExecutionContainer.EngineList.Values)  // call all engine's begin, now we are on the right thread!
            //    eng.SetupBegin(iEngHub, m_ExecutionContainer);
            //foreach (Engine eng in m_ExecutionContainer.EngineList.Values) // call all engine's complete
            //    eng.SetupComplete();
            this.SetupBegin(iEngHub, m_ExecutionContainer);
            this.SetupComplete();
        }
コード例 #23
0
        //
        //
        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            base.SetupBegin(myEngineHub, engineContainer);

            if (myEngineHub is ExecutionHub)
            { // set up ITimer to work
                ThreadContainer execContainer = (ThreadContainer)engineContainer;
                ((ExecutionHub)myEngineHub).SubscribeToTimer((ITimerSubscriber)execContainer.m_ExecutionListener);
                execContainer.m_ExecutionListener.SubscribeToTimer(this); // subscribe to updates
            }
        }
コード例 #24
0
        //
        // *****************************************
        // ****     Setup Initialize()          ****
        // *****************************************
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, false);
            EngineGui engineGui = base.SetupGuiTemplates();

            if (engineContainer is Strategy)
            {
                ParentStrategy = (Strategy)engineContainer;
                Log            = ParentStrategy.StrategyHub.Log;
            }
            m_Services = AppServices.GetInstance();
        }
コード例 #25
0
        private Dictionary <int, int> m_OppositeOrderIDToIPrice             = new Dictionary <int, int>();            // map order ids to IPrice we want to scratch

        #endregion                                                                                                    // members

        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            this.m_EngineName = string.Format("Scratcher:{0}", m_PriceLeg.InstrumentName);
            if (typeof(UV.Strategies.ExecutionHubs.ExecutionContainers.MultiThreadContainer).IsAssignableFrom(engineContainer.GetType()))
            {                                                          // this is the "first" set up call from the manager container.
                base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
                m_Log = ((ExecutionHubs.ExecutionHub)myEngineHub).Log; // keep pointer to log
            }
            else
            {   // this is the second set up call from the correct container, add correct sub engine mappings
            }
        }
コード例 #26
0
 //
 public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
 {
     base.SetupBegin(myEngineHub, engineContainer);
     foreach (IEngine eng in engineContainer.GetEngines())
     {
         if (eng is IOrderEngine)
         {   // find our orer engine and our execution listner
             m_ExecutionListener = ((IOrderEngine)eng).GetExecutionListener();
             continue;
         }
     }
 }
コード例 #27
0
 //
 public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
 {
     base.SetupBegin(myEngineHub, engineContainer);
     m_Log = ((ExecutionHub)myEngineHub).Log;
     foreach (IEngine iEng in engineContainer.GetEngines())
     {// find our needed engine pointers
         if (iEng is ExecutionEngines.OrderEngines.Spreader)
         {
             m_Quoter = (ExecutionEngines.OrderEngines.Spreader)iEng;
         }
     }
 }
コード例 #28
0
        private OrderEventArgs m_OrderEventArg; // careful, but this is always recycled

        #endregion                              // members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            if (typeof(UV.Strategies.ExecutionHubs.ExecutionContainers.MultiThreadContainer).IsAssignableFrom(engineContainer.GetType()))
            {   // this is the "first" set up call from the manager container.
                base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
                m_Log = ((ExecutionHubs.ExecutionHub)myEngineHub).Log;
            }
            else
            {   // this is the second set up call from the correct container, add correct sub engine mappings
                m_ExecutionContainer = (ThreadContainer)engineContainer;
            }
        }
コード例 #29
0
        }//SetupInitialize()

        //
        //
        //
        //
        // ************************************************
        // ****             SetupBegin()               ****
        // ************************************************
        /// <summary>
        /// </summary>
        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            //
            // Master Remote-Engines must send requests to ExecutionHub now.
            //
            if (m_IsSubEngine == false)
            {
                // Count number of (master) remote engines found in this strategy.
                // Master remote engines are those connected directly to the Strategy,
                // without being held by another engine.
                // Only masters broadcast their xml to the ExecutionHub, and other sub-engine
                // engines are included as subelements of their master's broadcast.
                // (If each remote engine broadcasted separately, the ExecHub would have to know how
                // to put them all back together again... that is, who owned whom.)
                int remoteMasterEngineCount = 0;
                foreach (IEngine iEng in engineContainer.GetEngines())
                {
                    if (iEng is ExecutionController && ((ExecutionController)iEng).m_IsSubEngine == false)
                    {
                        remoteMasterEngineCount++;
                    }
                    //if (iEng is RemoteEngine)           // now count all remote engines
                    //    remoteMasterEngineCount++;
                }

                //
                // Create my engine creation request
                //
                Dictionary <Type, string[]> rules = new Dictionary <Type, string[]>();
                rules.Add(this.GetType(), new string[] { "GetClassName", string.Empty, string.Empty });
                string xmlString = Stringifiable.Stringify(this, rules);

                EngineEventArgs e = new EngineEventArgs();
                e.MsgType           = EngineEventArgs.EventType.NewEngine;
                e.Status            = EngineEventArgs.EventStatus.Request;
                e.EngineID          = m_EngineID;
                e.EngineContainerID = m_EngineContainerId;
                e.DataObjectList    = new List <object>();
                e.DataObjectList.Add(xmlString);                          // 0 - engine specs
                e.DataObjectList.Add(m_LocalEngineHubName);               // 1 - engine hub name
                e.DataObjectList.Add(remoteMasterEngineCount.ToString()); // 2 - number of engines remote hub should expect from this EngineContainer
                // Send request to remote.
                if (m_RemoteEngineHub != null && m_RemoteEngineHub.HubEventEnqueue(e))
                {
                    Log.NewEntry(LogLevel.Minor, "SetupBegin: Remote-{0} sent creation request to remote.", m_RemoteEngineClassName);
                }
                else
                {
                    Log.NewEntry(LogLevel.Minor, "SetupBegin: Remote-{0} failed to send creation request to remote.", m_RemoteEngineClassName);
                }
            } // master remote-engine sends request.
        }     //SetupBegin()
コード例 #30
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, false);
            EngineGui engineGui = base.SetupGuiTemplates();

            engineGui.LowerHudFullName = typeof(OrderEngineHud).FullName;


            // Collect services that I need.
            m_Hub                = (Hub)myEngineHub;
            this.Log             = m_Hub.Log;
            m_ExecutionContainer = (ThreadContainer)engineContainer;
        }// SetupInitialize()