예제 #1
0
        //
        //
        #endregion//Public Methods


        #region Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        //
        // *****************************************************
        // ****            TryLocatePricingLegs             ****
        // *****************************************************
        /// <summary>
        /// The LegID's inside are set to -1 at construction time to denote that we have not
        /// received events yet for those legs.
        /// </summary>
        /// <param name="marketBook">Most recent marketbook.</param>
        /// <returns>true if all legs have been found in mkt book.</returns>
        protected bool TryLocatePricingLegs(Book marketBook)
        {
            int unknownLegs = 0;

            for (int leg = 0; leg < m_Legs.Count; ++leg)                    // This is the old way of doing things,
            {                                                               // where we actually searched for instrtument.
                if (m_Legs[leg].MarketID == -1)
                {
                    unknownLegs += 1;                                       // now, assume we won't find this instrument.
                    foreach (Market mkt in marketBook.Instruments.Values)
                    {
                        if (mkt.Name == m_Legs[leg].InstrumentName && mkt.DeepestLevelKnown > -1)
                        {                                                   // Found the instrument we are looking for.
                            m_Legs[leg].MarketID = mkt.ID;
                            unknownLegs         -= 1;                       // remove from counter since we found the instrument.
                            break;
                        }
                    }
                }
            }
            if (unknownLegs == 0)
            {   // Now that all legs are known, lets perform the first update
                // for the implied market.
                this.ImpliedMarket = ImplMarket.Create(ParentStrategy.Name);
                this.ImpliedMarket.SetMarket(marketBook, m_Legs);
            }
            // Exit
            return(unknownLegs == 0);
        }//end InitalizeLegs()
예제 #2
0
        //
        public static ImplMarket Create(string name)
        {
            ImplMarket instr = new ImplMarket();

            // Name this implied instrument.
            Product        prod           = new Product(string.Empty, name, ProductTypes.Strategy);
            InstrumentName instrumentName = new InstrumentName(prod, name);

            instr.Name = instrumentName;

            //Exit
            return(instr);
        }