// ***************************************************************** // **** Event Handlers **** // ***************************************************************** // // // *********************************************************** // **** Filled() **** // *********************************************************** // public void Filled(UV.Lib.Fills.FillEventArgs fillEventArgs) { UVFill fill = fillEventArgs.Fill; if (UpdateAndCheckTotalFillCounts(fill) | PnLCheck()) { // Take the fill and update our counts and PnL, checking both. FlagRiskEvents(); } }
// ***************************************************************** // **** Event Handlers **** // ***************************************************************** // // // *********************************************************** // **** OrderBook_OrderFilled() **** // *********************************************************** // public virtual void OrderBook_OrderFilled(object sender, EventArgs eventArgs) { FillEventArgs fillEventArgs = (FillEventArgs)eventArgs; UVFill fill = fillEventArgs.Fill; if (UpdateAndCheckTotalFillCounts(fill) | PnLCheck()) { // Take the fill and update our counts and PnL, checking both. FlagRiskEvents(); } }
//************************************************************** // **** UpdateAndCheckTotalFillCounts() **** //************************************************************** /// <summary> /// Aggregate total number of fills across entire strategy and check /// to make sure we are under the number of allowed fills. If we are over return true. /// </summary> /// <param name="fill"></param> /// <returns>true if over max allowed fills</returns> protected bool UpdateAndCheckTotalFillCounts(UVFill fill) { if (fill == null) { return(false); } int fillQty = Math.Abs(fill.Qty); // sum total fill count m_TotalFillQty += fillQty; // check to see if we have tripped our risk trigger if (m_TotalFillQty > m_MaxFillQty) { m_Log.NewEntry(LogLevel.Error, "Max Fills Has Been Exceeded: FillQty = {0} MaxFillQty = {1}", m_TotalFillQty, m_MaxFillQty); return(true); } else { return(false); } }