Пример #1
0
 void execution_CompleteFill(EZFill fill)
 {
     if (Metrics != null)
     {
         ExecutionStatus status = execution.GetExecutionStatus(this.Name);
         Spy.Print("METRICS (complete fill): {0} {1}", status.AverageBuyPrice, status.AverageSellPrice);
         // If the Fill side matches the Trade side then it is an ENTRY (otherwise it is an EXIT).
         if (fill.BuySell == this.BuySell)
         {
             tradeCycle.SetEntryPriceAverage(status.AverageBuyPrice);
             if (currentTradeState == TradeState.ENTERING)
             {
                 ChangeState(TradeState.ENTERED);
             }
         }
         else
         {
             tradeCycle.SetExitPriceAverage(status.AverageSellPrice);
             if (currentTradeState == TradeState.EXITING)
             {
                 ChangeState(TradeState.EXITED);
             }
             else if (currentTradeState == TradeState.STOPPING)
             {
                 ChangeState(TradeState.STOPPED);
             }
         }
     }
 }