Beispiel #1
0
        internal void EmitExecutionReport(ExecutionReport report)
        {
            if ((report.OrdStatus == OrdStatus.New || report.OrdStatus == OrdStatus.PendingNew) && report.ContainsField(37))
            {
                this.OrderID = report.OrderID;
            }
            if (report.Text == "")
            {
                report.Text = this.Text;
            }
            this.CumQty    = report.CumQty;
            this.LeavesQty = report.LeavesQty;
            this.AvgPx     = report.AvgPx;
            this.OrdStatus = report.OrdStatus;
            if (report.ExecType == ExecType.PartialFill || report.ExecType == ExecType.Fill || report.ExecType == ExecType.Trade)
            {
                this.LastPx  = report.LastPx;
                this.LastQty = report.LastQty;
                if (report.ContainsField(13))
                {
                    double num1 = 0.0;
//         switch (report.CommType)
//          {
//            case CommType.PerShare:
//              num1 = report.Commission * report.LastQty;
//              break;
//            case CommType.Percent:
//              num1 = report.Commission * (report.LastPx * report.LastQty);
//              break;
//            case CommType.Absolute:
//              num1 = report.Commission;
//              break;
//          }
                    SingleOrder singleOrder = this;
                    double      num2        = singleOrder.Commission + num1;
                    singleOrder.Commission = num2;
                }
            }
            this.reports.Add(report);
            if (this.ExecutionReport != null)
            {
                this.ExecutionReport((object)this, new ExecutionReportEventArgs(report));
            }
        }
Beispiel #2
0
        private static void OnExecutionReport(object sender, ExecutionReportEventArgs e)
        {
            ExecutionReport executionReport = e.ExecutionReport;
            SingleOrder     order;

            if (executionReport.ExecType == ExecType.PendingCancel || executionReport.ExecType == ExecType.Cancelled || (executionReport.ExecType == ExecType.PendingReplace || executionReport.ExecType == ExecType.Replace))
            {
                order = OrderManager.orders.All[executionReport.OrigClOrdID] as SingleOrder;
                if (executionReport.ExecType == ExecType.Replace)
                {
                    OrderManager.orders.Remove(order);
                    order.ClOrdID  = executionReport.ClOrdID;
                    order.OrdType  = executionReport.OrdType;
                    order.OrderQty = executionReport.OrderQty;
                    if (executionReport.ContainsField(44))
                    {
                        order.Price = executionReport.Price;
                    }
                    if (executionReport.ContainsField(99))
                    {
                        order.StopPx = executionReport.StopPx;
                    }
                    if (executionReport.ContainsField(10701))
                    {
                        order.TrailingAmt = executionReport.TrailingAmt;
                    }
                    if (executionReport.ContainsField(59))
                    {
                        order.TimeInForce = executionReport.TimeInForce;
                    }
                    if (executionReport.ContainsField(126))
                    {
                        order.ExpireTime = executionReport.ExpireTime;
                    }
                    OrderManager.orders.Add(order);
                }
            }
            else
            {
                order = OrderManager.orders.All[executionReport.ClOrdID] as SingleOrder;
            }
            if (order == null)
            {
                throw new ApplicationException(executionReport.ExecType + executionReport.ClOrdID + executionReport.OrigClOrdID);
            }
            else
            {
                if (order.Provider == null)
                {
                    throw new ApplicationException("provider is null");
                }
                OrdStatus ordStatus = order.OrdStatus;
                order.EmitExecutionReport(executionReport);
                if (order.Persistent)
                {
                    OrderManager.server.AddReport(order, executionReport);
                }
                if (OrderManager.ExecutionReport != null)
                {
                    OrderManager.ExecutionReport(sender, new ExecutionReportEventArgs((NewOrderSingle)order, executionReport));
                }
                if (ordStatus != order.OrdStatus)
                {
                    OrderManager.orders.Update(order);
                    order.EmitStatusChanged();
                    OrderManager.EmitOrderStatusChanged(order);
                }
                if (OrderManager.EnablePartialTransactions && (executionReport.ExecType == ExecType.Fill || executionReport.ExecType == ExecType.PartialFill || executionReport.ExecType == ExecType.Trade))
                {
                    OrderManager.nf3XP7Xf3(order, executionReport.TransactTime, executionReport.LastPx, executionReport.LastQty);
                }
                // ISSUE: reference to a compiler-generated method
                if (ordStatus != order.OrdStatus && order.IsDone)
                {
                    if (!OrderManager.EnablePartialTransactions)
                    {
                        OrderManager.nf3XP7Xf3(order, executionReport.TransactTime, executionReport.AvgPx, executionReport.CumQty);
                    }
                    OrderManager.YUArMfFNj(order);
                }
                if (!(order.OCAGroup != "") || order.Provider.Id == 4 || order.OrdStatus != OrdStatus.Filled && order.OrdStatus != OrdStatus.Cancelled || OrderManager.oca.Contains((object)order.OCAGroup))
                {
                    return;
                }
                OrderManager.oca.Add(order.OCAGroup, order.OCAGroup);
                foreach (SingleOrder singleOrder in OrderManager.GetOCAGroup(order.OCAGroup))
                {
                    if (singleOrder != order)
                    {
                        singleOrder.Cancel();
                    }
                }
            }
        }