/// <summary> /// Makes an order object /// </summary> /// <param name="executionReport"></param> /// <returns></returns> private Order PopulateOder(QuickFix.FIX42.ExecutionReport executionReport) { string orderSide = FixCommon.Converter.ConvertOrderSide.GetLocalOrderSide(executionReport.Side.getValue()); // Extract Order information Order order = new Order(_provider) { OrderID = executionReport.ExecType.getValue().Equals(ExecType.NEW) ? executionReport.ClOrdID.getValue() : executionReport.OrigClOrdID.getValue(), OrderSide = orderSide, OrderSize = Convert.ToInt32(executionReport.OrderQty.getValue(), CultureInfo.InvariantCulture), OrderTif = FixCommon.Converter.ConvertTif.GetLocalValue(executionReport.TimeInForce.getValue()) }; return(order); }
/// <summary> /// Makes an execution object /// </summary> /// <param name="executionReport"></param> /// <returns></returns> private Execution PopulateExecution(QuickFix.FIX42.ExecutionReport executionReport) { string orderSide = FixCommon.Converter.ConvertOrderSide.GetLocalOrderSide(executionReport.Side.getValue()); // Extract Fill information Fill fill = new Fill(new Security { Symbol = executionReport.Symbol.getValue() }, _provider, executionReport.ClOrdID.getValue()) { ExecutionDateTime = executionReport.TransactTime.getValue(), ExecutionType = executionReport.OrdStatus.getValue() == FixCommon.Constants.FixOrderStatus.Filled ? Constants.ExecutionType.Fill : Constants.ExecutionType.Partial, ExecutionId = executionReport.ExecID.getValue(), ExecutionPrice = Convert.ToDecimal(executionReport.AvgPx.getValue(), CultureInfo.InvariantCulture), ExecutionSize = Convert.ToInt32(executionReport.CumQty.getValue(), CultureInfo.InvariantCulture) - Convert.ToInt32(executionReport.LeavesQty.getValue(), CultureInfo.InvariantCulture), ExecutionSide = orderSide, AverageExecutionPrice = Convert.ToDecimal(executionReport.AvgPx.getValue(), CultureInfo.InvariantCulture), LeavesQuantity = Convert.ToInt32(executionReport.LeavesQty.getValue(), CultureInfo.InvariantCulture), CummalativeQuantity = Convert.ToInt32(executionReport.CumQty.getValue(), CultureInfo.InvariantCulture) }; // Extract Order information Order order = new Order(_provider) { OrderID = executionReport.ClOrdID.getValue(), OrderSide = orderSide, OrderSize = Convert.ToInt32(executionReport.OrderQty.getValue(), CultureInfo.InvariantCulture), OrderTif = FixCommon.Converter.ConvertTif.GetLocalValue(executionReport.TimeInForce.getValue()) }; return(new Execution(fill, order)); }
public void OnMessage(QuickFix.FIX42.ExecutionReport m, SessionID s) { _mainform._addMsg("Received execution report (4.2)\r\n"); string msg = "Order Dump Begin =======================\r\n"; msg += "\r\n"; msg += "OrdemInfo:\r\n"; msg += "==========\r\n"; msg += "Account .........: " + m.Account.getValue() + "\r\n"; msg += "Numero da ordem .: " + m.ClOrdID.getValue() + "\r\n"; msg += "Symbol ..........: " + m.Symbol.getValue() + "\r\n"; msg += "ExchangeNumber ..: " + m.OrderID.getValue() + "\r\n"; msg += "Status ..........: " + m.OrdStatus.getValue() + "\r\n"; msg += "Status ..........: " + FixMessageUtilities.TraduzirOrdemStatus(m.OrdStatus.getValue()) + "\r\n"; msg += "Quantidade ......: " + m.OrderQty.getValue() + "\r\n"; msg += "Qtde restante ...: " + (m.OrderQty.getValue() - m.CumQty.getValue()) + "\r\n"; if (m.IsSetLastPx()) { msg += "Preco ...........: " + m.LastPx.getValue() + "\r\n"; } if (m.IsSetText()) { msg += "Text ............: [" + m.Text.getValue() + "]\r\n"; } if (m.IsSetField(5149)) { msg += "Memo5149 ........: " + m.GetString(5149) + "\r\n"; } msg += "\r\n"; msg += "\r\nOrder Dump End =========================\r\n"; _mainform._addMsg(msg); }
/// <summary> /// Execution Report /// </summary> /// <param name="message"></param> /// <param name="sessionID"></param> private void OnMessage(QuickFix.FIX42.ExecutionReport message, SessionID sessionID) { try { if (Logger.IsDebugEnabled) { Logger.Debug( "Execution Report, OrderId=" + message.ClOrdID.getValue() + ", Exec Type=" + message.ExecType.getValue(), _type.FullName, "OnMessage"); } Order getOrder = (from order in _orders where order.OrderID == message.ClOrdID.getValue() select order) .FirstOrDefault(); switch (message.ExecType.getValue()) { case ExecType.NEW: if (getOrder != null) { if (NewArrived != null) { NewArrived((Order)getOrder.Clone()); } } break; case ExecType.REJECTED: if (getOrder != null) { Rejection rejection = new Rejection(getOrder.Security, getOrder.OrderExecutionProvider, message.TransactTime.getValue()); rejection.OrderId = getOrder.OrderID; if (OrderRejectionArrived != null) { OrderRejectionArrived(rejection); } } break; case ExecType.CANCELED: if (getOrder != null) { if (CancellationArrived != null) { CancellationArrived((Order)getOrder.Clone()); } _orders.Remove(getOrder); } break; case ExecType.PARTIAL_FILL: if (getOrder != null) { Fill fill = new Fill(new Security() { Symbol = message.Symbol.getValue() }, getOrder.OrderExecutionProvider, getOrder.OrderID); fill.ExecutionId = message.ExecID.getValue(); fill.ExecutionType = ExecutionType.Partial; fill.LeavesQuantity = Convert.ToInt32(message.LeavesQty.getValue()); fill.CummalativeQuantity = Convert.ToInt32(message.CumQty.getValue()); fill.ExecutionSize = Convert.ToInt32(message.LastShares.getValue()); fill.AverageExecutionPrice = Convert.ToInt32(message.AvgPx.getValue()); fill.ExecutionPrice = message.LastPx.getValue(); fill.ExecutionDateTime = message.TransactTime.getValue(); fill.ExecutionSide = getOrder.OrderSide; Order orderClone = (Order)getOrder.Clone(); orderClone.OrderStatus = OrderStatus.PARTIALLY_EXECUTED; Execution execution = new Execution(fill, orderClone); execution.OrderExecutionProvider = _provider; if (ExecutionArrived != null) { ExecutionArrived(execution); } } break; case ExecType.FILL: if (getOrder != null) { Fill fill = new Fill(new Security() { Symbol = message.Symbol.getValue() }, getOrder.OrderExecutionProvider, getOrder.OrderID); fill.ExecutionId = message.ExecID.getValue(); fill.ExecutionType = ExecutionType.Fill; fill.LeavesQuantity = Convert.ToInt32(message.LeavesQty.getValue()); fill.CummalativeQuantity = Convert.ToInt32(message.CumQty.getValue()); fill.ExecutionSize = Convert.ToInt32(message.LastShares.getValue()); fill.AverageExecutionPrice = Convert.ToInt32(message.AvgPx.getValue()); fill.ExecutionPrice = message.LastPx.getValue(); fill.ExecutionDateTime = message.TransactTime.getValue(); fill.ExecutionSide = getOrder.OrderSide; Order orderClone = (Order)getOrder.Clone(); orderClone.OrderStatus = OrderStatus.EXECUTED; Execution execution = new Execution(fill, orderClone); execution.OrderExecutionProvider = _provider; if (ExecutionArrived != null) { ExecutionArrived(execution); } _orders.Remove(getOrder); } break; } } catch (Exception exception) { Logger.Error(exception, _type.FullName, "OnMessage"); } }
/// <summary> /// /// </summary> /// <param name="executionReport">Execution report</param> /// <param name="sessionId">Session ID</param> private void OnMessage(QuickFix.FIX42.ExecutionReport executionReport, SessionID sessionId) { try { switch (executionReport.ExecType.getValue()) { case ExecType.NEW: { Order order = PopulateOder(executionReport); if (Logger.IsDebugEnabled) { Logger.Debug("New arrived : " + order, _type.FullName, "OnMessage"); } if (NewArrived != null) { NewArrived(order); } break; } case ExecType.CANCELED: { Order order = PopulateOder(executionReport); if (Logger.IsDebugEnabled) { Logger.Debug("Cancellation arrived : " + order, _type.FullName, "OnMessage"); } if (CancellationArrived != null) { CancellationArrived(order); } break; } case ExecType.REJECTED: var rejection = ExtractOrderRejection(executionReport); if (OrderRejectionArrived != null) { OrderRejectionArrived(rejection); } break; case '2': // Currenex has its own Trade Tag { Execution execution = PopulateExecution(executionReport); if (Logger.IsDebugEnabled) { Logger.Debug("Trade arrived : " + execution, _type.FullName, "OnMessage"); } if (ExecutionArrived != null) { ExecutionArrived(execution); } break; } } } catch (Exception exception) { Logger.Error(exception.ToString(), _type.FullName, "OnMessage"); } }