Esempio n. 1
0
        private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission)
        {
            ExecutionReport report = new ExecutionReport
            {
                TransactTime     = Clock.Now,
                ClOrdID          = record.Order.ClOrdID,
                OrigClOrdID      = record.Order.ClOrdID,
                OrderID          = record.Order.OrderID,
                Symbol           = record.Order.Symbol,
                SecurityType     = record.Order.SecurityType,
                SecurityExchange = record.Order.SecurityExchange,
                Currency         = record.Order.Currency,
                CommType         = commType,
                Commission       = commission,
                Side             = record.Order.Side,

                OrdType     = record.Order.OrdType,
                TimeInForce = record.Order.TimeInForce,
                OrderQty    = record.Order.OrderQty,
                Price       = record.Order.Price,
                StopPx      = record.Order.StopPx,
                LastPx      = lastPx,
                LastQty     = lastQty
            };

            if (ordStatus == OrdStatus.Replaced)
            {
                report.OrdType     = record.Order.ReplaceOrder.ContainsField(EFIXField.OrdType) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType;
                report.TimeInForce = record.Order.ReplaceOrder.ContainsField(EFIXField.TimeInForce) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce;
                report.OrderQty    = record.Order.ReplaceOrder.ContainsField(EFIXField.OrderQty) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty;
                report.Price       = record.Order.ReplaceOrder.ContainsField(EFIXField.Price) ? record.Order.ReplaceOrder.Price : record.Order.Price;
                report.StopPx      = record.Order.ReplaceOrder.ContainsField(EFIXField.StopPx) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx;
                record.LeavesQty   = ((int)report.OrderQty) - record.CumQty;
            }
            else
            {
                report.OrdType     = record.Order.OrdType;
                report.TimeInForce = record.Order.TimeInForce;
                report.OrderQty    = record.Order.OrderQty;
                report.Price       = record.Order.Price;
                report.StopPx      = record.Order.StopPx;
            }


            if (ordStatus == OrdStatus.Undefined)
            {
                record.AddFill(lastPx, lastQty);
                if (record.LeavesQty > 0)
                {
                    ordStatus = OrdStatus.PartiallyFilled;
                }
                else
                {
                    ordStatus = OrdStatus.Filled;
                }
            }
            report.AvgPx     = record.AvgPx;
            report.CumQty    = record.CumQty;
            report.LeavesQty = record.LeavesQty;
            report.ExecType  = CTPZQProvider.GetExecType(ordStatus);
            report.OrdStatus = ordStatus;
            report.Text      = text;

            EmitExecutionReport(report);
        }
 public void Init(CTPZQProvider provider)
 {
     this.provider = provider;
 }
 public void Init(CTPZQProvider provider)
 {
     this.provider = provider;
 }