コード例 #1
0
        //
        //
        //
        //***********************************************************
        // ****                    PnLCheck()                    ****
        //***********************************************************
        //
        //
        /// <summary>
        /// Aggregate total PnL across all legs of the strategy, and ensure we aren't below
        /// our allowed loss
        /// </summary>
        /// <returns>true if we are below our maximum allowed loss</returns>
        protected virtual bool PnLCheck()
        {
            if (!m_SingleLegExecutor.m_IsLegSetUpComplete)
            {
                return(false);
            }

            m_PnL = 0; // reset PnL to 0
            double midPrice = (m_ExecutionContainer.m_Markets[m_SingleLegExecutor.m_InstrumentDetails.InstrumentName].Price[UV.Lib.Utilities.QTMath.BidSide][0] +
                               m_ExecutionContainer.m_Markets[m_SingleLegExecutor.m_InstrumentDetails.InstrumentName].Price[UV.Lib.Utilities.QTMath.AskSide][0]) / 2;

            m_PnL = m_IOrderEngine.GetFillBook().m_RealizedGain + m_IOrderEngine.GetFillBook().UnrealizedDollarGains(midPrice);
            if (m_PnL < m_MaxLossPnL)
            {
                m_Log.NewEntry(LogLevel.Error, "Max Loss PnL Has Been Exceeded: Current PnL = {0} MaxLossPnL = {1}", m_PnL, m_MaxLossPnL);
                return(true);
            }
            else
            {
                return(false);
            }
        }