예제 #1
0
 private void EmitExecutionReport(SmartQuant.FIX.ExecutionReport report)
 {
     if (this.ExecutionReport != null)
     {
         this.ExecutionReport(this, new ExecutionReportEventArgs(report));
     }
 }
예제 #2
0
 private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission)
 {
     SmartQuant.FIX.ExecutionReport executionReport = new SmartQuant.FIX.ExecutionReport();
     executionReport.TransactTime     = Clock.Now;
     executionReport.ClOrdID          = record.Order.ClOrdID;
     executionReport.OrigClOrdID      = record.Order.ClOrdID;
     executionReport.OrderID          = record.Order.OrderID;
     executionReport.Symbol           = record.Order.Symbol;
     executionReport.SecurityType     = record.Order.SecurityType;
     executionReport.SecurityExchange = record.Order.SecurityExchange;
     executionReport.Currency         = record.Order.Currency;
     executionReport.CommType         = commType;
     executionReport.Commission       = commission;
     executionReport.Side             = record.Order.Side;
     if (ordStatus == OrdStatus.Replaced)
     {
         executionReport.OrdType     = (record.Order.ReplaceOrder.ContainsField(40) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType);
         executionReport.TimeInForce = (record.Order.ReplaceOrder.ContainsField(59) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce);
         executionReport.OrderQty    = (record.Order.ReplaceOrder.ContainsField(38) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty);
         executionReport.Price       = (record.Order.ReplaceOrder.ContainsField(44) ? record.Order.ReplaceOrder.Price : record.Order.Price);
         executionReport.StopPx      = (record.Order.ReplaceOrder.ContainsField(99) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx);
         record.LeavesQty            = (int)executionReport.OrderQty - record.CumQty;
     }
     else
     {
         executionReport.OrdType     = record.Order.OrdType;
         executionReport.TimeInForce = record.Order.TimeInForce;
         executionReport.OrderQty    = record.Order.OrderQty;
         executionReport.Price       = record.Order.Price;
         executionReport.StopPx      = record.Order.StopPx;
     }
     executionReport.LastPx  = lastPx;
     executionReport.LastQty = (double)lastQty;
     if (ordStatus == OrdStatus.Undefined)
     {
         record.AddFill(lastPx, lastQty);
         if (record.LeavesQty > 0)
         {
             ordStatus = OrdStatus.PartiallyFilled;
         }
         else
         {
             ordStatus = OrdStatus.Filled;
         }
     }
     executionReport.AvgPx     = record.AvgPx;
     executionReport.CumQty    = (double)record.CumQty;
     executionReport.LeavesQty = (double)record.LeavesQty;
     executionReport.ExecType  = this.GetExecType(ordStatus);
     executionReport.OrdStatus = ordStatus;
     executionReport.Text      = text;
     this.EmitExecutionReport(executionReport);
 }
