コード例 #1
0
 //
 // *************************************************************
 // ****                      AddBook()                      ****
 // *************************************************************
 //
 /// <summary>
 /// Strategy wants to get a book for a single instrument.  This method is usually called by the Strategy
 /// or pricing model during SetupComplete().
 /// </summary>
 /// <param name="instrumentName"></param>
 public void AddBook(InstrumentName instrumentName)
 {
     if (m_Instrument != null)
     {   // a new instrument we should get a book for.
         m_Instrument = instrumentName;
         m_OrderBook  = m_OrderHub.CreateOrderBook(instrumentName);
         m_StrategyHub.SubscribeToFills(m_Strategy, m_OrderBook);                                  // tell StrategyHub what events i want, and who they belong to.
         m_StrategyHub.SubscribeToMajorOrderStatusEvents(m_Strategy, m_OrderBook);
         m_StrategyHub.SubscribeToOrderSubmitted(m_Strategy, m_OrderBook);
         if (m_IsMarketReady && m_StrategyHub.m_Market.TryGetInstrumentDetails(instrumentName, out m_InstrumentDetails))
         {
             m_FillBook = new FillBook(instrumentName.ToString(), m_InstrumentDetails.Multiplier);
         }
     }
 }// AddBook()
コード例 #2
0
        //
        //
        // *****************************************************************
        // ****         ExecutionListener_InstrumentsFound()            ****
        // *****************************************************************
        /// <summary>
        /// Called when our execution listener has found a new instrument.  This means that it has also created
        /// a market for this instrument which we can now have a pointer to in the quoter leg, as well as subscribe
        /// to the MarketChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ExecutionListener_InstrumentsFound(object sender, EventArgs eventArgs)
        {
            //
            // Gather and save pertinent information about the Instrument found.
            //
            InstrumentsFoundEventArgs instrEventArgs = (InstrumentsFoundEventArgs)eventArgs;

            m_InstrumentDetails = instrEventArgs.InstrumentDetails;
            m_FillBook          = new FillBook(m_PriceLeg.InstrumentName.ToString(), m_InstrumentDetails.Multiplier);
            if (double.IsNaN(m_QuoteTickSize))                          // if our user hasn't defined this yet
            {
                m_QuoteTickSize = m_InstrumentDetails.TickSize;         // set it to the default tick size here
            }
            m_IsLegSetUpComplete = true;
            m_RiskManager.Start();
            m_ExecutionContainer.ConfirmStrategyLaunched();             // confirm we are "launched"
        }
コード例 #3
0
        //
        #endregion//Properties

        #region Public Methods
        // *****************************************************************
        // ****                 Public Methods                         ****
        // *****************************************************************
        //
        //
        // *************************************************************
        // ****             MarketInstrumentInitialized()           ****
        // *************************************************************
        //
        /// <summary>
        /// called once the market for all instruments is subscribed to and we have instrument
        /// details
        /// </summary>
        public override void MarketInstrumentInitialized(Lib.BookHubs.Book marketBook)
        {
            if (m_IsMarketReady)
            {
                return;
            }
            m_IsMarketReady = true;
            if (m_StrategyHub.m_Market.TryGetInstrumentDetails(m_Instrument, out m_InstrumentDetails))
            {
                if (m_FillBook == null)
                {
                    m_FillBook = new FillBook(m_Instrument.ToString(), m_InstrumentDetails.Multiplier);
                }
                if (double.IsNaN(m_QuoteTickSize))                      // if our user hasn't defined this yet
                {
                    m_QuoteTickSize = m_InstrumentDetails.TickSize;     // set it to the default tick size here
                }
            }
            else
            {
                Log.NewEntry(LogLevel.Error,
                             "OrderEngine:MarketInstrumentInitialized failed to get instrument details and create order book for {0}", m_Instrument);
            }
        }