예제 #3
0
        public void OnExecutionReport(object sender, ExecutionReportEventArgs e)
        {
            if (ExecutionReport != null)
            {
                QuickFix42.ExecutionReport sourceReport = e.ExecutionReport;
                try
                {
                    SmartQuant.FIX.ExecutionReport report = new SmartQuant.FIX.ExecutionReport();
                    if (sourceReport.isSetField(41))//如果已有原始编号OrigClOrdID
                    {
                        report.OrigClOrdID = sourceReport.getOrigClOrdID().getValue();
                    }
                    else if (sourceReport.isSetField(11))//如果有标识委托所对应的ClOrdID
                    {
                        report.ClOrdID = sourceReport.getClOrdID().getValue();
                    }

                    report.ExecID = sourceReport.getExecID().getValue();
                    char execType = sourceReport.getExecType().getValue();
                    //Console.WriteLine(execType);
                    switch (execType)//订单执行结果
                    {
                    case '0':
                        report.ExecType = ExecType.New;
                        break;

                    case '1':
                        report.ExecType = ExecType.PartialFill;
                        break;

                    case '2':
                        report.ExecType = ExecType.Fill;
                        break;

                    case '4':
                        report.ExecType = ExecType.Cancelled;
                        break;

                    case '6':
                        report.ExecType = ExecType.PendingCancel;
                        break;

                    case '8':
                        report.ExecType = ExecType.Rejected;
                        break;

                    default:
                        report.ExecType = ExecType.Undefined;
                        break;
                    }
                    if ((execType == '1') || (execType == '2'))                   //执行结果是部分成交或是全部成交
                    {
                        report.LastPx  = sourceReport.getLastPx().getValue();     //本次成交均价
                        report.LastQty = sourceReport.getLastShares().getValue(); //本次成交数量
                    }
                    report.OrderQty = sourceReport.getOrderQty().getValue();      //订单委托量

                    char orderStatus = sourceReport.getOrdStatus().getValue();
                    if (orderStatus == '1' || orderStatus == '2')               //订单状态是部分成交或是全部成交
                    {
                        report.AvgPx     = sourceReport.getAvgPx().getValue();  //平均成交价
                        report.CumQty    = sourceReport.getCumQty().getValue(); //累计成交量
                        report.LeavesQty = report.OrderQty - report.CumQty;     //未成交量
                    }

                    switch (orderStatus)
                    {
                    case '0':
                        report.OrdStatus = OrdStatus.New;
                        break;

                    case '1':
                        report.OrdStatus = OrdStatus.PartiallyFilled;
                        break;

                    case '2':
                        report.OrdStatus = OrdStatus.Filled;
                        break;

                    case '4':
                        report.OrdStatus = OrdStatus.Cancelled;
                        break;

                    case '6':
                        report.OrdStatus = OrdStatus.PendingCancel;
                        break;

                    case '8':
                        report.OrdStatus = OrdStatus.Rejected;
                        break;

                    default:
                        report.OrdStatus = OrdStatus.Undefined;
                        break;
                    }
                    if (sourceReport.isSetTransactTime())//传送时间
                    {
                        report.TransactTime = sourceReport.getTransactTime().getValue();
                    }
                    if (sourceReport.isSetText())
                    {
                        report.Text = sourceReport.getText().getValue();
                    }
                    ExecutionReport(this, new SmartQuant.FIX.ExecutionReportEventArgs(report));
                }
                catch (Exception ex)
                {
                    EmitError(-1, -1, ex.Message);
                }
            }
        }
예제 #4
0
		private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission)
		{
			SmartQuant.FIX.ExecutionReport executionReport = new SmartQuant.FIX.ExecutionReport();
			executionReport.TransactTime = Clock.Now;
			executionReport.ClOrdID = record.Order.ClOrdID;
			executionReport.OrigClOrdID = record.Order.ClOrdID;
			executionReport.OrderID = record.Order.OrderID;
			executionReport.Symbol = record.Order.Symbol;
			executionReport.SecurityType = record.Order.SecurityType;
			executionReport.SecurityExchange = record.Order.SecurityExchange;
			executionReport.Currency = record.Order.Currency;
			executionReport.CommType = commType;
			executionReport.Commission = commission;
			executionReport.Side = record.Order.Side;
			if (ordStatus == OrdStatus.Replaced)
			{
				executionReport.OrdType = (record.Order.ReplaceOrder.ContainsField(40) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType);
				executionReport.TimeInForce = (record.Order.ReplaceOrder.ContainsField(59) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce);
				executionReport.OrderQty = (record.Order.ReplaceOrder.ContainsField(38) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty);
				executionReport.Price = (record.Order.ReplaceOrder.ContainsField(44) ? record.Order.ReplaceOrder.Price : record.Order.Price);
				executionReport.StopPx = (record.Order.ReplaceOrder.ContainsField(99) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx);
				record.LeavesQty = (int)executionReport.OrderQty - record.CumQty;
			}
			else
			{
				executionReport.OrdType = record.Order.OrdType;
				executionReport.TimeInForce = record.Order.TimeInForce;
				executionReport.OrderQty = record.Order.OrderQty;
				executionReport.Price = record.Order.Price;
				executionReport.StopPx = record.Order.StopPx;
			}
			executionReport.LastPx = lastPx;
			executionReport.LastQty = (double)lastQty;
			if (ordStatus == OrdStatus.Undefined)
			{
				record.AddFill(lastPx, lastQty);
				if (record.LeavesQty > 0)
				{
					ordStatus = OrdStatus.PartiallyFilled;
				}
				else
				{
					ordStatus = OrdStatus.Filled;
				}
			}
			executionReport.AvgPx = record.AvgPx;
			executionReport.CumQty = (double)record.CumQty;
			executionReport.LeavesQty = (double)record.LeavesQty;
			executionReport.ExecType = this.GetExecType(ordStatus);
			executionReport.OrdStatus = ordStatus;
			executionReport.Text = text;
			this.EmitExecutionReport(executionReport);
		}